summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:18:28 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-01-29 14:18:28 -0800
commitdb9f8dce667916cd6575d2894c8ca25006138836 (patch)
treee53990767d7a7b7e8c369cf546e298e1635788d9 /spec/support
parentb19b7d000887209f9d8dc1dc6aa468a0497a7391 (diff)
downloadchef-db9f8dce667916cd6575d2894c8ca25006138836.tar.gz
s/mock\(/double(/g
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/mock/platform.rb2
-rw-r--r--spec/support/shared/unit/provider/file.rb12
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb14
3 files changed, 14 insertions, 14 deletions
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index df90d1eda2..46e8c74d72 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -5,7 +5,7 @@
# 'i386-mingw32' (windows) or 'x86_64-darwin11.2.0' (unix). Usueful for
# testing code that mixes in platform specific modules like +Chef::Mixin::Securable+
# or +Chef::FileAccessControl+
-def platform_mock(platform = :unix, &block)
+def platform_double(platform = :unix, &block)
Chef::Platform.stub(:windows?).and_return(platform == :windows ? true : false)
ENV['SYSTEMDRIVE'] = (platform == :windows ? 'C:' : nil)
if block_given?
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 72dda3c07a..1200b2a488 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -220,11 +220,11 @@ shared_examples_for Chef::Provider::File do
Chef::Platform.stub(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
resource_real_path = File.realpath(resource.path)
File.should_receive(:stat).with(resource_real_path).at_least(:once).and_return(stat_struct)
- Etc.stub(:getgrgid).with(0).and_return(mock("Group Ent", :name => "wheel"))
- Etc.stub(:getpwuid).with(0).and_return(mock("User Ent", :name => "root"))
+ Etc.stub(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
+ Etc.stub(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
end
context "when the new_resource does not specify any state" do
@@ -345,11 +345,11 @@ shared_examples_for Chef::Provider::File do
Chef::Platform.stub(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
resource_real_path = File.realpath(resource.path)
File.stub(:stat).with(resource_real_path).and_return(stat_struct)
- Etc.stub(:getgrgid).with(0).and_return(mock("Group Ent", :name => "wheel"))
- Etc.stub(:getpwuid).with(0).and_return(mock("User Ent", :name => "root"))
+ Etc.stub(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
+ Etc.stub(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
provider.send(:load_resource_attributes_from_file, resource)
end
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index 269372ab9b..8043c0cd3b 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -260,12 +260,12 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when checking the lock" do
# lazy initialize so we can modify stdout and stderr strings
let(:passwd_s_status) do
- mock("Mixlib::ShellOut command", :exitstatus => 0, :stdout => @stdout, :stderr => @stderr)
+ double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => @stdout, :stderr => @stderr)
end
before(:each) do
# @node = Chef::Node.new
- # @new_resource = mock("Chef::Resource::User",
+ # @new_resource = double("Chef::Resource::User",
# :nil_object => true,
# :username => "adam"
# )
@@ -313,7 +313,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
provider.should_receive(:shell_out!).
with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
and_return(passwd_s_status)
- rpm_status = mock("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-1\n", :stderr => "")
+ rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-1\n", :stderr => "")
provider.should_receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
lambda { provider.check_lock }.should_not raise_error(Chef::Exceptions::User)
end
@@ -324,7 +324,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
provider.should_receive(:shell_out!).
with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
and_return(passwd_s_status)
- rpm_status = mock("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-2\n", :stderr => "")
+ rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-2\n", :stderr => "")
provider.should_receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
lambda { provider.check_lock }.should raise_error(Chef::Exceptions::User)
end
@@ -338,7 +338,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
context "when in why run mode" do
before do
- passwd_status = mock("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
+ passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
provider.should_receive(:shell_out!).
with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
and_return(passwd_status)
@@ -398,9 +398,9 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
].each do |home_check|
it home_check["action"] do
provider.current_resource.home home_check["current_resource_home"].first
- @current_home_mock = mock("Pathname")
+ @current_home_mock = double("Pathname")
provider.new_resource.home home_check["new_resource_home"].first
- @new_home_mock = mock("Pathname")
+ @new_home_mock = double("Pathname")
Pathname.should_receive(:new).with(@current_resource.home).and_return(@current_home_mock)
@current_home_mock.should_receive(:cleanpath).and_return(home_check["current_resource_home"].last)