我正在尝试对包含通配符的目录进行存根(不知道影响文件夹命名方案的特定版本号)。我尝试使用double()并遇到问题,所以我想这可能是一个两步的process...in,我现在的迭代是用通配符显示文件,然后检查目录是否存在。我做错了什么吗?
it "Return 1.5 is Linux OS and correct version" do
Facter.fact(:kernel).stubs(:value).returns("linux")
dir = Dir.glob("/opt/athena-*/bin/runner")
Dir.exist?(dir).and_return(true)
Facter::Util::Resolution.stubs(:exec).with('runner -version').returns("Version: 1.5")
Facter.fact(:version).value.should == "1.5"
end发布于 2014-03-25 02:14:39
看起来你需要存根Dir.exist?
Dir.stub(:exist?).with(dir).and_return(true)但是,Dir.glob返回一个数组。也许你只想要第一个?:
dir = Dir.glob('/opt/athena-*/bin/runner').first我不清楚你想在这里测试什么。
https://stackoverflow.com/questions/22617845
复制相似问题