我正在编写一本运行部分搜索以在其他节点上查找属性的食谱。我的 chefspec 测试因错误而失败ERROR: Connection refused connecting to localhost:443
。搜索实例化如下:
describe 'my_recipe::default' do
let(:test1_node) do
stub_node('test1.com', platform: 'redhat', version: '6.3') do |node|
node.set['my_recipe']['id'] = 101
node.set['chef_environment'] = 'production'
end
end
let(:test2_node) do
stub_node('test2.com', platform: 'redhat', version: '6.3') do |node|
node.set['my_recipe']['id'] = 102
node.set['chef_environment'] = 'production'
end
end
before do
stub_search("node", "my_recipe:* AND chef_environment:production").and_return([])
end
let(:chef_run) do
ChefSpec::Runner.new do |node|
env = Chef::Environment.new
env.name 'production'
node.stub(:chef_environment).and_return(env.name)
Chef::Environment.stub(:load).and_return(env)
end.converge(described_recipe)
end
it 'updates the file' do
stub_search("node", "my_recipe:* AND chef_environment:production").and_return([test1_node,test2_node])
expect(chef_run).to create_template(/conf/my_recipe.cfg")
end
end
我不正确地存根吗?