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/provider | |
parent | b19b7d000887209f9d8dc1dc6aa468a0497a7391 (diff) | |
download | chef-db9f8dce667916cd6575d2894c8ca25006138836.tar.gz |
s/mock\(/double(/g
Diffstat (limited to 'spec/unit/provider')
61 files changed, 245 insertions, 245 deletions
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) |