Hi,
maybe I am doing it wrong, but stubbing with stub_search(:apps) raises Chef::Exceptions::PrivateKeyMissing!?
describe “#load_configurations” do
it ‘should return app configuration’ do
env = Chef::Environment.new
env.name 'production'
runner.node.stub(:chef_environment).and_return env.name
Chef::Environment.stub(:load).and_return env
# stub_search(:apps) { JSON.parse(File.read('fixutres/sauspiel.json')) }
chef_run
stub_search(:apps) { JSON.parse(File.read('fixutres/sauspiel.json')) }
w = NS::GameserverFrontend.new(runner.node, 'tcp', 'production')
w.load_configuration('sauspiel')
expect(w.app_configurations["sauspiel"]).to eq({"test" => "1"})
end
end
Any ideas?
Seems like it has something to do with upgrade to chefspec 3, because every stub on search raises the same exception now, even with Chef::Search::Query.any_instance.stub(:search)
It's working again if I downgrade to 2.0.1
Am 16.10.2013 um 13:45 schrieb Holger Amann holger@sauspiel.de:
Hi,
maybe I am doing it wrong, but stubbing with stub_search(:apps) raises Chef::Exceptions::PrivateKeyMissing!?
describe "#load_configurations" do
it 'should return app configuration' do
env = Chef::Environment.new
env.name 'production'
runner.node.stub(:chef_environment).and_return env.name
Chef::Environment.stub(:load).and_return env
# stub_search(:apps) { JSON.parse(File.read('fixutres/sauspiel.json')) }
chef_run
stub_search(:apps) { JSON.parse(File.read('fixutres/sauspiel.json')) }
w = NS::GameserverFrontend.new(runner.node, 'tcp', 'production')
w.load_configuration('sauspiel')
expect(w.app_configurations["sauspiel"]).to eq({"test" => "1"})
end
end
Any ideas?