我正在编写一本食谱,它运行部分搜索以在其他节点上找到一个属性。我的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我是不是搞错了?
发布于 2014-05-30 21:30:12
stub_search是用来搜索主厨的。部分搜索是由食谱支持的,因此不是主厨核心的一部分。部分搜索使用不同的API端点,对协议使用POST而不是GET。
您需要对Chef的API调用进行存根,以进行部分搜索。stub_search将无法工作。
https://stackoverflow.com/questions/23937124
复制相似问题