diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-01-29 14:18:28 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-01-29 14:18:28 -0800 |
commit | db9f8dce667916cd6575d2894c8ca25006138836 (patch) | |
tree | e53990767d7a7b7e8c369cf546e298e1635788d9 /spec/unit | |
parent | b19b7d000887209f9d8dc1dc6aa468a0497a7391 (diff) | |
download | chef-db9f8dce667916cd6575d2894c8ca25006138836.tar.gz |
s/mock\(/double(/g
Diffstat (limited to 'spec/unit')
110 files changed, 347 insertions, 347 deletions
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index be98c86e55..845c217f72 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -50,7 +50,7 @@ describe Chef::ApiClient::Registration do end describe "when creating/updating the client on the server" do - let(:http_mock) { mock("Chef::REST mock") } + let(:http_mock) { double("Chef::REST mock") } before do registration.stub(:http_api).and_return(http_mock) @@ -125,7 +125,7 @@ describe Chef::ApiClient::Registration do describe "when registering a client" do - let(:http_mock) { mock("Chef::REST mock") } + let(:http_mock) { double("Chef::REST mock") } before do registration.stub(:http_api).and_return(http_mock) diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index 945e5ed70f..4ccd64bafe 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -189,7 +189,7 @@ describe Chef::ApiClient do describe "when requesting a new key" do before do - @http_client = mock("Chef::REST mock") + @http_client = double("Chef::REST mock") Chef::REST.stub(:new).and_return(@http_client) end diff --git a/spec/unit/application/apply.rb b/spec/unit/application/apply.rb index 4ada2b521c..32c98c6ed6 100644 --- a/spec/unit/application/apply.rb +++ b/spec/unit/application/apply.rb @@ -36,7 +36,7 @@ describe Chef::Application::Apply do before do @recipe_file_name = "foo.rb" @recipe_path = File.expand_path("foo.rb") - @recipe_file = mock("Tempfile (mock)", :read => @recipe_text) + @recipe_file = double("Tempfile (mock)", :read => @recipe_text) @app.stub(:open).with(@recipe_path).and_return(@recipe_file) File.stub(:exist?).with("foo.rb").and_return(true) Chef::Application.stub(:fatal!).and_return(true) diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb index e96be3e54f..1baaad110d 100644 --- a/spec/unit/application/knife_spec.rb +++ b/spec/unit/application/knife_spec.rb @@ -54,7 +54,7 @@ describe Chef::Application::Knife do it "should run a sub command with the applications command line option prototype" do with_argv(*%w{noop knife command with some args}) do - knife = mock(Chef::Knife) + knife = double(Chef::Knife) Chef::Knife.should_receive(:run).with(ARGV, @knife.options).and_return(knife) @knife.should_receive(:exit).with(0) @knife.run @@ -158,7 +158,7 @@ describe Chef::Application::Knife do it "should run a sub command with the applications command line option prototype" do with_argv(*%w{noop knife command with some args}) do - knife = mock(Chef::Knife) + knife = double(Chef::Knife) Chef::Knife.should_receive(:run).with(ARGV, @knife.options).and_return(knife) @knife.should_receive(:exit).with(0) @knife.run diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index cc32577218..d2f8b93169 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -108,7 +108,7 @@ describe Chef::Application::Solo do Chef::Config[:solo] = true Chef::Daemon.stub(:change_privilege) - @chef_client = mock("Chef::Client") + @chef_client = double("Chef::Client") Chef::Client.stub(:new).and_return(@chef_client) @app = Chef::Application::Solo.new # this is all stuff the reconfigure method needs diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 05be73f16d..cff887f631 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -157,7 +157,7 @@ describe Chef::Application do it "should initialise the chef logger" do Chef::Log.stub(:level=) - @monologger = mock("Monologger") + @monologger = double("Monologger") MonoLogger.should_receive(:new).with(Chef::Config[:log_location]).and_return(@monologger) Chef::Log.should_receive(:init).with(@monologger) @app.configure_logging diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 724b8ba451..378f0cb7b6 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -168,10 +168,10 @@ shared_examples_for Chef::Client do describe "run" do it "should identify the node and run ohai, then register the client" do - mock_chef_rest_for_node = mock("Chef::REST (node)") - mock_chef_rest_for_cookbook_sync = mock("Chef::REST (cookbook sync)") - mock_chef_rest_for_node_save = mock("Chef::REST (node save)") - mock_chef_runner = mock("Chef::Runner") + mock_chef_rest_for_node = double("Chef::REST (node)") + mock_chef_rest_for_cookbook_sync = double("Chef::REST (cookbook sync)") + mock_chef_rest_for_node_save = double("Chef::REST (node save)") + mock_chef_runner = double("Chef::Runner") # --Client.register # Make sure Client#register thinks the client key doesn't @@ -253,10 +253,10 @@ shared_examples_for Chef::Client do end it "should remove the run_lock on failure of #load_node" do - @run_lock = mock("Chef::RunLock", :acquire => true) + @run_lock = double("Chef::RunLock", :acquire => true) Chef::RunLock.stub(:new).and_return(@run_lock) - @events = mock("Chef::EventDispatch::Dispatcher").as_null_object + @events = double("Chef::EventDispatch::Dispatcher").as_null_object Chef::EventDispatch::Dispatcher.stub(:new).and_return(@events) # @events is created on Chef::Client.new, so we need to recreate it after mocking @@ -324,7 +324,7 @@ shared_examples_for Chef::Client do # build_node will call Node#expand! with server, which will # eventually hit the server to expand the included role. - mock_chef_rest = mock("Chef::REST") + mock_chef_rest = double("Chef::REST") mock_chef_rest.should_receive(:get_rest).with("roles/role_containing_cookbook1").and_return(role_containing_cookbook1) Chef::REST.should_receive(:new).and_return(mock_chef_rest) @@ -434,7 +434,7 @@ shared_examples_for Chef::Client do original_runlist = @node.run_list.dup - mock_chef_rest = mock("Chef::REST") + mock_chef_rest = double("Chef::REST") mock_chef_rest.should_receive(:get_rest).with("roles/test_role").and_return(override_role) Chef::REST.should_receive(:new).and_return(mock_chef_rest) diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 3e015058c1..c52593287a 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -14,7 +14,7 @@ describe Chef::CookbookCacheCleaner do end it "removes all files not validated during the chef run" do - file_cache = mock("Chef::FileCache with files from unused cookbooks") + file_cache = double("Chef::FileCache with files from unused cookbooks") unused_template_files = %w{cookbooks/unused/templates/default/foo.conf.erb cookbooks/unused/tempaltes/default/bar.conf.erb} valid_cached_cb_files = %w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb} @cleaner.mark_file_as_valid('cookbooks/valid1/recipes/default.rb') @@ -81,7 +81,7 @@ describe Chef::CookbookSynchronizer do context "when the cache contains unneeded cookbooks" do before do - @file_cache = mock("Chef::FileCache with files from unused cookbooks") + @file_cache = double("Chef::FileCache with files from unused cookbooks") @valid_cached_cb_files = %w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb} @obsolete_cb_files = %w{cookbooks/old1/recipes/default.rb cookbooks/old2/recipes/default.rb} @@ -105,16 +105,16 @@ describe Chef::CookbookSynchronizer do # the state is a PITA and tests for this behavior are above. @synchronizer.stub(:clear_obsoleted_cookbooks) - @server_api = mock("Chef::REST (mock)") - @file_cache = mock("Chef::FileCache (mock)") + @server_api = double("Chef::REST (mock)") + @file_cache = double("Chef::FileCache (mock)") @synchronizer.stub(:server_api).and_return(@server_api) @synchronizer.stub(:cache).and_return(@file_cache) - @cookbook_a_default_recipe_tempfile = mock("Tempfile for cookbook_a default.rb recipe", + @cookbook_a_default_recipe_tempfile = double("Tempfile for cookbook_a default.rb recipe", :path => "/tmp/cookbook_a_recipes_default_rb") - @cookbook_a_default_attribute_tempfile = mock("Tempfile for cookbook_a default.rb attr file", + @cookbook_a_default_attribute_tempfile = double("Tempfile for cookbook_a default.rb attr file", :path => "/tmp/cookbook_a_attributes_default_rb") end @@ -171,9 +171,9 @@ describe Chef::CookbookSynchronizer do @synchronizer.stub(:cache).and_return(@file_cache) @synchronizer.stub(:clear_obsoleted_cookbooks) - @cookbook_a_file_default_tempfile = mock("Tempfile for cookbook_a megaman.conf file", + @cookbook_a_file_default_tempfile = double("Tempfile for cookbook_a megaman.conf file", :path => "/tmp/cookbook_a_file_default_tempfile") - @cookbook_a_template_default_tempfile = mock("Tempfile for cookbook_a apache.conf.erb template", + @cookbook_a_template_default_tempfile = double("Tempfile for cookbook_a apache.conf.erb template", :path => "/tmp/cookbook_a_template_default_tempfile") end diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index d972fa7a4a..ea6bc95df8 100644 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -123,8 +123,8 @@ describe Chef::Daemon do Process::UID.stub(:change_privilege).and_return(nil) Process::GID.stub(:change_privilege).and_return(nil) - @pw_user = mock("Struct::Passwd", :uid => 501) - @pw_group = mock("Struct::Group", :gid => 20) + @pw_user = double("Struct::Passwd", :uid => 501) + @pw_group = double("Struct::Group", :gid => 20) Process.stub(:initgroups).and_return(true) diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 7a0d3575fb..109cd76ef8 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -203,7 +203,7 @@ describe Chef::DataBagItem do describe "save" do before do - @rest = mock("Chef::REST") + @rest = double("Chef::REST") Chef::REST.stub(:new).and_return(@rest) @data_bag_item['id'] = "heart of darkness" raw_data = {"id" => "heart_of_darkness", "author" => "Conrad"} @@ -216,7 +216,7 @@ describe Chef::DataBagItem do end it "should create if the item is not found" do - exception = mock("404 error", :code => "404") + exception = double("404 error", :code => "404") @rest.should_receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception)) @rest.should_receive(:post_rest).with("data/books", @data_bag_item) @data_bag_item.save @@ -247,7 +247,7 @@ describe Chef::DataBagItem do describe "from an API call" do before do - @http_client = mock("Chef::REST") + @http_client = double("Chef::REST") Chef::REST.stub(:new).and_return(@http_client) end diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index 8b3c0d71ad..4ac843c869 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -78,12 +78,12 @@ describe Chef::DataBag do describe "when saving" do before do @data_bag.name('piggly_wiggly') - @rest = mock("Chef::REST") + @rest = double("Chef::REST") Chef::REST.stub(:new).and_return(@rest) end it "should silently proceed when the data bag already exists" do - exception = mock("409 error", :code => "409") + exception = double("409 error", :code => "409") @rest.should_receive(:post_rest).and_raise(Net::HTTPServerException.new("foo", exception)) @data_bag.save end @@ -111,7 +111,7 @@ describe Chef::DataBag do describe "from an API call" do before do Chef::Config[:chef_server_url] = 'https://myserver.example.com' - @http_client = mock('Chef::REST') + @http_client = double('Chef::REST') end it "should get the data bag from the server" do diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb index c0c4feee19..ebbcdd9861 100644 --- a/spec/unit/environment_spec.rb +++ b/spec/unit/environment_spec.rb @@ -355,16 +355,16 @@ describe Chef::Environment do describe "api model" do before(:each) do - @rest = mock("Chef::REST") + @rest = double("Chef::REST") Chef::REST.stub(:new).and_return(@rest) - @query = mock("Chef::Search::Query") + @query = double("Chef::Search::Query") Chef::Search::Query.stub(:new).and_return(@query) end describe "list" do describe "inflated" do it "should return a hash of environment names and objects" do - e1 = mock("Chef::Environment", :name => "one") + e1 = double("Chef::Environment", :name => "one") @query.should_receive(:search).with(:environment).and_yield(e1) r = Chef::Environment.list(true) r["one"].should == e1 diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb index add56bcb6d..4e257c2a22 100644 --- a/spec/unit/file_access_control_spec.rb +++ b/spec/unit/file_access_control_spec.rb @@ -36,7 +36,7 @@ describe Chef::FileAccessControl do @run_context = Chef::RunContext.new(@node, {}, @events) @current_resource = Chef::Resource::File.new('/tmp/different_file.txt') @provider_requirements = Chef::Provider::ResourceRequirements.new(@resource, @run_context) - @provider = mock("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false) + @provider = double("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false) @fac = Chef::FileAccessControl.new(@current_resource, @resource, @provider) end diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb index 0a0b1f899a..a4c814951d 100644 --- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb @@ -79,8 +79,8 @@ describe Chef::FileContentManagement::Deploy::MvWindows do context "when run with administrator privileges" do - let(:original_target_file_owner) { mock("original target file owner") } - let(:original_target_file_group) { mock("original target file group") } + let(:original_target_file_owner) { double("original target file owner") } + let(:original_target_file_group) { double("original target file group") } let(:target_file_security_descriptor) do mock "security descriptor for target file", @@ -116,17 +116,17 @@ describe Chef::FileContentManagement::Deploy::MvWindows do end context "and the target has a dacl and sacl" do - let(:inherited_dacl_ace) { mock("Windows dacl ace (inherited)", :inherited? => true) } - let(:not_inherited_dacl_ace) { mock("Windows dacl ace (not inherited)", :inherited? => false) } + let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", :inherited? => true) } + let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", :inherited? => false) } let(:original_target_file_dacl) { [inherited_dacl_ace, not_inherited_dacl_ace] } - let(:inherited_sacl_ace) { mock("Windows sacl ace (inherited)", :inherited? => true) } - let(:not_inherited_sacl_ace) { mock("Windows sacl ace (not inherited)", :inherited? => false) } + let(:inherited_sacl_ace) { double("Windows sacl ace (inherited)", :inherited? => true) } + let(:not_inherited_sacl_ace) { double("Windows sacl ace (not inherited)", :inherited? => false) } let(:original_target_file_sacl) { [inherited_sacl_ace, not_inherited_sacl_ace] } - let(:custom_dacl) { mock("Windows ACL for non-inherited dacl aces") } - let(:custom_sacl) { mock("Windows ACL for non-inherited sacl aces") } + let(:custom_dacl) { double("Windows ACL for non-inherited dacl aces") } + let(:custom_sacl) { double("Windows ACL for non-inherited sacl aces") } before do target_file_security_descriptor.stub(:dacl_present?).and_return(true) diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb index 8ddc5200b0..69c55ba015 100644 --- a/spec/unit/knife/client_create_spec.rb +++ b/spec/unit/knife/client_create_spec.rb @@ -63,7 +63,7 @@ describe Chef::Knife::ClientCreate do it "should write the private key to a file" do @knife.config[:file] = "/tmp/monkeypants" @client.stub(:save).and_return({ 'private_key' => "woot" }) - filehandle = mock("Filehandle") + filehandle = double("Filehandle") filehandle.should_receive(:print).with('woot') File.should_receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle) @knife.run diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb index b03071b973..daf18d5d25 100644 --- a/spec/unit/knife/client_reregister_spec.rb +++ b/spec/unit/knife/client_reregister_spec.rb @@ -22,7 +22,7 @@ describe Chef::Knife::ClientReregister do before(:each) do @knife = Chef::Knife::ClientReregister.new @knife.name_args = [ 'adam' ] - @client_mock = mock('client_mock', :private_key => "foo_key") + @client_mock = double('client_mock', :private_key => "foo_key") @stdout = StringIO.new @knife.ui.stub(:stdout).and_return(@stdout) end diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb index ce5f93ab5f..b5c95db097 100644 --- a/spec/unit/knife/client_show_spec.rb +++ b/spec/unit/knife/client_show_spec.rb @@ -22,7 +22,7 @@ describe Chef::Knife::ClientShow do before(:each) do @knife = Chef::Knife::ClientShow.new @knife.name_args = [ 'adam' ] - @client_mock = mock('client_mock') + @client_mock = double('client_mock') end describe 'run' do diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index d6842ca2c6..eab42fadd5 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -6,7 +6,7 @@ describe Chef::Knife::Configure do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::Configure.new - @rest_client = mock("null rest client", :post_rest => { :result => :true }) + @rest_client = double("null rest client", :post_rest => { :result => :true }) @knife.stub(:rest).and_return(@rest_client) @out = StringIO.new diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index 2dcc276ad2..0cff690bc2 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -34,7 +34,7 @@ describe Chef::Knife::CookbookBulkDelete do cookbook = Chef::CookbookVersion.new(cookbook_name) @cookbooks[cookbook_name] = cookbook end - @rest = mock("Chef::REST") + @rest = double("Chef::REST") @rest.stub(:get_rest).and_return(@cookbooks) @rest.stub(:delete_rest).and_return(true) @knife.stub(:rest).and_return(@rest) diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb index 79ec6769ec..f4ba46f513 100644 --- a/spec/unit/knife/cookbook_delete_spec.rb +++ b/spec/unit/knife/cookbook_delete_spec.rb @@ -125,7 +125,7 @@ describe Chef::Knife::CookbookDelete do describe 'available_versions' do before(:each) do - @rest_mock = mock('rest') + @rest_mock = double('rest') @knife.should_receive(:rest).and_return(@rest_mock) @cookbook_data = { 'foobar' => { 'versions' => [{'version' => '1.0.0'}, {'version' => '1.1.0'}, diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index 96b5a860b3..efab98f646 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -44,7 +44,7 @@ describe Chef::Knife::CookbookDownload do before(:each) do @knife.name_args = ['foobar'] @knife.config[:download_directory] = '/var/tmp/chef' - @rest_mock = mock('rest') + @rest_mock = double('rest') @knife.stub(:rest).and_return(@rest_mock) @manifest_data = { @@ -66,7 +66,7 @@ describe Chef::Knife::CookbookDownload do ] } - @cookbook_mock = mock('cookbook') + @cookbook_mock = double('cookbook') @cookbook_mock.stub(:version).and_return('1.0.0') @cookbook_mock.stub(:manifest).and_return(@manifest_data) @rest_mock.should_receive(:get_rest).with('cookbooks/foobar/1.0.0'). @@ -87,7 +87,7 @@ describe Chef::Knife::CookbookDownload do @files = @manifest_data.values.map { |v| v.map { |i| i['path'] } }.flatten.uniq @files_mocks = {} @files.map { |f| File.basename(f) }.flatten.uniq.each do |f| - @files_mocks[f] = mock("#{f}_mock") + @files_mocks[f] = double("#{f}_mock") @files_mocks[f].stub(:path).and_return("/var/tmp/#{f}") end end diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb index 5482d5d33c..9ff16edb37 100644 --- a/spec/unit/knife/cookbook_list_spec.rb +++ b/spec/unit/knife/cookbook_list_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Knife::CookbookList do before do @knife = Chef::Knife::CookbookList.new - @rest_mock = mock('rest') + @rest_mock = double('rest') @knife.stub(:rest).and_return(@rest_mock) @cookbook_names = ['apache2', 'mysql'] @base_url = 'https://server.example.com/cookbooks' diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb index 11d8613590..92db650435 100644 --- a/spec/unit/knife/cookbook_metadata_spec.rb +++ b/spec/unit/knife/cookbook_metadata_spec.rb @@ -105,8 +105,8 @@ describe Chef::Knife::CookbookMetadata do describe 'generate_metadata_from_file' do before(:each) do - @metadata_mock = mock('metadata') - @json_file_mock = mock('json_file') + @metadata_mock = double('metadata') + @json_file_mock = double('json_file') end it 'should generate the metatdata json from metatdata.rb' do diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb index 44f7064a64..b862c3154c 100644 --- a/spec/unit/knife/cookbook_show_spec.rb +++ b/spec/unit/knife/cookbook_show_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::CookbookShow do @knife = Chef::Knife::CookbookShow.new @knife.config = { } @knife.name_args = [ "cookbook_name" ] - @rest = mock(Chef::REST) + @rest = double(Chef::REST) @knife.stub(:rest).and_return(@rest) @knife.stub(:pretty_print).and_return(true) @knife.stub(:output).and_return(true) diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index b89223b1eb..14c4262cb3 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::CookbookSiteShare do @cookbook = Chef::CookbookVersion.new('cookbook_name') - @cookbook_loader = mock('Chef::CookbookLoader') + @cookbook_loader = double('Chef::CookbookLoader') @cookbook_loader.stub(:cookbook_exists?).and_return(true) @cookbook_loader.stub(:[]).and_return(@cookbook) Chef::CookbookLoader.stub(:new).and_return(@cookbook_loader) @@ -98,7 +98,7 @@ describe Chef::Knife::CookbookSiteShare do describe 'do_upload' do before(:each) do - @upload_response = mock('Net::HTTPResponse') + @upload_response = double('Net::HTTPResponse') Chef::CookbookSiteStreamingUploader.stub(:post).and_return(@upload_response) @stdout = StringIO.new diff --git a/spec/unit/knife/cookbook_site_unshare_spec.rb b/spec/unit/knife/cookbook_site_unshare_spec.rb index 65318f03e0..14cda65b43 100644 --- a/spec/unit/knife/cookbook_site_unshare_spec.rb +++ b/spec/unit/knife/cookbook_site_unshare_spec.rb @@ -26,7 +26,7 @@ describe Chef::Knife::CookbookSiteUnshare do @knife.name_args = ['cookbook_name'] @knife.stub(:confirm).and_return(true) - @rest = mock('Chef::REST') + @rest = double('Chef::REST') @rest.stub(:delete_rest).and_return(true) @knife.stub(:rest).and_return(@rest) @stdout = StringIO.new @@ -55,14 +55,14 @@ describe Chef::Knife::CookbookSiteUnshare do end it 'should log an error and exit when forbidden' do - exception = mock('403 "Forbidden"', :code => '403') + exception = double('403 "Forbidden"', :code => '403') @rest.stub(:delete_rest).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception)) @knife.ui.should_receive(:error) lambda { @knife.run }.should raise_error(SystemExit) end it 'should re-raise any non-forbidden errors on delete_rest' do - exception = mock('500 "Application Error"', :code => '500') + exception = double('500 "Application Error"', :code => '500') @rest.stub(:delete_rest).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception)) lambda { @knife.run }.should raise_error(Net::HTTPServerException) end diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index f550b82835..d62fb0ffc9 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -62,7 +62,7 @@ describe Chef::Knife::UI do before do @ui.config[:disable_editing] = false @ui.config[:editor] = my_editor - @mock = mock('Tempfile') + @mock = double('Tempfile') @mock.should_receive(:sync=).with(true) @mock.should_receive(:puts).with(json_from_ruby) @mock.should_receive(:close) diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb index 534bc18f5c..866ca99174 100644 --- a/spec/unit/knife/data_bag_edit_spec.rb +++ b/spec/unit/knife/data_bag_edit_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::DataBagEdit do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::DataBagEdit.new - @rest = mock('chef-rest-mock') + @rest = double('chef-rest-mock') @knife.stub(:rest).and_return(@rest) @stdout = StringIO.new diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb index aa1c16d0f4..8537045164 100644 --- a/spec/unit/knife/data_bag_from_file_spec.rb +++ b/spec/unit/knife/data_bag_from_file_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::DataBagFromFile do before :each do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::DataBagFromFile.new - @rest = mock("Chef::REST") + @rest = double("Chef::REST") @knife.stub(:rest).and_return(@rest) @stdout = StringIO.new @knife.ui.stub(:stdout).and_return(@stdout) diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb index 669dfeb5cc..d8d1077d0d 100644 --- a/spec/unit/knife/data_bag_show_spec.rb +++ b/spec/unit/knife/data_bag_show_spec.rb @@ -29,7 +29,7 @@ describe Chef::Knife::DataBagShow do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::DataBagShow.new @knife.config[:format] = 'json' - @rest = mock("Chef::REST") + @rest = double("Chef::REST") @knife.stub(:rest).and_return(@rest) @stdout = StringIO.new @knife.ui.stub(:stdout).and_return(@stdout) diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb index 251b525da1..3a8ec00651 100644 --- a/spec/unit/knife/index_rebuild_spec.rb +++ b/spec/unit/knife/index_rebuild_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Knife::IndexRebuild do let(:knife){Chef::Knife::IndexRebuild.new} - let(:rest_client){mock(Chef::REST)} + let(:rest_client){double(Chef::REST)} let(:stub_rest!) do knife.should_receive(:rest).and_return(rest_client) diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb index 680868d53c..6d8d9d5b25 100644 --- a/spec/unit/knife/status_spec.rb +++ b/spec/unit/knife/status_spec.rb @@ -25,7 +25,7 @@ describe Chef::Knife::Status do n.automatic_attrs["fqdn"] = "foobar" n.automatic_attrs["ohai_time"] = 1343845969 end - query = mock("Chef::Search::Query") + query = double("Chef::Search::Query") query.stub(:search).and_yield(node) Chef::Search::Query.stub(:new).and_return(query) @knife = Chef::Knife::Status.new diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb index 00a570e4c8..cc803e99ce 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -78,7 +78,7 @@ describe Chef::Knife::UserCreate do it "writes the private key to a file when --file is specified" do @knife.config[:file] = "/tmp/a_file" - filehandle = mock("filehandle") + filehandle = double("filehandle") filehandle.should_receive(:print).with('private_key') File.should_receive(:open).with("/tmp/a_file", "w").and_yield(filehandle) @knife.run diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb index 16d57042f0..1cbbdb47d2 100644 --- a/spec/unit/knife/user_reregister_spec.rb +++ b/spec/unit/knife/user_reregister_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::UserReregister do Chef::Knife::UserReregister.load_deps @knife = Chef::Knife::UserReregister.new @knife.name_args = [ 'a_user' ] - @user_mock = mock('user_mock', :private_key => "private_key") + @user_mock = double('user_mock', :private_key => "private_key") Chef::User.stub(:load).and_return(@user_mock) @stdout = StringIO.new @knife.ui.stub(:stdout).and_return(@stdout) diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb index f2bd959d15..af8485ad7d 100644 --- a/spec/unit/knife/user_show_spec.rb +++ b/spec/unit/knife/user_show_spec.rb @@ -23,7 +23,7 @@ describe Chef::Knife::UserShow do Chef::Knife::UserShow.load_deps @knife = Chef::Knife::UserShow.new @knife.name_args = [ 'my_user' ] - @user_mock = mock('user_mock') + @user_mock = double('user_mock') end it 'loads and displays the user' do diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 79f22852ae..9e56b9fe1c 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -179,7 +179,7 @@ describe "LWRP" do end it "should create a method for each attribute" do - new_resource = mock("new resource", :null_object=>true) + new_resource = double("new resource", :null_object=>true) 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) end diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb index b701dd6a50..54689c9992 100644 --- a/spec/unit/mixin/checksum_spec.rb +++ b/spec/unit/mixin/checksum_spec.rb @@ -29,7 +29,7 @@ describe Chef::Mixin::Checksum do @checksum_user = Chef::CMCCheck.new @cache = Chef::Digester.instance @file = CHEF_SPEC_DATA + "/checksum/random.txt" - @stat = mock("File::Stat", { :mtime => Time.at(0) }) + @stat = double("File::Stat", { :mtime => Time.at(0) }) File.stub(:stat).and_return(@stat) end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index d21059c9dd..f2a78f87cd 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -764,16 +764,16 @@ describe Chef::Node do describe "api model" do before(:each) do - @rest = mock("Chef::REST") + @rest = double("Chef::REST") Chef::REST.stub(:new).and_return(@rest) - @query = mock("Chef::Search::Query") + @query = double("Chef::Search::Query") Chef::Search::Query.stub(:new).and_return(@query) end describe "list" do describe "inflated" do it "should return a hash of node names and objects" do - n1 = mock("Chef::Node", :name => "one") + n1 = double("Chef::Node", :name => "one") @query.should_receive(:search).with(:node).and_yield(n1) r = Chef::Node.list(true) r["one"].should == n1 @@ -818,7 +818,7 @@ describe Chef::Node do it "should create if it cannot update" do node.name("monkey") - exception = mock("404 error", :code => "404") + exception = double("404 error", :code => "404") @rest.should_receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception)) @rest.should_receive(:post_rest).with("nodes", node) node.save diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb index ebdefd9bea..05f3e8e0ed 100644 --- a/spec/unit/provider/breakpoint_spec.rb +++ b/spec/unit/provider/breakpoint_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::Breakpoint do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @collection = mock("resource collection") + @collection = double("resource collection") @run_context.stub(:resource_collection).and_return(@collection) @provider = Chef::Provider::Breakpoint.new(@resource, @run_context) end @@ -36,7 +36,7 @@ describe Chef::Provider::Breakpoint do it "gets the iterator from @collection and pauses it" do Shell.stub(:running?).and_return(true) - @iterator = mock("stepable_iterator") + @iterator = double("stepable_iterator") @collection.stub(:iterator).and_return(@iterator) @iterator.should_receive(:pause) @provider.action_break @@ -45,7 +45,7 @@ describe Chef::Provider::Breakpoint do it "doesn't pause the iterator if chef-shell isn't running" do Shell.stub(:running?).and_return(false) - @iterator = mock("stepable_iterator") + @iterator = double("stepable_iterator") @collection.stub(:iterator).and_return(@iterator) @iterator.should_not_receive(:pause) @provider.action_break diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb index d2f1d3aef2..ed8942aaf2 100644 --- a/spec/unit/provider/cookbook_file/content_spec.rb +++ b/spec/unit/provider/cookbook_file/content_spec.rb @@ -20,10 +20,10 @@ require 'spec_helper' describe Chef::Provider::CookbookFile::Content do - let(:new_resource) { mock('Chef::Resource::CookbookFile (new)', :cookbook_name => 'apache2', :cookbook => 'apache2') } + let(:new_resource) { double('Chef::Resource::CookbookFile (new)', :cookbook_name => 'apache2', :cookbook => 'apache2') } let(:content) do - @run_context = mock('Chef::RunContext') - @current_resource = mock('Chef::Resource::CookbookFile (current)') + @run_context = double('Chef::RunContext') + @current_resource = double('Chef::Resource::CookbookFile (current)') Chef::Provider::CookbookFile::Content.new(new_resource, @current_resource, @run_context) end diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb index 05509fbae4..131fca2ba6 100644 --- a/spec/unit/provider/cookbook_file_spec.rb +++ b/spec/unit/provider/cookbook_file_spec.rb @@ -49,7 +49,7 @@ describe Chef::Provider::CookbookFile do end let(:content) do - content = mock('Chef::Provider::CookbookFile::Content') + content = double('Chef::Provider::CookbookFile::Content') end it_behaves_like Chef::Provider::File diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb index 1683fad7a1..60e09baceb 100644 --- a/spec/unit/provider/cron/unix_spec.rb +++ b/spec/unit/provider/cron/unix_spec.rb @@ -39,7 +39,7 @@ describe Chef::Provider::Cron::Unix do describe "read_crontab" do before :each do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stdout = StringIO.new(<<-CRONTAB) 0 2 * * * /some/other/command @@ -69,13 +69,13 @@ CRONTAB end it "should return nil if the user has no crontab" do - status = mock("Status", :exitstatus => 1) + status = double("Status", :exitstatus => 1) @provider.stub(:popen4).and_return(status) @provider.send(:read_crontab).should == nil end it "should raise an exception if another error occurs" do - status = mock("Status", :exitstatus => 2) + status = double("Status", :exitstatus => 2) @provider.stub(:popen4).and_return(status) lambda do @provider.send(:read_crontab) @@ -85,9 +85,9 @@ CRONTAB describe "write_crontab" do before :each do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.stub(:run_command_and_return_stdout_stderr).and_return(@status, String.new, String.new) - @tempfile = mock("foo", :path => "/tmp/foo", :close => true) + @tempfile = double("foo", :path => "/tmp/foo", :close => true) Tempfile.stub(:new).and_return(@tempfile) @tempfile.should_receive(:flush) @tempfile.should_receive(:chmod).with(420) diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index ce5f0b7bf9..3a7a96c549 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -748,7 +748,7 @@ MAILTO=foo@example.com describe "read_crontab" do before :each do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stdout = StringIO.new(<<-CRONTAB) 0 2 * * * /some/other/command @@ -778,13 +778,13 @@ MAILTO=foo@example.com end it "should return nil if the user has no crontab" do - status = mock("Status", :exitstatus => 1) + status = double("Status", :exitstatus => 1) @provider.stub(:popen4).and_return(status) @provider.send(:read_crontab).should == nil end it "should raise an exception if another error occurs" do - status = mock("Status", :exitstatus => 2) + status = double("Status", :exitstatus => 2) @provider.stub(:popen4).and_return(status) lambda do @provider.send(:read_crontab) @@ -794,7 +794,7 @@ MAILTO=foo@example.com describe "write_crontab" do before :each do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stdin = StringIO.new @provider.stub(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status) end diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb index 4f38f77762..292c0ad9f6 100644 --- a/spec/unit/provider/deploy/revision_spec.rb +++ b/spec/unit/provider/deploy/revision_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Deploy::Revision do @run_context = Chef::RunContext.new(@node, {}, @events) @provider = Chef::Provider::Deploy::Revision.new(@resource, @run_context) @provider.load_current_resource - @runner = mock("runnah") + @runner = double("runnah") Chef::Runner.stub(:new).and_return(@runner) @expected_release_dir = "/my/deploy/dir/releases/8a3195bf3efa246f743c5dfa83683201880f935c" end diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb index 5e3d07d3d9..1d42abfc05 100644 --- a/spec/unit/provider/deploy/timestamped_spec.rb +++ b/spec/unit/provider/deploy/timestamped_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Deploy::Timestamped do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @timestamped_deploy = Chef::Provider::Deploy::Timestamped.new(@resource, @run_context) - @runner = mock("runnah") + @runner = double("runnah") Chef::Runner.stub(:new).and_return(@runner) end diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb index cec971c31b..e6e4566011 100644 --- a/spec/unit/provider/deploy_spec.rb +++ b/spec/unit/provider/deploy_spec.rb @@ -265,7 +265,7 @@ describe Chef::Provider::Deploy do end it "runs the new resource collection in the runner during a callback" do - @runner = mock("Runner") + @runner = double("Runner") Chef::Runner.stub(:new).and_return(@runner) @runner.should_receive(:converge) callback_code = Proc.new { :noop } @@ -543,7 +543,7 @@ describe Chef::Provider::Deploy do end it "defines run as a forwarder to execute, setting the user, group, cwd and environment to new_resource.user" do - mock_execution = mock("Resource::Execute") + mock_execution = double("Resource::Execute") @provider.should_receive(:execute).with("iGoToHell4this").and_return(mock_execution) @resource.user("notCoolMan") @resource.group("Ggroup") @@ -572,7 +572,7 @@ describe Chef::Provider::Deploy do end it "defines run as a forwarder to execute, setting cwd and environment but not override" do - mock_execution = mock("Resource::Execute") + mock_execution = double("Resource::Execute") @provider.should_receive(:execute).with("iGoToHell4this").and_return(mock_execution) @resource.user("notCoolMan") mock_execution.should_receive(:user).with("notCoolMan") @@ -583,7 +583,7 @@ describe Chef::Provider::Deploy do it "converts sudo and run to exec resources in hooks" do - runner = mock("tehRunner") + runner = double("tehRunner") Chef::Runner.stub(:new).and_return(runner) snitch = nil diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb index 62e9816340..25ca9e0175 100644 --- a/spec/unit/provider/directory_spec.rb +++ b/spec/unit/provider/directory_spec.rb @@ -51,7 +51,7 @@ describe Chef::Provider::Directory do Chef::Platform.stub(:windows?).and_return(false) end let(:mock_stat) do - cstats = mock("stats") + cstats = double("stats") cstats.stub(:uid).and_return(500) cstats.stub(:gid).and_return(500) cstats.stub(:mode).and_return(0755) @@ -176,7 +176,7 @@ describe Chef::Provider::Directory do end def stub_file_cstats - cstats = mock("stats") + cstats = double("stats") cstats.stub(:uid).and_return(500) cstats.stub(:gid).and_return(500) cstats.stub(:mode).and_return(0755) diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index ca5a94afe3..34d98b6619 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -25,7 +25,7 @@ describe Chef::Provider::File::Content do # let(:current_resource) do - mock("Chef::Provider::File::Resource (current)") + double("Chef::Provider::File::Resource (current)") end let(:enclosing_directory) { @@ -36,11 +36,11 @@ describe Chef::Provider::File::Content do } let(:new_resource) do - mock("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path) + double("Chef::Provider::File::Resource (new)", :name => "seattle.txt", :path => resource_path) end let(:run_context) do - mock("Chef::RunContext") + double("Chef::RunContext") end # diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index 6c401e3030..059f1722fb 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::File do end let(:content) do - content = mock('Chef::Provider::File::Content') + content = double('Chef::Provider::File::Content') end let(:node) { double('Chef::Node') } diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 1f62ab1b03..416012f5fa 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -41,9 +41,9 @@ describe Chef::Provider::Git do context "determining the revision of the currently deployed checkout" do before do - @stdout = mock("standard out") - @stderr = mock("standard error") - @exitstatus = mock("exitstatus") + @stdout = double("standard out") + @stderr = double("standard error") + @exitstatus = double("exitstatus") end it "sets the current revision to nil if the deploy dir does not exist" do @@ -54,7 +54,7 @@ describe Chef::Provider::Git do it "determines the current revision when there is one" do ::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n" - @provider.should_receive(:shell_out!).with('git rev-parse HEAD', {:cwd => '/my/deploy/dir', :returns => [0,128]}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with('git rev-parse HEAD', {:cwd => '/my/deploy/dir', :returns => [0,128]}).and_return(double("ShellOut result", :stdout => @stdout)) @provider.find_current_revision.should eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -62,7 +62,7 @@ describe Chef::Provider::Git do ::File.should_receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stderr = "fatal: Not a git repository (or any of the parent directories): .git" @stdout = "" - @provider.should_receive(:shell_out!).with('git rev-parse HEAD', :cwd => '/my/deploy/dir', :returns => [0,128]).and_return(mock("ShellOut result", :stdout => "", :stderr => @stderr)) + @provider.should_receive(:shell_out!).with('git rev-parse HEAD', :cwd => '/my/deploy/dir', :returns => [0,128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) @provider.find_current_revision.should be_nil end end @@ -93,7 +93,7 @@ describe Chef::Provider::Git do @resource.revision "v1.0" @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -102,7 +102,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n") - @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) @provider.target_revision.should eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -117,21 +117,21 @@ describe Chef::Provider::Git do it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do @resource.revision "FAIL, that's the revision I want" @provider.action = :checkout - @provider.should_receive(:shell_out!).and_return(mock("ShellOut result", :stdout => "\n")) + @provider.should_receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::UnresolvableGitReference) end it "does not raise an error if the revision can't be resolved when assertions are not run" do @resource.revision "FAIL, that's the revision I want" - @provider.should_receive(:shell_out!).and_return(mock("ShellOut result", :stdout => "\n")) + @provider.should_receive(:shell_out!).and_return(double("ShellOut result", :stdout => "\n")) @provider.target_revision.should == nil end it "does not raise an error when the revision is valid and assertions are run." do @resource.revision "0.8-alpha" @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" - @provider.should_receive(:shell_out!).with(@git_ls_remote + "0.8-alpha*", {:log_tag=>"git[web2.0 app]"}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote + "0.8-alpha*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) @provider.action = :checkout ::File.stub(:directory?).with("/my/deploy").and_return(true) @provider.define_resource_requirements @@ -156,7 +156,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS @resource.revision '' - @provider.should_receive(:shell_out!).with(@git_ls_remote + "HEAD", {:log_tag=>"git[web2.0 app]"}).and_return(mock("ShellOut result", :stdout => @stdout)) + @provider.should_receive(:shell_out!).with(@git_ls_remote + "HEAD", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) @provider.target_revision.should eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end end diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 5890ee43a1..6eb85f7417 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -27,7 +27,7 @@ describe Chef::Provider::Group::Dscl do @current_resource = Chef::Resource::Group.new("aj") @provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @status = mock("Process::Status", :exitstatus => 0) + @status = double("Process::Status", :exitstatus => 0) @pid = 2342 @stdin = StringIO.new @stdout = StringIO.new("\n") @@ -60,7 +60,7 @@ describe Chef::Provider::Group::Dscl do describe "with the dscl command returning a non zero exit status for a delete" do before do - @status = mock("Process::Status", :exitstatus => 1) + @status = double("Process::Status", :exitstatus => 1) @provider.stub(:dscl).and_return(["cmd", @status, "stdout", "stderr"]) end diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb index b395ed96d8..6888c750f5 100644 --- a/spec/unit/provider/group/windows_spec.rb +++ b/spec/unit/provider/group/windows_spec.rb @@ -33,7 +33,7 @@ describe Chef::Provider::Group::Windows do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Group.new("staff") - @net_group = mock("Chef::Util::Windows::NetGroup") + @net_group = double("Chef::Util::Windows::NetGroup") Chef::Util::Windows::NetGroup.stub(:new).and_return(@net_group) @provider = Chef::Provider::Group::Windows.new(@new_resource, @run_context) end diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index ad6cfbff7c..9ff9f85c7c 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::User do @provider.current_resource = @current_resource - @pw_group = mock("Struct::Group", + @pw_group = double("Struct::Group", :name => "wheel", :gid => 20, :mem => [ "root", "aj" ] diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb index d1ee5163a1..605287fcc3 100644 --- a/spec/unit/provider/http_request_spec.rb +++ b/spec/unit/provider/http_request_spec.rb @@ -45,7 +45,7 @@ describe Chef::Provider::HttpRequest do # run_action(x) forces load_current_resource to run; # that would overwrite our supplied mock Chef::Rest # object @provider.stub(:load_current_resource).and_return(true) - @http = mock("Chef::REST") + @http = double("Chef::REST") @provider.http = @http end diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 93504b4096..3f46d9df23 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -34,7 +34,7 @@ describe Chef::Provider::Ifconfig::Debian do @provider = Chef::Provider::Ifconfig::Debian.new(@new_resource, @run_context) @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) - status = mock("Status", :exitstatus => 0) + status = double("Status", :exitstatus => 0) @provider.instance_variable_set("@status", status) @provider.current_resource = @current_resource @provider.stub(:load_current_resource) diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb index fc7ace5398..f4b98dfc32 100644 --- a/spec/unit/provider/ifconfig/redhat_spec.rb +++ b/spec/unit/provider/ifconfig/redhat_spec.rb @@ -34,7 +34,7 @@ describe Chef::Provider::Ifconfig::Redhat do @provider = Chef::Provider::Ifconfig::Redhat.new(@new_resource, @run_context) @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) - status = mock("Status", :exitstatus => 0) + status = double("Status", :exitstatus => 0) @provider.instance_variable_set("@status", status) @provider.current_resource = @current_resource end diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 80f623302f..fb8d0956d7 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -35,14 +35,14 @@ describe Chef::Provider::Ifconfig do @provider = Chef::Provider::Ifconfig.new(@new_resource, @run_context) @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) - status = mock("Status", :exitstatus => 0) + status = double("Status", :exitstatus => 0) @provider.instance_variable_set("@status", status) @provider.current_resource = @current_resource end describe Chef::Provider::Ifconfig, "load_current_resource" do before do - status = mock("Status", :exitstatus => 1) + status = double("Status", :exitstatus => 1) @provider.should_receive(:popen4).and_return status @provider.load_current_resource end diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 869796219d..6052f5dd3b 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -44,7 +44,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do describe "when the target is a symlink" do before(:each) do - lstat = mock("stats", :ino => 5) + lstat = double("stats", :ino => 5) lstat.stub(:uid).and_return(501) lstat.stub(:gid).and_return(501) lstat.stub(:mode).and_return(0777) @@ -144,7 +144,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do describe "when the target is a regular old file" do before do - stat = mock("stats", :ino => 5) + stat = double("stats", :ino => 5) stat.stub(:uid).and_return(501) stat.stub(:gid).and_return(501) stat.stub(:mode).and_return(0755) @@ -176,7 +176,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do describe "and the source exists" do before do - stat = mock("stats", :ino => 6) + stat = double("stats", :ino => 6) stat.stub(:uid).and_return(502) stat.stub(:gid).and_return(502) stat.stub(:mode).and_return(0644) @@ -203,7 +203,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do describe "and is hardlinked to the source" do before do - stat = mock("stats", :ino => 5) + stat = double("stats", :ino => 5) stat.stub(:uid).and_return(502) stat.stub(:gid).and_return(502) stat.stub(:mode).and_return(0644) diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 2c304980d8..b1339eef8a 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -56,7 +56,7 @@ describe Chef::Provider::Mount::Mount do it "should accecpt device_type :uuid" do @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" - @stdout_findfs = mock("STDOUT", :first => "/dev/sdz1") + @stdout_findfs = double("STDOUT", :first => "/dev/sdz1") @provider.should_receive(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status) @provider.load_current_resource() @provider.mountable? @@ -95,8 +95,8 @@ describe Chef::Provider::Mount::Mount do it "should raise an error if the mount device (uuid) does not exist" do @new_resource.device_type :uuid @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" - status_findfs = mock("Status", :exitstatus => 1) - stdout_findfs = mock("STDOUT", :first => nil) + status_findfs = double("Status", :exitstatus => 1) + stdout_findfs = double("STDOUT", :first => nil) @provider.should_receive(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,stdout_findfs,@stderr).and_return(status_findfs) ::File.should_receive(:exists?).with("").and_return(false) lambda { @provider.load_current_resource();@provider.mountable? }.should raise_error(Chef::Exceptions::Mount) @@ -278,9 +278,9 @@ describe Chef::Provider::Mount::Mount do it "should mount the filesystem specified by uuid" do @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" @new_resource.device_type :uuid - @stdout_findfs = mock("STDOUT", :first => "/dev/sdz1") + @stdout_findfs = double("STDOUT", :first => "/dev/sdz1") @provider.stub(:popen4).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_yield(@pid,@stdin,@stdout_findfs,@stderr).and_return(@status) - @stdout_mock = mock('stdout mock') + @stdout_mock = double('stdout mock') @stdout_mock.stub(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}") @provider.should_receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}").and_return(@stdout_mock) @provider.mount_fs() diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index 5a5cda6d7a..80e7f1e695 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -42,9 +42,9 @@ describe Chef::Provider::Mount::Windows do @current_resource = Chef::Resource::Mount.new("X:") Chef::Resource::Mount.stub(:new).and_return(@current_resource) - @net_use = mock("Chef::Util::Windows::NetUse") + @net_use = double("Chef::Util::Windows::NetUse") Chef::Util::Windows::NetUse.stub(:new).and_return(@net_use) - @vol = mock("Chef::Util::Windows::Volume") + @vol = double("Chef::Util::Windows::Volume") Chef::Util::Windows::Volume.stub(:new).and_return(@vol) @provider = Chef::Provider::Mount::Windows.new(@new_resource, @run_context) diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index 83f4763664..35f85b628f 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::Package::Aix do @bffinfo ="/usr/lib/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX: /etc/objrepos:samba.base:3.3.12.0::COMMITTED:I:Samba for AIX:" - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) end it "should create a current resource with the name of new_resource" do @@ -88,7 +88,7 @@ describe Chef::Provider::Package::Aix do end it "should raise an exception if installp/lslpp fails to run" do - @status = mock("Status", :exitstatus => -1) + @status = double("Status", :exitstatus => -1) @provider.stub(:popen4).and_return(@status) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) end @@ -110,13 +110,13 @@ describe Chef::Provider::Package::Aix do end it "should lookup the candidate_version if the variable is not already set" do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.should_receive(:popen4).and_return(@status) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - @status = mock("Status", :exitstatus => 1) + @status = double("Status", :exitstatus => 1) @provider.stub(:popen4).and_return(@status) lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index 5f0c823b7e..b8e23d8756 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Package::Apt do @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Package.new("irssi", @run_context) - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context) @stdin = StringIO.new @stdout =<<-PKG_STATUS @@ -83,7 +83,7 @@ libmysqlclient15-dev: Candidate: (none) Version table: VPKG_STDOUT - virtual_package = mock(:stdout => virtual_package_out,:exitstatus => 0) + virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0) @provider.should_receive(:shell_out!).with("apt-cache policy libmysqlclient15-dev").and_return(virtual_package) showpkg_out =<<-SHOWPKG_STDOUT Package: libmysqlclient15-dev @@ -103,7 +103,7 @@ libmysqlclient-dev 5.1.41-3ubuntu12.7 libmysqlclient-dev 5.1.41-3ubuntu12.10 libmysqlclient-dev 5.1.41-3ubuntu12 SHOWPKG_STDOUT - showpkg = mock(:stdout => showpkg_out,:exitstatus => 0) + showpkg = double(:stdout => showpkg_out,:exitstatus => 0) @provider.should_receive(:shell_out!).with("apt-cache showpkg libmysqlclient15-dev").and_return(showpkg) real_package_out=<<-RPKG_STDOUT libmysqlclient-dev: @@ -118,7 +118,7 @@ libmysqlclient-dev: 5.1.41-3ubuntu12 0 500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages RPKG_STDOUT - real_package = mock(:stdout => real_package_out,:exitstatus => 0) + real_package = double(:stdout => real_package_out,:exitstatus => 0) @provider.should_receive(:shell_out!).with("apt-cache policy libmysqlclient-dev").and_return(real_package) @provider.load_current_resource end @@ -131,7 +131,7 @@ mp3-decoder: Candidate: (none) Version table: VPKG_STDOUT - virtual_package = mock(:stdout => virtual_package_out,:exitstatus => 0) + virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0) @provider.should_receive(:shell_out!).with("apt-cache policy mp3-decoder").and_return(virtual_package) showpkg_out=<<-SHOWPKG_STDOUT Package: mp3-decoder @@ -154,7 +154,7 @@ opencubicplayer 1:0.1.17-2 mpg321 0.2.10.6 mpg123 1.12.1-0ubuntu1 SHOWPKG_STDOUT - showpkg = mock(:stdout => showpkg_out,:exitstatus => 0) + showpkg = double(:stdout => showpkg_out,:exitstatus => 0) @provider.should_receive(:shell_out!).with("apt-cache showpkg mp3-decoder").and_return(showpkg) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index 03786ff00b..6ba7695a1e 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -30,9 +30,9 @@ describe Chef::Provider::Package::Dpkg do @stdin = StringIO.new @stdout = StringIO.new - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stderr = StringIO.new - @pid = mock("PID") + @pid = double("PID") @provider.stub(:popen4).and_return(@status) ::File.stub(:exists?).and_return(true) @@ -110,7 +110,7 @@ DPKG_S end it "should raise an exception if dpkg fails to run" do - @status = mock("Status", :exitstatus => -1) + @status = double("Status", :exitstatus => -1) @provider.stub(:popen4).and_return(@status) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb index 8625619860..87cbabcc19 100644 --- a/spec/unit/provider/package/easy_install_spec.rb +++ b/spec/unit/provider/package/easy_install_spec.rb @@ -34,7 +34,7 @@ describe Chef::Provider::Package::EasyInstall do @stdin = StringIO.new @stdout = StringIO.new - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stderr = StringIO.new @pid = 2342 @provider.stub(:popen4).and_return(@status) diff --git a/spec/unit/provider/package/freebsd_spec.rb b/spec/unit/provider/package/freebsd_spec.rb index 037d559bc2..962f9c23d1 100644 --- a/spec/unit/provider/package/freebsd_spec.rb +++ b/spec/unit/provider/package/freebsd_spec.rb @@ -68,11 +68,11 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do #@provider = Chef::Provider::Package::Freebsd.new(@node, @new_resource) - #@status = mock("Status", :exitstatus => 0) - #@stdin = mock("STDIN", :null_object => true) - #@stdout = mock("STDOUT", :null_object => true) - #@stderr = mock("STDERR", :null_object => true) - #@pid = mock("PID", :null_object => true) + #@status = double("Status", :exitstatus => 0) + #@stdin = double("STDIN", :null_object => true) + #@stdout = double("STDOUT", :null_object => true) + #@stderr = double("STDERR", :null_object => true) + #@pid = double("PID", :null_object => true) end it "should return the version number when it is installed" do @@ -161,7 +161,7 @@ describe Chef::Provider::Package::Freebsd, "load_current_resource" do end it "should use the package_name as a relative path from /usr/ports when it contains / but doesn't start with it" do - # @new_resource = mock( "Chef::Resource::Package", + # @new_resource = double( "Chef::Resource::Package", # :package_name => "www/wordpress", # :cookbook_name => "xenoparadox") new_resource = Chef::Resource::Package.new("www/wordpress") diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index 79025f912b..9ebf23860d 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Package::Macports do @provider = Chef::Provider::Package::Macports.new(@new_resource, @run_context) Chef::Resource::Package.stub(:new).and_return(@current_resource) - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stdin = StringIO.new @stdout = StringIO.new @stderr = StringIO.new diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index 7dae87b799..83f376431e 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -26,7 +26,7 @@ describe Chef::Provider::Package::Pacman do @new_resource = Chef::Resource::Package.new("nano") @current_resource = Chef::Resource::Package.new("nano") - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Pacman.new(@new_resource, @run_context) Chef::Resource::Package.stub(:new).and_return(@current_resource) @provider.stub(:popen4).and_return(@status) diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index 684d776b37..6f22952da2 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -107,7 +107,7 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do end it "should throw an exception if the exitstatus is not 0" do - @status = mock("Status", :exitstatus => 1) + @status = double("Status", :exitstatus => 1) @provider.stub(:popen4).and_return(@status) lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) end @@ -143,7 +143,7 @@ Searching... License: GPL-2 EOF - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) @provider.candidate_version.should == "1.6.0.6" end @@ -179,7 +179,7 @@ Searching... License: GPL-2 EOF - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) @provider.candidate_version.should == "1.6.0.6" @@ -224,7 +224,7 @@ Searching... License: GPL-2 EOF - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Portage.new(@new_resource_without_category, @run_context) @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) @@ -269,7 +269,7 @@ Searching... License: GPL-2 EOF - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Portage.new(@new_resource, @run_context) @provider.should_receive(:popen4).and_yield(nil, nil, StringIO.new(output), nil).and_return(@status) @provider.candidate_version.should == "1.6.0.6" diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index ab8447b3e1..7126b06d66 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Package::Rpm do @provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context) - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) ::File.stub(:exists?).and_return(true) end @@ -76,7 +76,7 @@ describe Chef::Provider::Package::Rpm do end it "should raise an exception if rpm fails to run" do - status = mock("Status", :exitstatus => -1) + status = double("Status", :exitstatus => -1) @provider.stub(:popen4).and_return(status) lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index b6807f1b70..d3cb9cf7fa 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -99,8 +99,8 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do dep = Gem::Dependency.new('rspec', '>= 0') dep_installer = Gem::DependencyInstaller.new @gem_env.stub(:dependency_installer).and_return(dep_installer) - best_gem = mock("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org") - available_set = mock("Gem::AvailableSet test double") + best_gem = double("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org") + available_set = double("Gem::AvailableSet test double") available_set.should_receive(:pick_best!) available_set.should_receive(:set).and_return([best_gem]) dep_installer.should_receive(:find_gems_with_sources).with(dep).and_return(available_set) @@ -131,7 +131,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do end it "finds a matching gem candidate version on rubygems 2.0+ with some rubygems 1.8 code loaded" do - package = mock("Gem::Package", :spec => "a gemspec from package") + package = double("Gem::Package", :spec => "a gemspec from package") Gem::Package.should_receive(:new).with("/path/to/package.gem").and_return(package) @gem_env.spec_from_file("/path/to/package.gem").should == "a gemspec from package" end @@ -180,14 +180,14 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do end it "uninstalls all versions of a gem" do - uninstaller = mock('gem uninstaller') + uninstaller = double('gem uninstaller') uninstaller.should_receive(:uninstall) @gem_env.should_receive(:uninstaller).with('rspec', :all => true).and_return(uninstaller) @gem_env.uninstall('rspec') end it "uninstalls a specific version of a gem" do - uninstaller = mock('gem uninstaller') + uninstaller = double('gem uninstaller') uninstaller.should_receive(:uninstall) @gem_env.should_receive(:uninstaller).with('rspec', :version => '1.2.3').and_return(uninstaller) @gem_env.uninstall('rspec', '1.2.3') @@ -295,7 +295,7 @@ RubyGems Environment: - http://rubygems.org/ - http://gems.github.com/ JRUBY_GEM_ENV - @gem_env.should_receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(mock('jruby_gem_env', :stdout => gem_env_out)) + @gem_env.should_receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('jruby_gem_env', :stdout => gem_env_out)) expected = ['ruby', Gem::Platform.new('universal-java-1.6')] @gem_env.gem_platforms.should == expected # it should also cache the result @@ -337,7 +337,7 @@ RubyGems Environment: - http://rubygems.org/ - http://gems.github.com/ RBX_GEM_ENV - @gem_env.should_receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(mock('rbx_gem_env', :stdout => gem_env_out)) + @gem_env.should_receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('rbx_gem_env', :stdout => gem_env_out)) @gem_env.gem_platforms.should == Gem.platforms Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem'].should == Gem.platforms end diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index 86ac159f69..1c690acbf5 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do @current_resource = Chef::Resource::Package.new("varnish") - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context) Chef::Resource::Package.stub(:new).and_return(@current_resource) @stdin = StringIO.new @@ -77,11 +77,11 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end it "should lookup the candidate_version if the variable is not already set" do - search = mock() + search = double() search.should_receive(:each_line). and_yield("something-varnish-1.1.1 something varnish like\n"). and_yield("varnish-2.3.4 actual varnish\n") - @shell_out = mock('shell_out!', :stdout => search) + @shell_out = double('shell_out!', :stdout => search) @provider.should_receive(:shell_out!).with('/opt/local/bin/pkgin se varnish', :env => nil, :returns => [0,1]).and_return(@shell_out) @provider.candidate_version.should == "2.3.4" end diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb index be07eeb45f..086e327cce 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -46,7 +46,7 @@ INSTDATE: Nov 04 2009 01:02 HOTLINE: Please contact your local service provider PKGINFO - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) end it "should create a current resource with the name of new_resource" do @@ -98,7 +98,7 @@ PKGINFO end it "should raise an exception if pkginfo fails to run" do - @status = mock("Status", :exitstatus => -1) + @status = double("Status", :exitstatus => -1) @provider.stub(:popen4).and_return(@status) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package) end @@ -120,14 +120,14 @@ PKGINFO end it "should lookup the candidate_version if the variable is not already set" do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.stub(:popen4).and_return(@status) @provider.should_receive(:popen4) @provider.candidate_version end it "should throw and exception if the exitstatus is not 0" do - @status = mock("Status", :exitstatus => 1) + @status = double("Status", :exitstatus => 1) @provider.stub(:popen4).and_return(@status) lambda { @provider.candidate_version }.should raise_error(Chef::Exceptions::Package) end diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 0e417aae0d..8a947c2b2d 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -24,8 +24,8 @@ describe Chef::Provider::Package::Yum do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Package.new('cups') - @status = mock("Status", :exitstatus => 0) - @yum_cache = mock( + @status = double("Status", :exitstatus => 0) + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -39,7 +39,7 @@ describe Chef::Provider::Package::Yum do ) Chef::Provider::Package::Yum::YumCache.stub(:instance).and_return(@yum_cache) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) - @pid = mock("PID") + @pid = double("PID") end describe "when loading the current system state" do @@ -76,7 +76,7 @@ describe Chef::Provider::Package::Yum do describe "when arch in package_name" do it "should set the arch if no existing package_name is found and new_package_name+new_arch is available" do @new_resource = Chef::Resource::YumPackage.new('testing.noarch') - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache' ) @yum_cache.stub(:installed_version) do |package_name, arch| @@ -110,7 +110,7 @@ describe Chef::Provider::Package::Yum do it "should not set the arch when an existing package_name is found" do @new_resource = Chef::Resource::YumPackage.new('testing.beta3') - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache' ) @yum_cache.stub(:installed_version) do |package_name, arch| @@ -145,7 +145,7 @@ describe Chef::Provider::Package::Yum do it "should not set the arch when no existing package_name or new_package_name+new_arch is found" do @new_resource = Chef::Resource::YumPackage.new('testing.beta3') - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache' ) @yum_cache.stub(:installed_version) do |package_name, arch| @@ -176,7 +176,7 @@ describe Chef::Provider::Package::Yum do it "should ensure it doesn't clobber an existing arch if passed" do @new_resource = Chef::Resource::YumPackage.new('testing.i386') @new_resource.arch("x86_64") - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache' ) @yum_cache.stub(:installed_version) do |package_name, arch| @@ -232,7 +232,7 @@ describe Chef::Provider::Package::Yum do end it "should search provides if package name can't be found then set package_name to match" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -251,7 +251,7 @@ describe Chef::Provider::Package::Yum do end it "should search provides if package name can't be found, warn about multiple matches, but use the first one" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -272,7 +272,7 @@ describe Chef::Provider::Package::Yum do end it "should search provides if no package is available - if no match in installed provides then load the complete set" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -290,7 +290,7 @@ describe Chef::Provider::Package::Yum do end it "should search provides if no package is available and not load the complete set if action is :remove or :purge" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -313,7 +313,7 @@ describe Chef::Provider::Package::Yum do end it "should search provides if no package is available - if no match in provides leave the name intact" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_provides => true, :reload_installed => true, @@ -383,7 +383,7 @@ describe Chef::Provider::Package::Yum do end it "should raise an exception if the package is not available" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_from_cache => true, :reset => true, @@ -400,7 +400,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do @new_resource.stub(:allow_downgrade).and_return(false) - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -418,7 +418,7 @@ describe Chef::Provider::Package::Yum do end it "should not raise an exception if candidate version is older than the installed version and the package is list in yum's installonlypkg option" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -441,7 +441,7 @@ describe Chef::Provider::Package::Yum do it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do @new_resource.stub(:allow_downgrade).and_return(true) - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -508,7 +508,7 @@ describe Chef::Provider::Package::Yum do end it "should raise an exception if candidate version is older than the installed version" do - @yum_cache = mock( + @yum_cache = double( 'Chef::Provider::Yum::YumCache', :reload_installed => true, :reset => true, @@ -595,7 +595,7 @@ describe Chef::Provider::Package::Yum do describe "when running yum" do it "should run yum once if it exits with a return code of 0" do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.stub(:output_of_command).and_return([@status, "", ""]) @provider.should_receive(:output_of_command).once.with( "yum -d0 -e0 -y install emacs-1.0", @@ -605,7 +605,7 @@ describe Chef::Provider::Package::Yum do end it "should run yum once if it exits with a return code > 0 and no scriptlet failures" do - @status = mock("Status", :exitstatus => 2) + @status = double("Status", :exitstatus => 2) @provider.stub(:output_of_command).and_return([@status, "failure failure", "problem problem"]) @provider.should_receive(:output_of_command).once.with( "yum -d0 -e0 -y install emacs-1.0", @@ -615,7 +615,7 @@ describe Chef::Provider::Package::Yum do end it "should run yum once if it exits with a return code of 1 and %pre scriptlet failures" do - @status = mock("Status", :exitstatus => 1) + @status = double("Status", :exitstatus => 1) @provider.stub(:output_of_command).and_return([@status, "error: %pre(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""]) @provider.should_receive(:output_of_command).once.with( "yum -d0 -e0 -y install emacs-1.0", @@ -626,7 +626,7 @@ describe Chef::Provider::Package::Yum do end it "should run yum twice if it exits with a return code of 1 and %post scriptlet failures" do - @status = mock("Status", :exitstatus => 1) + @status = double("Status", :exitstatus => 1) @provider.stub(:output_of_command).and_return([@status, "error: %post(demo-1-1.el5.centos.x86_64) scriptlet failed, exit status 2", ""]) @provider.should_receive(:output_of_command).twice.with( "yum -d0 -e0 -y install emacs-1.0", @@ -1543,8 +1543,8 @@ describe Chef::Provider::Package::Yum::YumCache do end before(:each) do - @stdin = mock("STDIN", :nil_object => true) - @stdout = mock("STDOUT", :nil_object => true) + @stdin = double("STDIN", :nil_object => true) + @stdout = double("STDOUT", :nil_object => true) @stdout_good = <<EOF [option installonlypkgs] kernel kernel-bigmem kernel-enterprise @@ -1586,7 +1586,7 @@ yum-dump Config Error: File contains no section headers. file: file://///etc/yum.repos.d/CentOS-Base.repo, line: 12 'qeqwewe\n' EOF - @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_good, :stderr => @stderr) + @status = double("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_good, :stderr => @stderr) # new singleton each time Chef::Provider::Package::Yum::YumCache.reset_instance @@ -1642,28 +1642,28 @@ EOF end it "should warn about invalid data with too many separators" do - @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_separators, :stderr => @stderr) + @status = double("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_separators, :stderr => @stderr) @yc.stub(:shell_out!).and_return(@status) Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing}) @yc.refresh end it "should warn about invalid data with an incorrect type" do - @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_type, :stderr => @stderr) + @status = double("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_bad_type, :stderr => @stderr) @yc.stub(:shell_out!).and_return(@status) Chef::Log.should_receive(:warn).exactly(2).times.with(%r{Problem parsing}) @yc.refresh end it "should warn about no output from yum-dump.py" do - @status = mock("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr) + @status = double("Status", :exitstatus => 0, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr) @yc.stub(:shell_out!).and_return(@status) Chef::Log.should_receive(:warn).exactly(1).times.with(%r{no output from yum-dump.py}) @yc.refresh end it "should raise exception yum-dump.py exits with a non zero status" do - @status = mock("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr) + @status = double("Status", :exitstatus => 1, :stdin => @stdin, :stdout => @stdout_no_output, :stderr => @stderr) @yc.stub(:shell_out!).and_return(@status) lambda { @yc.refresh}.should raise_error(Chef::Exceptions::Package, %r{CentOS-Base.repo, line: 12}) end diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 63f235a05c..e63ac5160e 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -27,14 +27,14 @@ describe Chef::Provider::Package::Zypper do @current_resource = Chef::Resource::Package.new("cups") - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Zypper.new(@new_resource, @run_context) Chef::Resource::Package.stub(:new).and_return(@current_resource) @provider.stub(:popen4).and_return(@status) @stderr = StringIO.new @stdout = StringIO.new - @pid = mock("PID") + @pid = double("PID") @provider.stub(:`).and_return("2.0") end diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index 00999fc307..0f311dc0ec 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -36,7 +36,7 @@ describe Chef::Provider::RemoteFile::Content do r end - let(:run_context) { mock("Chef::RunContext") } + let(:run_context) { double("Chef::RunContext") } # # subject @@ -78,13 +78,13 @@ describe Chef::Provider::RemoteFile::Content do shared_examples_for "the resource needs fetching" do before do # FIXME: test one or the other nil, test both not nil and not equal, abuse the regexp a little - @uri = mock("URI") + @uri = double("URI") URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri) end describe "when the fetcher returns nil for the tempfile" do before do - http_fetcher = mock("Chef::Provider::RemoteFile::HTTP", :fetch => nil) + http_fetcher = double("Chef::Provider::RemoteFile::HTTP", :fetch => nil) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) end @@ -96,8 +96,8 @@ describe Chef::Provider::RemoteFile::Content do describe "when the fetcher returns a valid tempfile" do let(:mtime) { Time.now } - let(:tempfile) { mock("Tempfile") } - let(:http_fetcher) { mock("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) } + let(:tempfile) { double("Tempfile") } + let(:http_fetcher) { double("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) } before do Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) @@ -146,9 +146,9 @@ describe Chef::Provider::RemoteFile::Content do before do new_resource.stub(:checksum).and_return(nil) current_resource.stub(:checksum).and_return(nil) - @uri = mock("URI") + @uri = double("URI") URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri) - http_fetcher = mock("Chef::Provider::RemoteFile::HTTP") + http_fetcher = double("Chef::Provider::RemoteFile::HTTP") http_fetcher.should_receive(:fetch).and_raise(Errno::ECONNREFUSED) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) end @@ -164,20 +164,20 @@ describe Chef::Provider::RemoteFile::Content do before do new_resource.stub(:checksum).and_return(nil) current_resource.stub(:checksum).and_return(nil) - @uri0 = mock("URI0") - @uri1 = mock("URI1") + @uri0 = double("URI0") + @uri1 = double("URI1") URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0) URI.should_receive(:parse).with(new_resource.source[1]).and_return(@uri1) - @http_fetcher_throws_exception = mock("Chef::Provider::RemoteFile::HTTP") + @http_fetcher_throws_exception = double("Chef::Provider::RemoteFile::HTTP") @http_fetcher_throws_exception.should_receive(:fetch).at_least(:once).and_raise(Errno::ECONNREFUSED) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(@http_fetcher_throws_exception) end describe "when the second url succeeds" do before do - @tempfile = mock("Tempfile") + @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works) end @@ -207,12 +207,12 @@ describe Chef::Provider::RemoteFile::Content do before do new_resource.stub(:checksum).and_return(nil) current_resource.stub(:checksum).and_return(nil) - @uri0 = mock("URI0") + @uri0 = double("URI0") URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0) URI.should_not_receive(:parse).with(new_resource.source[1]) - @tempfile = mock("Tempfile") + @tempfile = double("Tempfile") mtime = Time.now - http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) + http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works) end diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb index 68802fb83c..b5594b50e6 100644 --- a/spec/unit/provider/remote_file/fetcher_spec.rb +++ b/spec/unit/provider/remote_file/fetcher_spec.rb @@ -20,12 +20,12 @@ require 'spec_helper' describe Chef::Provider::RemoteFile::Fetcher do - let(:current_resource) { mock("current resource") } - let(:new_resource) { mock("new resource") } - let(:fetcher_instance) { mock("fetcher") } + let(:current_resource) { double("current resource") } + let(:new_resource) { double("new resource") } + let(:fetcher_instance) { double("fetcher") } describe "when passed an http url" do - let(:uri) { mock("uri", :scheme => "http" ) } + let(:uri) { double("uri", :scheme => "http" ) } before do Chef::Provider::RemoteFile::HTTP.should_receive(:new).and_return(fetcher_instance) end @@ -35,7 +35,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an https url" do - let(:uri) { mock("uri", :scheme => "https" ) } + let(:uri) { double("uri", :scheme => "https" ) } before do Chef::Provider::RemoteFile::HTTP.should_receive(:new).and_return(fetcher_instance) end @@ -45,7 +45,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed an ftp url" do - let(:uri) { mock("uri", :scheme => "ftp" ) } + let(:uri) { double("uri", :scheme => "ftp" ) } before do Chef::Provider::RemoteFile::FTP.should_receive(:new).and_return(fetcher_instance) end @@ -55,7 +55,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a file url" do - let(:uri) { mock("uri", :scheme => "file" ) } + let(:uri) { double("uri", :scheme => "file" ) } before do Chef::Provider::RemoteFile::LocalFile.should_receive(:new).and_return(fetcher_instance) end @@ -65,7 +65,7 @@ describe Chef::Provider::RemoteFile::Fetcher do end describe "when passed a url we do not recognize" do - let(:uri) { mock("uri", :scheme => "xyzzy" ) } + let(:uri) { double("uri", :scheme => "xyzzy" ) } it "throws an ArgumentError exception" do lambda { described_class.for_resource(uri, new_resource, current_resource) }.should raise_error(ArgumentError) end diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index 524405bb06..b393912ef9 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -38,7 +38,7 @@ describe Chef::Provider::RemoteFile::FTP do end let(:ftp) do - ftp = mock(Net::FTP, { }) + ftp = double(Net::FTP, { }) ftp.stub(:connect) ftp.stub(:login) ftp.stub(:voidcmd) diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index 4411bff9cf..951d9f0a05 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -159,12 +159,12 @@ describe Chef::Provider::RemoteFile::HTTP do let(:tempfile_path) { "/tmp/chef-mock-tempfile-abc123" } - let(:tempfile) { mock(Tempfile, :path => tempfile_path, :close => nil) } + let(:tempfile) { double(Tempfile, :path => tempfile_path, :close => nil) } let(:last_response) { {} } let(:rest) do - rest = mock(Chef::HTTP::Simple) + rest = double(Chef::HTTP::Simple) rest.stub(:streaming_request).and_return(tempfile) rest.stub(:last_response).and_return(last_response) rest diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb index 00634f50eb..0020a03210 100644 --- a/spec/unit/provider/remote_file/local_file_spec.rb +++ b/spec/unit/provider/remote_file/local_file_spec.rb @@ -40,8 +40,8 @@ describe Chef::Provider::RemoteFile::LocalFile do describe "when fetching the object" do - let(:tempfile) { mock("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) } - let(:chef_tempfile) { mock("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } + let(:tempfile) { double("Tempfile", :path => "/tmp/foo/bar/nyan.png", :close => nil) } + let(:chef_tempfile) { double("Chef::FileContentManagement::Tempfile", :tempfile => tempfile) } before do current_resource.source("file:///nyan_cat.png") diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb index 4562083e7e..3fa3866743 100644 --- a/spec/unit/provider/remote_file_spec.rb +++ b/spec/unit/provider/remote_file_spec.rb @@ -32,7 +32,7 @@ describe Chef::Provider::RemoteFile do end let(:content) do - content = mock('Chef::Provider::File::Content::RemoteFile') + content = double('Chef::Provider::File::Content::RemoteFile') end let(:node) { double('Chef::Node') } diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index cb0ea50e09..b267915e44 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -127,7 +127,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb DEFAULT_PS - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @node.automatic_attrs[:command] = {:ps => "ps -ef"} @@ -171,7 +171,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "enable_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", @@ -192,7 +192,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "disable_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", @@ -214,7 +214,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "start_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", @@ -240,7 +240,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "stop_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", @@ -266,7 +266,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "restart_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", @@ -301,7 +301,7 @@ RUNNING_PS describe Chef::Provider::Service::Arch, "reload_service" do # before(:each) do - # @new_resource = mock("Chef::Resource::Service", + # @new_resource = double("Chef::Resource::Service", # :null_object => true, # :name => "chef", # :service_name => "chef", diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index ecc59e5e96..567eb6744a 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -61,7 +61,7 @@ describe Chef::Provider::Service::Debian do @stdout = StringIO.new(result) @stderr = StringIO.new - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end @@ -80,11 +80,11 @@ describe Chef::Provider::Service::Debian do context "when update-rc.d shows init isn't linked to rc*.d/" do before do @provider.stub(:assert_update_rcd_available) - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @stdout = StringIO.new( " Removing any system startup links for /etc/init.d/chef ...") @stderr = StringIO.new - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end @@ -102,7 +102,7 @@ describe Chef::Provider::Service::Debian do context "when update-rc.d fails" do before do - @status = mock("Status", :exitstatus => -1) + @status = double("Status", :exitstatus => -1) @provider.stub(:popen4).and_return(@status) end @@ -200,7 +200,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop @stdout = StringIO.new(expected_results["linked"]["stdout"]) @stderr = StringIO.new(expected_results["linked"]["stderr"]) - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end @@ -226,7 +226,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop @provider.stub(:assert_update_rcd_available) @stdout = StringIO.new(expected_results["not linked"]["stdout"]) @stderr = StringIO.new(expected_results["not linked"]["stderr"]) - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 327aff1707..4ebfe12b49 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -44,12 +44,12 @@ describe Chef::Provider::Service::Freebsd do 539 ?? Is 0:00.14 /usr/sbin/sshd 545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail) PS_SAMPLE - @status = mock(:stdout => @stdout, :exitstatus => 0) + @status = double(:stdout => @stdout, :exitstatus => 0) @provider.stub(:shell_out!).with(@node[:command][:ps]).and_return(@status) ::File.stub(:exists?).and_return(false) ::File.stub(:exists?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true) - @lines = mock("lines") + @lines = double("lines") @lines.stub(:each).and_yield("sshd_enable=\"YES\""). and_yield("#{@new_resource.name}_enable=\"YES\"") ::File.stub(:open).and_return(@lines) @@ -282,7 +282,7 @@ RC_SAMPLE # #{@current_resource.service_name}_enable="YES" # (default: "") RCVAR_SAMPLE - @status = mock(:stdout => @rcvar_stdout, :exitstatus => 0) + @status = double(:stdout => @rcvar_stdout, :exitstatus => 0) @provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status) end @@ -304,7 +304,7 @@ RCVAR_SAMPLE # service_with_noname # RCVAR_SAMPLE - @status = mock(:stdout => @rcvar_stdout, :exitstatus => 0) + @status = double(:stdout => @rcvar_stdout, :exitstatus => 0) @provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status) end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index 274c0f72fc..95dc04108d 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -30,7 +30,7 @@ describe Chef::Provider::Service::Gentoo do @provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context) Chef::Resource::Service.stub(:new).and_return(@current_resource) - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out).and_return(@status) File.stub(:exists?).with("/etc/init.d/chef").and_return(true) File.stub(:exists?).with("/sbin/rc-update").and_return(true) diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 2fcddb82e3..9b0371a270 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) end diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index e0c0d9682a..04e63458a0 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Service::Insserv do @current_resource = Chef::Resource::Service.new("initgrediant") @provider = Chef::Provider::Service::Insserv.new(@new_resource, @run_context) - @status = mock("Process::Status mock", :exitstatus => 0, :stdout => "") + @status = double("Process::Status mock", :exitstatus => 0, :stdout => "") @provider.stub(:shell_out!).and_return(@status) end diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 3df6f002c7..b638b08b72 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -37,7 +37,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb PS - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) end @@ -113,7 +113,7 @@ PS describe "when we have a 'ps' attribute" do it "should shell_out! the node's ps command" do - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.should_receive(:shell_out!).with(@node[:command][:ps]).and_return(@status) @provider.load_current_resource end @@ -123,14 +123,14 @@ PS aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.should_receive(:shell_out!).and_return(@status) @provider.load_current_resource @current_resource.running.should be_true end it "should set running to false if the regex doesn't match" do - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.should_receive(:shell_out!).and_return(@status) @provider.load_current_resource @current_resource.running.should be_false diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 814320f64f..65639f2084 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -53,9 +53,9 @@ describe Chef::Provider::Service::Macosx do Dir.stub(:glob).and_return(["/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist"], []) provider.stub(:shell_out!). with("launchctl list", {:group => 1001, :user => 101}). - and_return(mock("ouput", :stdout => stdout)) + and_return(double("ouput", :stdout => stdout)) - File.stub(:stat).and_return(mock("stat", :gid => 1001, :uid => 101)) + File.stub(:stat).and_return(double("stat", :gid => 1001, :uid => 101)) end context "#{service_name}" do diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 0de93fe430..8cc6fb6549 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -30,9 +30,9 @@ shared_examples_for "define_resource_requirements_common" do end it "should not raise an error if the service exists but is not added to any runlevels" do - status = mock("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = mock("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "", :stderr => "service chef supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add chef')") @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements @@ -65,9 +65,9 @@ describe "Chef::Provider::Service::Redhat" do describe "load current resource" do it "sets the current enabled status to true if the service is enabled for any run level" do - status = mock("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = mock("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off", :stderr => "") @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) @provider.instance_variable_get("@service_missing").should be_false @provider.load_current_resource @@ -75,9 +75,9 @@ describe "Chef::Provider::Service::Redhat" do end it "sets the current enabled status to false if the regex does not match" do - status = mock("Status", :exitstatus => 0, :stdout => "" , :stderr => "") + status = double("Status", :exitstatus => 0, :stdout => "" , :stderr => "") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = mock("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "") + chkconfig = double("Chkconfig", :exitstatus => 0, :stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off", :stderr => "") @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) @provider.instance_variable_get("@service_missing").should be_false @provider.load_current_resource.should eql(@current_resource) @@ -90,9 +90,9 @@ describe "Chef::Provider::Service::Redhat" do context "when the service does not exist" do before do - status = mock("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = mock("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") + chkconfig = double("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements @@ -128,9 +128,9 @@ describe "Chef::Provider::Service::Redhat" do it_should_behave_like "define_resource_requirements_common" it "should not raise an error if the service does not exist" do - status = mock("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") + status = double("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) - chkconfig = mock("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") + chkconfig = double("Chkconfig", :existatus=> 1, :stdout => "", :stderr => "error reading information on service chef: No such file or directory") @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig) @provider.load_current_resource @provider.define_resource_requirements diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 7265399f58..1d94534320 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -36,7 +36,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 vi init.rb aj 7903 5016 0 21:26 pts/5 00:00:00 /bin/bash aj 8119 6041 0 21:34 pts/3 00:00:03 vi simple_service_spec.rb NOMOCKINGSTRINGSPLZ - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) end @@ -79,7 +79,7 @@ NOMOCKINGSTRINGSPLZ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos NOMOCKINGSTRINGSPLZ - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) @provider.load_current_resource @current_resource.running.should be_true diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 7dd6d7161c..887c1f6b5f 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -37,7 +37,7 @@ describe Chef::Provider::Service::Solaris do @pid = 2342 @stdout_string = "state disabled" @stdout.stub(:gets).and_return(@stdout_string) - @status = mock("Status", :exitstatus => 0, :stdout => @stdout) + @status = double("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub(:shell_out!).and_return(@status) end @@ -129,7 +129,7 @@ describe Chef::Provider::Service::Solaris do describe "when reloading the service" do before(:each) do - @status = mock("Process::Status", :exitstatus => 0) + @status = double("Process::Status", :exitstatus => 0) @provider.current_resource = @current_resource end diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 1c9a94af2e..154527a7da 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -67,12 +67,12 @@ describe Chef::Provider::Service::Upstart do @current_resource = Chef::Resource::Service.new("rsyslog") Chef::Resource::Service.stub(:new).and_return(@current_resource) - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.stub(:popen4).and_return(@status) @stdin = StringIO.new @stdout = StringIO.new @stderr = StringIO.new - @pid = mock("PID") + @pid = double("PID") ::File.stub(:exists?).and_return(true) ::File.stub(:open).and_return(true) @@ -135,14 +135,14 @@ describe Chef::Provider::Service::Upstart do end it "should set enabled to true when it finds 'starts on'" do - @lines = mock("start on filesystem", :gets => "start on filesystem") + @lines = double("start on filesystem", :gets => "start on filesystem") ::File.stub(:open).and_yield(@lines) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end it "should set enabled to false when it finds '#starts on'" do - @lines = mock("start on filesystem", :gets => "#start on filesystem") + @lines = double("start on filesystem", :gets => "#start on filesystem") ::File.stub(:open).and_yield(@lines) @current_resource.should_receive(:running).with(false) @provider.load_current_resource diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 5f4d9ca7d6..08f5a81a9d 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -32,9 +32,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do Win32::Service::AUTO_START = 0x00000002 Win32::Service::DISABLED = 0x00000004 Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running")) + double("StatusStruct", :current_state => "running")) Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return( - mock("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", :start_type => "auto start")) Win32::Service.stub(:exists?).and_return(true) end @@ -60,8 +60,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do describe Chef::Provider::Service::Windows, "start_service" do before(:each) do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "running")) + double("StatusStruct", :current_state => "stopped"), + double("StatusStruct", :current_state => "running")) end it "should call the start command if one is specified" do @@ -86,7 +86,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should do nothing if the service is running" do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running")) + double("StatusStruct", :current_state => "running")) @provider.load_current_resource Win32::Service.should_not_receive(:start).with(@new_resource.service_name) @provider.start_service @@ -98,8 +98,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do before(:each) do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running"), - mock("StatusStruct", :current_state => "stopped")) + double("StatusStruct", :current_state => "running"), + double("StatusStruct", :current_state => "stopped")) end it "should call the stop command if one is specified" do @@ -124,7 +124,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should do nothing if the service is stopped" do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "stopped")) + double("StatusStruct", :current_state => "stopped")) @provider.load_current_resource Win32::Service.should_not_receive(:stop).with(@new_resource.service_name) @provider.stop_service @@ -143,10 +143,10 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should stop then start the service if it is running" do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running"), - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "running")) + double("StatusStruct", :current_state => "running"), + double("StatusStruct", :current_state => "stopped"), + double("StatusStruct", :current_state => "stopped"), + double("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:stop).with(@new_resource.service_name) Win32::Service.should_receive(:start).with(@new_resource.service_name) @provider.restart_service @@ -155,9 +155,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should just start the service if it is stopped" do Win32::Service.stub(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "running")) + double("StatusStruct", :current_state => "stopped"), + double("StatusStruct", :current_state => "stopped"), + double("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:start).with(@new_resource.service_name) @provider.restart_service @new_resource.updated_by_last_action?.should be_true @@ -177,7 +177,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do before(:each) do Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return( - mock("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", :start_type => "disabled")) end it "should enable service" do @@ -195,7 +195,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should do nothing if the service is enabled" do Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return( - mock("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", :start_type => "auto start")) Win32::Service.should_not_receive(:configure) @provider.enable_service @new_resource.updated_by_last_action?.should be_false @@ -206,7 +206,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do before(:each) do Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return( - mock("ConfigStruct", :start_type => "auto start")) + double("ConfigStruct", :start_type => "auto start")) end it "should disable service" do @@ -224,7 +224,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should do nothing if the service is disabled" do Win32::Service.stub(:config_info).with(@new_resource.service_name).and_return( - mock("ConfigStruct", :start_type => "disabled")) + double("ConfigStruct", :start_type => "disabled")) @provider.load_current_resource Win32::Service.should_not_receive(:configure) @provider.disable_service diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 123ce1cf35..f37a42d235 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -43,9 +43,9 @@ describe Chef::Provider::Subversion do context "determining the revision of the currently deployed code" do before do - @stdout = mock("stdout") - @stderr = mock("stderr") - @exitstatus = mock("exitstatus") + @stdout = double("stdout") + @stderr = double("stderr") + @exitstatus = double("exitstatus") end it "sets the revision to nil if there isn't any deployed code yet" do @@ -109,8 +109,8 @@ describe Chef::Provider::Subversion do context "resolving revisions to an integer" do before do - @stdout = mock("stdout") - @stderr = mock("stderr") + @stdout = double("stdout") + @stderr = double("stderr") @resource.svn_info_args "--no-auth-cache" end @@ -128,7 +128,7 @@ describe Chef::Provider::Subversion do "Last Changed Author: codeninja\n" + "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" - exitstatus = mock("exitstatus") + exitstatus = double("exitstatus") exitstatus.stub(:exitstatus).and_return(0) @resource.revision "HEAD" @stdout.stub(:string).and_return(example_svn_info) @@ -142,7 +142,7 @@ describe Chef::Provider::Subversion do it "returns a helpful message if data from `svn info` can't be parsed" do example_svn_info = "some random text from an error message\n" - exitstatus = mock("exitstatus") + exitstatus = double("exitstatus") exitstatus.stub(:exitstatus).and_return(0) @resource.revision "HEAD" @stdout.stub(:string).and_return(example_svn_info) diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 1251f96bd3..dfc5d21c2a 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Template::Content do let(:new_resource) do - mock("Chef::Resource::Template (new)", + double("Chef::Resource::Template (new)", :cookbook_name => 'openldap', :source => 'openldap_stuff.conf.erb', :local => false, @@ -41,11 +41,11 @@ describe Chef::Provider::Template::Content do cl.load_cookbooks cookbook_collection = Chef::CookbookCollection.new(cl) node = Chef::Node.new - mock("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection) + double("Chef::Resource::RunContext", :node => node, :cookbook_collection => cookbook_collection) end let(:content) do - current_resource = mock("Chef::Resource::Template (current)") + current_resource = double("Chef::Resource::Template (current)") Chef::Provider::Template::Content.new(new_resource, current_resource, run_context) end diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 78d924aa41..514bdc12ff 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -50,7 +50,7 @@ describe Chef::Provider::Template do end let(:content) do - content = mock('Chef::Provider::File::Content::Template', :template_location => "/foo/bar/baz") + content = double('Chef::Provider::File::Content::Template', :template_location => "/foo/bar/baz") File.stub(:exists?).with("/foo/bar/baz").and_return(true) content end diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index ed22984c62..e5ebcb370a 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -159,7 +159,7 @@ describe Chef::Provider::User::Pw do describe "when modifying the password" do before(:each) do - @status = mock("Status", :exitstatus => 0) + @status = double("Status", :exitstatus => 0) @provider.stub(:popen4).and_return(@status) @pid, @stdin, @stdout, @stderr = nil, nil, nil, nil end diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 9cdb2b5d79..70adb8025a 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::User::Windows do @run_context = Chef::RunContext.new(@node, {}, @events) @current_resource = Chef::Resource::User.new("monkey") - @net_user = mock("Chef::Util::Windows::NetUser") + @net_user = double("Chef::Util::Windows::NetUser") Chef::Util::Windows::NetUser.stub(:new).and_return(@net_user) @provider = Chef::Provider::User::Windows.new(@new_resource, @run_context) diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index 7b29e51c3f..153db6f283 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -58,7 +58,7 @@ describe Chef::Provider::User do describe "executing load_current_resource" do before(:each) do @node = Chef::Node.new - #@new_resource = mock("Chef::Resource::User", + #@new_resource = double("Chef::Resource::User", # :null_object => true, # :username => "adam", # :comment => "Adam Jacob", @@ -226,7 +226,7 @@ describe Chef::Provider::User do describe "action_create" do before(:each) do @provider.stub(:load_current_resource) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = double("Chef::Resource::User", # :null_object => true, # :username => "adam", # :comment => "Adam Jacob", @@ -299,10 +299,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = double("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = double("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) @@ -342,10 +342,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = double("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = double("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) @@ -411,10 +411,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = double("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = double("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) diff --git a/spec/unit/registry_helper_spec.rb b/spec/unit/registry_helper_spec.rb index 49469b27e6..444a82dc7c 100644 --- a/spec/unit/registry_helper_spec.rb +++ b/spec/unit/registry_helper_spec.rb @@ -43,8 +43,8 @@ describe Chef::Provider::RegistryKey do Win32::Registry::Error = Class.new(RuntimeError) - @hive_mock = mock("::Win32::Registry::HKEY_CURRENT_USER") - @reg_mock = mock("reg") + @hive_mock = double("::Win32::Registry::HKEY_CURRENT_USER") + @reg_mock = double("reg") end describe "get_values" do diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb index 1910eb2ec9..c6f41156a4 100644 --- a/spec/unit/resource_reporter_spec.rb +++ b/spec/unit/resource_reporter_spec.rb @@ -35,13 +35,13 @@ describe Chef::ResourceReporter do before do @node = Chef::Node.new @node.name("spitfire") - @rest_client = mock("Chef::REST (mock)") + @rest_client = double("Chef::REST (mock)") @rest_client.stub(:post_rest).and_return(true) @resource_reporter = Chef::ResourceReporter.new(@rest_client) @run_id = @resource_reporter.run_id @new_resource = Chef::Resource::File.new("/tmp/a-file.txt") @new_resource.cookbook_name = "monkey" - @cookbook_version = mock("Cookbook::Version", :version => "1.2.3") + @cookbook_version = double("Cookbook::Version", :version => "1.2.3") @new_resource.stub(:cookbook_version).and_return(@cookbook_version) @current_resource = Chef::Resource::File.new("/tmp/a-file.txt") @start_time = Time.new @@ -381,7 +381,7 @@ describe Chef::ResourceReporter do @backtrace = ["foo.rb:1 in `foo!'","bar.rb:2 in `bar!","'baz.rb:3 in `baz!'"] @node = Chef::Node.new @node.name("spitfire") - @exception = mock("ArgumentError") + @exception = double("ArgumentError") @exception.stub(:inspect).and_return("Net::HTTPServerException") @exception.stub(:message).and_return("Object not found") @exception.stub(:backtrace).and_return(@backtrace) diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index b45ad1df3f..220e4ea4a6 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -174,7 +174,7 @@ describe Chef::RunList do @role.override_attributes :three => :four Chef::Role.stub(:load).and_return(@role) - @rest = mock("Chef::REST", { :get_rest => @role, :url => "/" }) + @rest = double("Chef::REST", { :get_rest => @role, :url => "/" }) Chef::REST.stub(:new).and_return(@rest) @run_list << "role[stubby]" @@ -218,7 +218,7 @@ describe Chef::RunList do describe "and multiply nested roles" do before do - @multiple_rest_requests = mock("Chef::REST") + @multiple_rest_requests = double("Chef::REST") @role.env_run_list["production"] << "role[prod-base]" diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb index 3cfecfaa35..48f820ff85 100644 --- a/spec/unit/scan_access_control_spec.rb +++ b/spec/unit/scan_access_control_spec.rb @@ -49,7 +49,7 @@ describe Chef::ScanAccessControl do describe "when the fs entity exists" do before do - @stat = mock("File::Stat for #{@new_resource.path}", :uid => 0, :gid => 0, :mode => 00100644) + @stat = double("File::Stat for #{@new_resource.path}", :uid => 0, :gid => 0, :mode => 00100644) File.should_receive(:realpath).with(@new_resource.path).and_return(@real_file) File.should_receive(:stat).with(@real_file).and_return(@stat) File.should_receive(:exist?).with(@new_resource.path).and_return(true) @@ -128,7 +128,7 @@ describe Chef::ScanAccessControl do end it "sets the owner of current_resource to the username of the current owner" do - @root_passwd = mock("Struct::Passwd for uid 0", :name => "root") + @root_passwd = double("Struct::Passwd for uid 0", :name => "root") Etc.should_receive(:getpwuid).with(0).and_return(@root_passwd) @scanner.set_all! @@ -163,7 +163,7 @@ describe Chef::ScanAccessControl do end it "sets the group of the current resource to the group name" do - @group_entry = mock("Struct::Group for wheel", :name => "wheel") + @group_entry = double("Struct::Group for wheel", :name => "wheel") Etc.should_receive(:getgrgid).with(0).and_return(@group_entry) @scanner.set_all! diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index bebb69f111..d880f49a4b 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -21,7 +21,7 @@ require 'chef/search/query' describe Chef::Search::Query do before(:each) do - @rest = mock("Chef::REST") + @rest = double("Chef::REST") Chef::REST.stub(:new).and_return(@rest) @query = Chef::Search::Query.new end @@ -85,13 +85,13 @@ describe Chef::Search::Query do end it "should call a block for each object in the response" do - @call_me = mock("blocky") + @call_me = double("blocky") @response["rows"].each { |r| @call_me.should_receive(:do).with(r) } @query.search(:foo) { |r| @call_me.do(r) } end it "should page through the responses" do - @call_me = mock("blocky") + @call_me = double("blocky") @response["rows"].each { |r| @call_me.should_receive(:do).with(r) } @query.search(:foo, "*:*", nil, 0, 1) { |r| @call_me.do(r) } end diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb index 17e4227a75..eae3b2b581 100644 --- a/spec/unit/shell/model_wrapper_spec.rb +++ b/spec/unit/shell/model_wrapper_spec.rb @@ -71,7 +71,7 @@ describe Shell::ModelWrapper do @wrapper = Shell::ModelWrapper.new(Chef::Node) # Creating a Chef::Search::Query object tries to read the private key... - @searcher = mock("Chef::Search::Query #{__FILE__}:#{__LINE__}") + @searcher = double("Chef::Search::Query #{__FILE__}:#{__LINE__}") Chef::Search::Query.stub(:new).and_return(@searcher) end diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb index 4710fd9c4b..c24acbca3e 100644 --- a/spec/unit/shell/shell_ext_spec.rb +++ b/spec/unit/shell/shell_ext_spec.rb @@ -28,14 +28,14 @@ describe Shell::Extensions do @root_context = Object.new @root_context.instance_eval(&ObjectTestHarness) Shell::Extensions.extend_context_object(@root_context) - @root_context.conf = mock("irbconf") + @root_context.conf = double("irbconf") end it "finds a subsession in irb for an object" do target_context_obj = Chef::Node.new - irb_context = mock("context", :main => target_context_obj) - irb_session = mock("irb session", :context => irb_context) + irb_context = double("context", :main => target_context_obj) + irb_session = double("irb session", :context => irb_context) @job_manager.jobs = [[:thread, irb_session]] @root_context.stub(:jobs).and_return(@job_manager) @root_context.ensure_session_select_defined @@ -92,7 +92,7 @@ describe Shell::Extensions do end it "prints node attributes" do - node = mock("node", :attribute => {:foo => :bar}) + node = double("node", :attribute => {:foo => :bar}) @shell_client.node = node @root_context.should_receive(:pp).with({:foo => :bar}) @root_context.ohai diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb index 2ad24d05ce..d305ed0ec6 100644 --- a/spec/unit/shell/shell_session_spec.rb +++ b/spec/unit/shell/shell_session_spec.rb @@ -89,7 +89,7 @@ describe Shell::StandAloneSession do it "runs chef with the standalone recipe" do @session.stub(:node_built?).and_return(true) Chef::Log.stub(:level) - chef_runner = mock("Chef::Runner.new", :converge => :converged) + chef_runner = double("Chef::Runner.new", :converge => :converged) # pre-heat resource collection cache @session.resource_collection @@ -145,7 +145,7 @@ describe Shell::SoloSession do it "runs chef with a resource collection from the compiled cookbooks" do @session.stub(:node_built?).and_return(true) Chef::Log.stub(:level) - chef_runner = mock("Chef::Runner.new", :converge => :converged) + chef_runner = double("Chef::Runner.new", :converge => :converged) Chef::Runner.should_receive(:new).with(an_instance_of(Chef::RunContext)).and_return(chef_runner) @recipe.run_chef.should == :converged diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 2363ce67ae..c535e4172b 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -196,7 +196,7 @@ describe Chef::User do before (:each) do @user = Chef::User.new @user.name "foobar" - @http_client = mock("Chef::REST mock") + @http_client = double("Chef::REST mock") Chef::REST.stub(:new).and_return(@http_client) end diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index c49694f924..617886cede 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -27,7 +27,7 @@ describe Chef::Util::Backup do end before(:each) do - @new_resource = mock("new_resource") + @new_resource = double("new_resource") @new_resource.should_receive(:path).at_least(:once).and_return(tempfile.path) @backup = Chef::Util::Backup.new(@new_resource) end diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index a69e236240..d87cebf95c 100644 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -61,7 +61,7 @@ describe Chef::Util::Selinux do describe "when selinux is enabled" do before do - cmd_result = mock("Cmd Result", :exitstatus => 0) + cmd_result = double("Cmd Result", :exitstatus => 0) @test_instance.should_receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) end @@ -74,7 +74,7 @@ describe Chef::Util::Selinux do describe "when selinux is disabled" do before do - cmd_result = mock("Cmd Result", :exitstatus => 1) + cmd_result = double("Cmd Result", :exitstatus => 1) @test_instance.should_receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) end @@ -87,7 +87,7 @@ describe Chef::Util::Selinux do describe "when selinux gives an unexpected status" do before do - cmd_result = mock("Cmd Result", :exitstatus => 101) + cmd_result = double("Cmd Result", :exitstatus => 101) @test_instance.should_receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) end |