diff options
Diffstat (limited to 'spec/unit/shell/shell_session_spec.rb')
-rw-r--r-- | spec/unit/shell/shell_session_spec.rb | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb index f49c9fc805..d72e3fa1bb 100644 --- a/spec/unit/shell/shell_session_spec.rb +++ b/spec/unit/shell/shell_session_spec.rb @@ -42,7 +42,7 @@ end describe Shell::ShellSession do it "is a singleton object" do - Shell::ShellSession.should include(Singleton) + expect(Shell::ShellSession).to include(Singleton) end end @@ -66,13 +66,13 @@ describe Shell::ClientSession do @session.instance_variable_set(:@client, @client) @expansion = Chef::RunList::RunListExpansion.new(@node.chef_environment, []) - @node.run_list.should_receive(:expand).with(@node.chef_environment).and_return(@expansion) - Chef::REST.should_receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest) + expect(@node.run_list).to receive(:expand).with(@node.chef_environment).and_return(@expansion) + expect(Chef::REST).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(@chef_rest) @session.rebuild_context end it "passes the shell CLI args to the client" do - Chef::Client.should_receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) + expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) @session.send(:rebuild_node) end @@ -90,30 +90,30 @@ describe Shell::StandAloneSession do end it "has a run_context" do - @session.run_context.should equal(@run_context) + expect(@session.run_context).to equal(@run_context) end it "returns a collection based on it's standalone recipe file" do - @session.resource_collection.should == @recipe.run_context.resource_collection + expect(@session.resource_collection).to eq(@recipe.run_context.resource_collection) end it "gives nil for the definitions (for now)" do - @session.definitions.should be_nil + expect(@session.definitions).to be_nil end it "gives nil for the cookbook_loader" do - @session.cookbook_loader.should be_nil + expect(@session.cookbook_loader).to be_nil end it "runs chef with the standalone recipe" do - @session.stub(:node_built?).and_return(true) - Chef::Log.stub(:level) + allow(@session).to receive(:node_built?).and_return(true) + allow(Chef::Log).to receive(:level) chef_runner = double("Chef::Runner.new", :converge => :converged) # pre-heat resource collection cache @session.resource_collection - Chef::Runner.should_receive(:new).with(@session.recipe.run_context).and_return(chef_runner) - @recipe.run_chef.should == :converged + expect(Chef::Runner).to receive(:new).with(@session.recipe.run_context).and_return(chef_runner) + expect(@recipe.run_chef).to eq(:converged) end it "passes the shell CLI args to the client" do @@ -123,7 +123,7 @@ describe Shell::StandAloneSession do :build_node => true, :register => true, :sync_cookbooks => {}) - Chef::Client.should_receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) + expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) @session.send(:rebuild_node) end @@ -147,39 +147,39 @@ describe Shell::SoloSession do end it "returns a collection based on it's compilation object and the extra recipe provided by chef-shell" do - @session.stub(:node_built?).and_return(true) + allow(@session).to receive(:node_built?).and_return(true) kitteh = Chef::Resource::Cat.new("keyboard") @recipe.run_context.resource_collection << kitteh - @session.resource_collection.should include(kitteh) + expect(@session.resource_collection).to include(kitteh) end it "returns definitions from its compilation object" do - @session.definitions.should == @run_context.definitions + expect(@session.definitions).to eq(@run_context.definitions) end it "keeps json attribs and passes them to the node for consumption" do @session.node_attributes = {"besnard_lakes" => "are_the_dark_horse"} - @session.node.besnard_lakes.should == "are_the_dark_horse" + expect(@session.node.besnard_lakes).to eq("are_the_dark_horse") #pending "1) keep attribs in an ivar 2) pass them to the node 3) feed them to the node on reset" end it "generates its resource collection from the compiled cookbooks and the ad hoc recipe" do - @session.stub(:node_built?).and_return(true) + allow(@session).to receive(:node_built?).and_return(true) kitteh_cat = Chef::Resource::Cat.new("kitteh") @run_context.resource_collection << kitteh_cat keyboard_cat = Chef::Resource::Cat.new("keyboard_cat") @recipe.run_context.resource_collection << keyboard_cat #@session.rebuild_collection - @session.resource_collection.should include(kitteh_cat, keyboard_cat) + expect(@session.resource_collection).to include(kitteh_cat, keyboard_cat) end it "runs chef with a resource collection from the compiled cookbooks" do - @session.stub(:node_built?).and_return(true) - Chef::Log.stub(:level) + allow(@session).to receive(:node_built?).and_return(true) + allow(Chef::Log).to receive(:level) chef_runner = double("Chef::Runner.new", :converge => :converged) - Chef::Runner.should_receive(:new).with(an_instance_of(Chef::RunContext)).and_return(chef_runner) + expect(Chef::Runner).to receive(:new).with(an_instance_of(Chef::RunContext)).and_return(chef_runner) - @recipe.run_chef.should == :converged + expect(@recipe.run_chef).to eq(:converged) end it "passes the shell CLI args to the client" do @@ -189,7 +189,7 @@ describe Shell::SoloSession do :build_node => true, :register => true, :sync_cookbooks => {}) - Chef::Client.should_receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) + expect(Chef::Client).to receive(:new).with(nil, Chef::Config[:shell_config]).and_return(@client) @session.send(:rebuild_node) end |