diff options
Diffstat (limited to 'spec/unit/lwrp_spec.rb')
-rw-r--r-- | spec/unit/lwrp_spec.rb | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 452e1da2a4..0fb0ea7cab 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -33,7 +33,7 @@ describe "LWRP" do describe "when overriding an existing class" do before :each do - $stderr.stub(:write) + allow($stderr).to receive(:write) end it "should log if attempting to load resource of same name" do @@ -42,8 +42,8 @@ describe "LWRP" do end Dir[File.expand_path( "lwrp/resources/*", CHEF_SPEC_DATA)].each do |file| - Chef::Log.should_receive(:info).with(/Skipping/) - Chef::Log.should_receive(:debug).with(/anymore/) + expect(Chef::Log).to receive(:info).with(/Skipping/) + expect(Chef::Log).to receive(:debug).with(/anymore/) Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) end end @@ -54,8 +54,8 @@ describe "LWRP" do end Dir[File.expand_path( "lwrp/providers/*", CHEF_SPEC_DATA)].each do |file| - Chef::Log.should_receive(:info).with(/Skipping/) - Chef::Log.should_receive(:debug).with(/anymore/) + expect(Chef::Log).to receive(:info).with(/Skipping/) + expect(Chef::Log).to receive(:debug).with(/anymore/) Chef::Provider::LWRPBase.build_from_file("lwrp", file, nil) end end @@ -67,11 +67,11 @@ describe "LWRP" do Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) end first_lwr_foo_class = Chef::Resource::LwrpFoo - Chef::Resource.resource_classes.should include(first_lwr_foo_class) + expect(Chef::Resource.resource_classes).to include(first_lwr_foo_class) Dir[File.expand_path( "lwrp/resources/*", CHEF_SPEC_DATA)].each do |file| Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) end - Chef::Resource.resource_classes.should include(first_lwr_foo_class) + expect(Chef::Resource.resource_classes).to include(first_lwr_foo_class) end it "does not attempt to remove classes from higher up namespaces [CHEF-4117]" do @@ -95,27 +95,27 @@ describe "LWRP" do end it "should load the resource into a properly-named class" do - Chef::Resource.const_get("LwrpFoo").should be_kind_of(Class) + expect(Chef::Resource.const_get("LwrpFoo")).to be_kind_of(Class) end it "should set resource_name" do - Chef::Resource::LwrpFoo.new("blah").resource_name.should eql(:lwrp_foo) + expect(Chef::Resource::LwrpFoo.new("blah").resource_name).to eql(:lwrp_foo) end it "should add the specified actions to the allowed_actions array" do - Chef::Resource::LwrpFoo.new("blah").allowed_actions.should include(:pass_buck, :twiddle_thumbs) + expect(Chef::Resource::LwrpFoo.new("blah").allowed_actions).to include(:pass_buck, :twiddle_thumbs) end it "should set the specified action as the default action" do - Chef::Resource::LwrpFoo.new("blah").action.should == :pass_buck + expect(Chef::Resource::LwrpFoo.new("blah").action).to eq(:pass_buck) end it "should create a method for each attribute" do - Chef::Resource::LwrpFoo.new("blah").methods.map{ |m| m.to_sym}.should include(:monkey) + expect(Chef::Resource::LwrpFoo.new("blah").methods.map{ |m| m.to_sym}).to include(:monkey) end it "should build attribute methods that respect validation rules" do - lambda { Chef::Resource::LwrpFoo.new("blah").monkey(42) }.should raise_error(ArgumentError) + expect { Chef::Resource::LwrpFoo.new("blah").monkey(42) }.to raise_error(ArgumentError) end it "should have access to the run context and node during class definition" do @@ -128,9 +128,9 @@ describe "LWRP" do end cls = Chef::Resource.const_get("LwrpNodeattr") - cls.node.should be_kind_of(Chef::Node) - cls.run_context.should be_kind_of(Chef::RunContext) - cls.node[:penguin_name].should eql("jackass") + expect(cls.node).to be_kind_of(Chef::Node) + expect(cls.run_context).to be_kind_of(Chef::RunContext) + expect(cls.node[:penguin_name]).to eql("jackass") end context "resource_name" do @@ -296,13 +296,13 @@ describe "LWRP" do end it "should load the provider into a properly-named class" do - Chef::Provider.const_get("LwrpBuckPasser").should be_kind_of(Class) + expect(Chef::Provider.const_get("LwrpBuckPasser")).to be_kind_of(Class) end it "should create a method for each attribute" do new_resource = double("new resource").as_null_object - Chef::Provider::LwrpBuckPasser.new(nil, new_resource).methods.map{|m|m.to_sym}.should include(:action_pass_buck) - Chef::Provider::LwrpThumbTwiddler.new(nil, new_resource).methods.map{|m|m.to_sym}.should include(:action_twiddle_thumbs) + expect(Chef::Provider::LwrpBuckPasser.new(nil, new_resource).methods.map{|m|m.to_sym}).to include(:action_pass_buck) + expect(Chef::Provider::LwrpThumbTwiddler.new(nil, new_resource).methods.map{|m|m.to_sym}).to include(:action_twiddle_thumbs) end it "should insert resources embedded in the provider into the middle of the resource collection" do @@ -316,10 +316,10 @@ describe "LWRP" do Chef::Runner.new(@run_context).converge - @run_context.resource_collection[0].should eql(injector) - @run_context.resource_collection[1].name.should eql(:prepared_thumbs) - @run_context.resource_collection[2].name.should eql(:twiddled_thumbs) - @run_context.resource_collection[3].should eql(dummy) + expect(@run_context.resource_collection[0]).to eql(injector) + expect(@run_context.resource_collection[1].name).to eql(:prepared_thumbs) + expect(@run_context.resource_collection[2].name).to eql(:twiddled_thumbs) + expect(@run_context.resource_collection[3]).to eql(dummy) end it "should insert embedded resources from multiple providers, including from the last position, properly into the resource collection" do @@ -340,13 +340,13 @@ describe "LWRP" do Chef::Runner.new(@run_context).converge - @run_context.resource_collection[0].should eql(injector) - @run_context.resource_collection[1].name.should eql(:prepared_thumbs) - @run_context.resource_collection[2].name.should eql(:twiddled_thumbs) - @run_context.resource_collection[3].should eql(dummy) - @run_context.resource_collection[4].should eql(injector2) - @run_context.resource_collection[5].name.should eql(:prepared_eyes) - @run_context.resource_collection[6].name.should eql(:dried_paint_watched) + expect(@run_context.resource_collection[0]).to eql(injector) + expect(@run_context.resource_collection[1].name).to eql(:prepared_thumbs) + expect(@run_context.resource_collection[2].name).to eql(:twiddled_thumbs) + expect(@run_context.resource_collection[3]).to eql(dummy) + expect(@run_context.resource_collection[4]).to eql(injector2) + expect(@run_context.resource_collection[5].name).to eql(:prepared_eyes) + expect(@run_context.resource_collection[6].name).to eql(:dried_paint_watched) end it "should properly handle a new_resource reference" do @@ -357,7 +357,7 @@ describe "LWRP" do provider = Chef::Platform.provider_for_resource(resource, :twiddle_thumbs) provider.action_twiddle_thumbs - provider.monkey_name.should == "my monkey's name is 'bob'" + expect(provider.monkey_name).to eq("my monkey's name is 'bob'") end it "should properly handle an embedded Resource accessing the enclosing Provider's scope" do @@ -369,7 +369,7 @@ describe "LWRP" do #provider = @runner.build_provider(resource) provider.action_twiddle_thumbs - provider.enclosed_resource.monkey.should == 'bob, the monkey' + expect(provider.enclosed_resource.monkey).to eq('bob, the monkey') end describe "when using inline compilation" do @@ -388,27 +388,27 @@ describe "LWRP" do it "does not add interior resources to the exterior resource collection" do @resource.run_action(:test) - @run_context.resource_collection.should be_empty + expect(@run_context.resource_collection).to be_empty end context "when interior resources are updated" do it "processes notifications within the LWRP provider's action" do @resource.run_action(:test) - $interior_ruby_block_2.should == "executed" + expect($interior_ruby_block_2).to eq("executed") end it "marks the parent resource updated" do @resource.run_action(:test) - @resource.should be_updated - @resource.should be_updated_by_last_action + expect(@resource).to be_updated + expect(@resource).to be_updated_by_last_action end end context "when interior resources are not updated" do it "does not mark the parent resource updated" do @resource.run_action(:no_updates) - @resource.should_not be_updated - @resource.should_not be_updated_by_last_action + expect(@resource).not_to be_updated + expect(@resource).not_to be_updated_by_last_action end end |