diff options
-rw-r--r-- | spec/unit/api_client_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/application_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife/cookbook_site_install_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/node/immutable_collections_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/provider/cron_spec.rb | 28 | ||||
-rw-r--r-- | spec/unit/provider/group_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/ohai_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/service/solaris_smf_service_spec.rb | 26 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 1 |
9 files changed, 43 insertions, 38 deletions
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index 8657fa59a8..76fc4afb5c 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -197,11 +197,11 @@ describe Chef::ApiClient do end it "preserves the admin status" do - @client.admin.should be_a_kind_of(Chef::TrueClass) + @client.admin.should be_a_kind_of(TrueClass) end it "preserves the 'validator' status" do - @client.validator.should be_a_kind_of(Chef::TrueClass) + @client.validator.should be_a_kind_of(TrueClass) end it "includes the private key if present" do diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 90e855e889..c73ebb2e21 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -85,6 +85,9 @@ describe Chef::Application do describe "configure_chef" do before do + # Silence warnings when no config file exists + Chef::Log.stub(:warn) + @app = Chef::Application.new #Chef::Config.stub(:merge!).and_return(true) @app.stub(:parse_options).and_return(true) @@ -108,6 +111,9 @@ describe Chef::Application do before do @app.config[:config_file] = config_location + + # force let binding to get evaluated or else we stub Pathname.new before we try to use it. + config_location_pathname Pathname.stub(:new).with(config_location).and_return(config_location_pathname) File.should_receive(:read). with(config_location). diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb index 3086c817d9..c756380a80 100644 --- a/spec/unit/knife/cookbook_site_install_spec.rb +++ b/spec/unit/knife/cookbook_site_install_spec.rb @@ -52,7 +52,7 @@ describe Chef::Knife::CookbookSiteInstall do end #Stubs for CookbookSCMRepo - @repo = stub(:sanity_check => true, :reset_to_default_state => true, + @repo = double(:sanity_check => true, :reset_to_default_state => true, :prepare_to_import => true, :finalize_updates_to => true, :merge_updates_from => true) Chef::Knife::CookbookSCMRepo.stub(:new).and_return(@repo) diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index d7abfa26e6..1c216e327a 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -76,7 +76,7 @@ describe Chef::Node::ImmutableMash do end it 'should allow mutation' do - lambda { @copy['m'] = 'm' }.should_not raise_error(Chef::Exceptions::ImmutableAttributeModification) + lambda { @copy['m'] = 'm' }.should_not raise_error end end @@ -97,7 +97,7 @@ describe Chef::Node::ImmutableMash do :shift ].each do |mutator| it "doesn't allow mutation via `#{mutator}'" do - lambda { @immutable_mash.send(mutator) }.should raise_error(Chef::Exceptions::ImmutableAttributeModification) + lambda { @immutable_mash.send(mutator) }.should raise_error end end @@ -154,7 +154,7 @@ describe Chef::Node::ImmutableArray do :unshift ].each do |mutator| it "does not allow mutation via `#{mutator}" do - lambda { @immutable_array.send(mutator)}.should raise_error(Chef::Exceptions::ImmutableAttributeModification) + lambda { @immutable_array.send(mutator)}.should raise_error end end @@ -190,7 +190,7 @@ describe Chef::Node::ImmutableArray do end it 'should allow mutation' do - lambda { @copy << 'm' }.should_not raise_error(Chef::Exceptions::ImmutableAttributeModification) + lambda { @copy << 'm' }.should_not raise_error end end diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index b78266fb25..460fb0ca6a 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -24,7 +24,7 @@ describe Chef::Provider::Cron do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Cron.new("cronhole some stuff", @run_context) @new_resource.user "root" @new_resource.minute "30" @@ -32,10 +32,10 @@ describe Chef::Provider::Cron do @new_resource.time :reboot @provider = Chef::Provider::Cron.new(@new_resource, @run_context) end - + context "with a matching entry in the user's crontab" do before :each do - @provider.stub!(:read_crontab).and_return(<<-CRONTAB) + @provider.stub(:read_crontab).and_return(<<-CRONTAB) 0 2 * * * /some/other/command # Chef Name: cronhole some stuff @@ -46,7 +46,7 @@ describe Chef::Provider::Cron do # Another comment CRONTAB end - + it "should set cron_exists" do @provider.load_current_resource @provider.cron_exists.should == true @@ -60,7 +60,7 @@ CRONTAB end it "should pull env vars out" do - @provider.stub!(:read_crontab).and_return(<<-CRONTAB) + @provider.stub(:read_crontab).and_return(<<-CRONTAB) 0 2 * * * /some/other/command # Chef Name: cronhole some stuff @@ -84,7 +84,7 @@ CRONTAB end it "should parse and load generic and standard environment variables from cron entry" do - @provider.stub!(:read_crontab).and_return(<<-CRONTAB) + @provider.stub(:read_crontab).and_return(<<-CRONTAB) # Chef Name: cronhole some stuff MAILTO=warn@example.com TEST=lol @@ -98,7 +98,7 @@ CRONTAB end it "should not break with variables that match the cron resource internals" do - @provider.stub!(:read_crontab).and_return(<<-CRONTAB) + @provider.stub(:read_crontab).and_return(<<-CRONTAB) # Chef Name: cronhole some stuff MINUTE=40 REBOOT=midnight @@ -116,11 +116,11 @@ CRONTAB Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'") @provider.load_current_resource end - + describe "action_create" do before :each do - @provider.stub!(:write_crontab) - @provider.stub!(:read_crontab).and_return(nil) + @provider.stub(:write_crontab) + @provider.stub(:read_crontab).and_return(nil) end context "when there is no existing crontab" do @@ -128,7 +128,7 @@ CRONTAB @provider.cron_exists = false @provider.cron_empty = true end - + it "should create a crontab with the entry" do @provider.should_receive(:write_crontab).with(<<-ENDCRON) # Chef Name: cronhole some stuff @@ -140,12 +140,12 @@ CRONTAB end end end - + before do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Cron.new("cronhole some stuff", @run_context) @new_resource.user "root" @new_resource.minute "30" @@ -417,7 +417,7 @@ CRONTAB @new_resource.send(:time, :reboot) @provider.cron_different?.should eql(true) end - + it "should return true if environment doesn't match" do @new_resource.environment "FOO" => "something_else" @provider.cron_different?.should eql(true) diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index b138f6b210..e467da751f 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -97,7 +97,7 @@ describe Chef::Provider::User do end it "should coerce an integer to a string for comparison" do - @current_resource.stub!(:gid).and_return("500") + @current_resource.stub(:gid).and_return("500") @provider.compare_group.should be_false end diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index 2085f44309..29c32e2690 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -41,8 +41,8 @@ describe Chef::Provider::Ohai do :newdata => "somevalue" } } - mock_ohai.stub!(:all_plugins).and_return(true) - mock_ohai.stub!(:data).and_return(mock_ohai[:data], + mock_ohai.stub(:all_plugins).and_return(true) + mock_ohai.stub(:data).and_return(mock_ohai[:data], mock_ohai[:data2]) Ohai::System.stub(:new).and_return(mock_ohai) Chef::Platform.stub(:find_platform_and_version).and_return({ "platform" => @platform, diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index af1351a4ff..8e66289a80 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -54,14 +54,14 @@ describe Chef::Provider::Service::Solaris do describe "when discovering the current service state" do it "should create a current resource with the name of the new resource" do - @provider.stub!(:shell_out!).with("/bin/svcs -l chef").and_return(@status) + @provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status) Chef::Resource::Service.should_receive(:new).and_return(@current_resource) @provider.load_current_resource end it "should return the current resource" do - @provider.stub!(:shell_out!).with("/bin/svcs -l chef").and_return(@status) + @provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status) @provider.load_current_resource.should eql(@current_resource) end @@ -71,27 +71,27 @@ describe Chef::Provider::Service::Solaris do end it "should mark service as not running" do - @provider.stub!(:shell_out!).and_return(@status) + @provider.stub(:shell_out!).and_return(@status) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end it "should mark service as running" do - @status = mock("Status", :exitstatus => 0, :stdout => 'state online') - @provider.stub!(:shell_out!).and_return(@status) + @status = double("Status", :exitstatus => 0, :stdout => 'state online') + @provider.stub(:shell_out!).and_return(@status) @current_resource.should_receive(:running).with(true) @provider.load_current_resource end it "should not mark service as maintenance" do - @provider.stub!(:shell_out!).and_return(@status) + @provider.stub(:shell_out!).and_return(@status) @provider.load_current_resource @provider.maintenance.should be_false end it "should mark service as maintenance" do - @status = mock("Status", :exitstatus => 0, :stdout => 'state maintenance') - @provider.stub!(:shell_out!).and_return(@status) + @status = double("Status", :exitstatus => 0, :stdout => 'state maintenance') + @provider.stub(:shell_out!).and_return(@status) @provider.load_current_resource @provider.maintenance.should be_true end @@ -104,7 +104,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef" do - @new_resource.stub!(:enable_command).and_return("#{@new_resource.enable_command}") + @new_resource.stub(:enable_command).and_return("#{@new_resource.enable_command}") @provider.should_not_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}") @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status) @provider.enable_service.should be_true @@ -112,7 +112,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm enable -s chef for start_service" do - @new_resource.stub!(:start_command).and_return("#{@new_resource.start_command}") + @new_resource.stub(:start_command).and_return("#{@new_resource.start_command}") @provider.should_not_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}") @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status) @provider.start_service.should be_true @@ -120,10 +120,10 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm clear chef for start_service when state maintenance" do - @status = mock("Status", :exitstatus => 0, :stdout => 'state maintenance') - @provider.stub!(:shell_out!).and_return(@status) + @status = double("Status", :exitstatus => 0, :stdout => 'state maintenance') + @provider.stub(:shell_out!).and_return(@status) @provider.load_current_resource - @new_resource.stub!(:enable_command).and_return("#{@new_resource.enable_command}") + @new_resource.stub(:enable_command).and_return("#{@new_resource.enable_command}") @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}").and_return(@status) @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status) @provider.enable_service.should be_true diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index c80f6971f1..ae00cd9b14 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -182,7 +182,6 @@ describe Chef::Resource::Mount do it "describes its state" do state = @resource.state - puts state state[:mount_point].should == "T:" state[:username].should == "Administrator" state[:password].should == "Jetstream123!" |