summaryrefslogtreecommitdiff
path: root/spec/functional/resource
diff options
context:
space:
mode:
Diffstat (limited to 'spec/functional/resource')
-rwxr-xr-xspec/functional/resource/aixinit_service_spec.rb4
-rw-r--r--spec/functional/resource/deploy_revision_spec.rb196
-rwxr-xr-xspec/functional/resource/env_spec.rb6
-rw-r--r--spec/functional/resource/execute_spec.rb10
-rw-r--r--spec/functional/resource/file_spec.rb14
-rw-r--r--spec/functional/resource/git_spec.rb24
-rw-r--r--spec/functional/resource/group_spec.rb50
-rw-r--r--spec/functional/resource/ifconfig_spec.rb4
-rw-r--r--spec/functional/resource/link_spec.rb176
-rw-r--r--spec/functional/resource/mount_spec.rb10
-rw-r--r--spec/functional/resource/ohai_spec.rb2
-rw-r--r--spec/functional/resource/package_spec.rb44
-rw-r--r--spec/functional/resource/powershell_spec.rb84
-rw-r--r--spec/functional/resource/reboot_spec.rb4
-rw-r--r--spec/functional/resource/registry_spec.rb180
-rw-r--r--spec/functional/resource/remote_directory_spec.rb38
-rw-r--r--spec/functional/resource/remote_file_spec.rb36
-rw-r--r--spec/functional/resource/template_spec.rb8
-rw-r--r--spec/functional/resource/user/dscl_spec.rb8
-rw-r--r--spec/functional/resource/user/useradd_spec.rb92
20 files changed, 494 insertions, 496 deletions
diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb
index a99309187c..3d3234f0f7 100755
--- a/spec/functional/resource/aixinit_service_spec.rb
+++ b/spec/functional/resource/aixinit_service_spec.rb
@@ -29,11 +29,11 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
# Platform specific validation routines.
def service_should_be_started(file_name)
# The existance of this file indicates that the service was started.
- expect(File.exists?("/tmp/#{file_name}")).to be_true
+ expect(File.exists?("/tmp/#{file_name}")).to be_truthy
end
def service_should_be_stopped(file_name)
- expect(File.exists?("/tmp/#{file_name}")).to be_false
+ expect(File.exists?("/tmp/#{file_name}")).to be_falsey
end
def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb
index eae422ac1d..7bc3da9a05 100644
--- a/spec/functional/resource/deploy_revision_spec.rb
+++ b/spec/functional/resource/deploy_revision_spec.rb
@@ -173,12 +173,12 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
it "deploys the app to the target revision (#{target_rev_spec})" do
target_rev = send(target_rev_spec)
- File.should exist(rel_path("current"))
+ expect(File).to exist(rel_path("current"))
- actual_current_rev.should == target_rev
+ expect(actual_current_rev).to eq(target_rev)
# Is the app code actually there?
- File.should exist(rel_path("current/app/app.rb"))
+ expect(File).to exist(rel_path("current/app/app.rb"))
end
end
@@ -193,12 +193,12 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the application" do
- File.should exist(rel_path("current/restart.txt"))
- actual_operations_order.should == %w[deploy_to_latest_rev]
+ expect(File).to exist(rel_path("current/restart.txt"))
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev])
end
it "is marked as updated" do
- deploy_to_latest_rev.should be_updated_by_last_action
+ expect(deploy_to_latest_rev).to be_updated_by_last_action
end
end
@@ -215,15 +215,15 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_latest_rev deploy_to_previous_rev deploy_to_latest_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev deploy_to_previous_rev deploy_to_latest_rev_again])
end
it "is marked updated" do
- deploy_to_latest_rev_again.should be_updated_by_last_action
+ expect(deploy_to_latest_rev_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the fourth version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the fourth version of the app")
end
end
@@ -233,27 +233,27 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
it "creates the required directory tree" do
- File.should be_directory(rel_path("releases"))
- File.should be_directory(rel_path("shared"))
- File.should be_directory(rel_path("releases/#{latest_rev}"))
+ expect(File).to be_directory(rel_path("releases"))
+ expect(File).to be_directory(rel_path("shared"))
+ expect(File).to be_directory(rel_path("releases/#{latest_rev}"))
- File.should be_directory(rel_path("current/tmp"))
- File.should be_directory(rel_path("current/config"))
- File.should be_directory(rel_path("current/public"))
+ expect(File).to be_directory(rel_path("current/tmp"))
+ expect(File).to be_directory(rel_path("current/config"))
+ expect(File).to be_directory(rel_path("current/public"))
- File.should be_symlink(rel_path("current"))
- File.readlink(rel_path("current")).should == rel_path("releases/#{latest_rev}")
+ expect(File).to be_symlink(rel_path("current"))
+ expect(File.readlink(rel_path("current"))).to eq(rel_path("releases/#{latest_rev}"))
end
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the application" do
- File.should exist(rel_path("current/restart.txt"))
- actual_operations_order.should == %w[deploy_to_latest_rev]
+ expect(File).to exist(rel_path("current/restart.txt"))
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev])
end
it "is marked as updated" do
- deploy_to_latest_rev.should be_updated_by_last_action
+ expect(deploy_to_latest_rev).to be_updated_by_last_action
end
end
@@ -266,11 +266,11 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "does not restart the app" do
- actual_operations_order.should == %w[deploy_to_latest_rev]
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev])
end
it "is not marked updated" do
- deploy_to_latest_rev.should_not be_updated_by_last_action
+ expect(deploy_to_latest_rev).not_to be_updated_by_last_action
end
end
@@ -284,11 +284,11 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the app" do
- actual_operations_order.should == %w[deploy_to_latest_rev deploy_to_latest_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev deploy_to_latest_rev_again])
end
it "is marked updated" do
- deploy_to_latest_rev.should be_updated_by_last_action
+ expect(deploy_to_latest_rev).to be_updated_by_last_action
end
end
@@ -302,15 +302,15 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the application after the new deploy" do
- actual_operations_order.should == %w[deploy_to_previous_rev deploy_to_latest_rev]
+ expect(actual_operations_order).to eq(%w[deploy_to_previous_rev deploy_to_latest_rev])
end
it "is marked updated" do
- deploy_to_previous_rev.should be_updated_by_last_action
+ expect(deploy_to_previous_rev).to be_updated_by_last_action
end
it "leaves the old copy of the app around for rollback" do
- File.should exist(File.join(deploy_directory, "releases", previous_rev))
+ expect(File).to exist(File.join(deploy_directory, "releases", previous_rev))
end
end
@@ -325,15 +325,15 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_latest_rev deploy_to_previous_rev deploy_to_latest_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_latest_rev deploy_to_previous_rev deploy_to_latest_rev_again])
end
it "is marked updated" do
- deploy_to_latest_rev_again.should be_updated_by_last_action
+ expect(deploy_to_latest_rev_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the fourth version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the fourth version of the app")
end
end
@@ -350,31 +350,31 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:previous_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_previous_rev deploy_to_latest_rev deploy_to_latest_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_previous_rev deploy_to_latest_rev deploy_to_latest_rev_again])
end
it "is marked updated" do
- deploy_to_latest_rev_again.should be_updated_by_last_action
+ expect(deploy_to_latest_rev_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the third version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the third version of the app")
end
it "all_releases after first deploy should have one entry" do
- @previous_rev_all_releases.length.should == 1
+ expect(@previous_rev_all_releases.length).to eq(1)
end
it "all_releases after second deploy should have two entries" do
- @latest_rev_all_releases.length.should == 2
+ expect(@latest_rev_all_releases.length).to eq(2)
end
it "all_releases after rollback should have one entry" do
- @previous_rev_again_all_releases.length.should == 1
+ expect(@previous_rev_again_all_releases.length).to eq(1)
end
it "all_releases after rollback should be the same as after the first deploy" do
- @previous_rev_again_all_releases.should == @previous_rev_all_releases
+ expect(@previous_rev_again_all_releases).to eq(@previous_rev_all_releases)
end
end
@@ -393,31 +393,31 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:previous_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_previous_rev deploy_to_latest_rev deploy_to_previous_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_previous_rev deploy_to_latest_rev deploy_to_previous_rev_again])
end
it "is marked updated" do
- deploy_to_previous_rev_again.should be_updated_by_last_action
+ expect(deploy_to_previous_rev_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the third version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the third version of the app")
end
it "all_releases after first deploy should have one entry" do
- @previous_rev_all_releases.length.should == 1
+ expect(@previous_rev_all_releases.length).to eq(1)
end
it "all_releases after second deploy should have two entries" do
- @latest_rev_all_releases.length.should == 2
+ expect(@latest_rev_all_releases.length).to eq(2)
end
it "all_releases after rollback should have one entry" do
- @previous_rev_again_all_releases.length.should == 1
+ expect(@previous_rev_again_all_releases.length).to eq(1)
end
it "all_releases after rollback should be the same as after the first deploy" do
- @previous_rev_again_all_releases.should == @previous_rev_all_releases
+ expect(@previous_rev_again_all_releases).to eq(@previous_rev_all_releases)
end
end
@@ -438,23 +438,23 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:second_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_second_rev deploy_to_previous_rev deploy_to_previous_rev_again deploy_to_latest_rev deploy_to_latest_rev_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_second_rev deploy_to_previous_rev deploy_to_previous_rev_again deploy_to_latest_rev deploy_to_latest_rev_again])
end
it "is marked updated" do
- deploy_to_latest_rev_again.should be_updated_by_last_action
+ expect(deploy_to_latest_rev_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the second version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the second version of the app")
end
it "all_releases after rollback should have one entry" do
- @fifth_deploy_all_releases.length.should == 1
+ expect(@fifth_deploy_all_releases.length).to eq(1)
end
it "all_releases after rollback should be the same as after the first deploy" do
- @fifth_deploy_all_releases.should == @first_deploy_all_releases
+ expect(@fifth_deploy_all_releases).to eq(@first_deploy_all_releases)
end
end
@@ -475,23 +475,23 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:second_rev)
it "restarts the application after rolling back" do
- actual_operations_order.should == %w[deploy_to_second_rev deploy_to_previous_rev deploy_to_second_rev_again deploy_to_latest_rev deploy_to_second_rev_again_again]
+ expect(actual_operations_order).to eq(%w[deploy_to_second_rev deploy_to_previous_rev deploy_to_second_rev_again deploy_to_latest_rev deploy_to_second_rev_again_again])
end
it "is marked updated" do
- deploy_to_second_rev_again_again.should be_updated_by_last_action
+ expect(deploy_to_second_rev_again_again).to be_updated_by_last_action
end
it "deploys the right code" do
- IO.read(rel_path("current/app/app.rb")).should include("this is the second version of the app")
+ expect(IO.read(rel_path("current/app/app.rb"))).to include("this is the second version of the app")
end
it "all_releases after rollback should have one entry" do
- @fifth_deploy_all_releases.length.should == 1
+ expect(@fifth_deploy_all_releases.length).to eq(1)
end
it "all_releases after rollback should be the same as after the first deploy" do
- @fifth_deploy_all_releases.should == @first_deploy_all_releases
+ expect(@fifth_deploy_all_releases).to eq(@first_deploy_all_releases)
end
end
@@ -510,21 +510,21 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
before do
- File.should_not exist(deploy_directory)
+ expect(File).not_to exist(deploy_directory)
deploy_to_latest_rev.run_action(:deploy)
end
it "creates the required directory tree" do
- File.should be_directory(rel_path("releases"))
- File.should be_directory(rel_path("shared"))
- File.should be_directory(rel_path("releases/#{latest_rev}"))
+ expect(File).to be_directory(rel_path("releases"))
+ expect(File).to be_directory(rel_path("shared"))
+ expect(File).to be_directory(rel_path("releases/#{latest_rev}"))
- File.should be_directory(rel_path("current/tmp"))
- File.should be_directory(rel_path("current/config"))
- File.should be_directory(rel_path("current/public"))
+ expect(File).to be_directory(rel_path("current/tmp"))
+ expect(File).to be_directory(rel_path("current/config"))
+ expect(File).to be_directory(rel_path("current/public"))
- File.should be_symlink(rel_path("current"))
- File.readlink(rel_path("current")).should == rel_path("releases/#{latest_rev}")
+ expect(File).to be_symlink(rel_path("current"))
+ expect(File.readlink(rel_path("current"))).to eq(rel_path("releases/#{latest_rev}"))
end
the_app_is_deployed_at_revision(:latest_rev)
@@ -599,18 +599,18 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:latest_rev)
it "is marked updated" do
- deploy_to_latest_with_inline_recipes.should be_updated_by_last_action
+ expect(deploy_to_latest_with_inline_recipes).to be_updated_by_last_action
end
it "calls the callbacks in order" do
- callback_order.should == [:before_migrate, :before_symlink, :before_restart, :after_restart]
+ expect(callback_order).to eq([:before_migrate, :before_symlink, :before_restart, :after_restart])
end
it "runs chef resources in the callbacks" do
- File.should exist(rel_path("current/before_migrate.txt"))
- File.should exist(rel_path("current/before_symlink.txt"))
- File.should exist(rel_path("current/tmp/before_restart.txt"))
- File.should exist(rel_path("current/tmp/after_restart.txt"))
+ expect(File).to exist(rel_path("current/before_migrate.txt"))
+ expect(File).to exist(rel_path("current/before_symlink.txt"))
+ expect(File).to exist(rel_path("current/tmp/before_restart.txt"))
+ expect(File).to exist(rel_path("current/tmp/after_restart.txt"))
end
end
@@ -629,10 +629,10 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
the_app_is_deployed_at_revision(:rev_with_in_repo_callbacks)
it "runs chef resources in the callbacks" do
- File.should exist(rel_path("current/before_migrate.txt"))
- File.should exist(rel_path("current/before_symlink.txt"))
- File.should exist(rel_path("current/tmp/before_restart.txt"))
- File.should exist(rel_path("current/tmp/after_restart.txt"))
+ expect(File).to exist(rel_path("current/before_migrate.txt"))
+ expect(File).to exist(rel_path("current/before_symlink.txt"))
+ expect(File).to exist(rel_path("current/tmp/before_restart.txt"))
+ expect(File).to exist(rel_path("current/tmp/after_restart.txt"))
end
end
@@ -690,7 +690,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
it "runs migrations in between the before_migrate and before_symlink steps" do
- actual_operations_order.should == %w[before_migrate migration before_symlink before_restart after_restart]
+ expect(actual_operations_order).to eq(%w[before_migrate migration before_symlink before_restart after_restart])
end
end
@@ -703,7 +703,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
it "should not raise an exception calling File.utime on symlinks" do
- lambda { deploy_with_in_repo_symlinks.run_action(:deploy) }.should_not raise_error
+ expect { deploy_with_in_repo_symlinks.run_action(:deploy) }.not_to raise_error
end
end
@@ -712,16 +712,16 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
shared_examples_for "a redeployed application" do
it "should redeploy the application" do
- File.should be_directory(rel_path("releases"))
- File.should be_directory(rel_path("shared"))
- File.should be_directory(rel_path("releases/#{latest_rev}"))
+ expect(File).to be_directory(rel_path("releases"))
+ expect(File).to be_directory(rel_path("shared"))
+ expect(File).to be_directory(rel_path("releases/#{latest_rev}"))
- File.should be_directory(rel_path("current/tmp"))
- File.should be_directory(rel_path("current/config"))
- File.should be_directory(rel_path("current/public"))
+ expect(File).to be_directory(rel_path("current/tmp"))
+ expect(File).to be_directory(rel_path("current/config"))
+ expect(File).to be_directory(rel_path("current/public"))
- File.should be_symlink(rel_path("current"))
- File.readlink(rel_path("current")).should == rel_path("releases/#{latest_rev}")
+ expect(File).to be_symlink(rel_path("current"))
+ expect(File.readlink(rel_path("current"))).to eq(rel_path("releases/#{latest_rev}"))
end
end
@@ -758,23 +758,23 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
shared_examples_for "a recovered deployment" do
it "should redeploy the application" do
- File.should be_directory(rel_path("releases"))
- File.should be_directory(rel_path("shared"))
- File.should be_directory(rel_path("releases/#{latest_rev}"))
+ expect(File).to be_directory(rel_path("releases"))
+ expect(File).to be_directory(rel_path("shared"))
+ expect(File).to be_directory(rel_path("releases/#{latest_rev}"))
- File.should be_directory(rel_path("current/tmp"))
- File.should be_directory(rel_path("current/config"))
- File.should be_directory(rel_path("current/public"))
+ expect(File).to be_directory(rel_path("current/tmp"))
+ expect(File).to be_directory(rel_path("current/config"))
+ expect(File).to be_directory(rel_path("current/public"))
- File.should be_symlink(rel_path("current"))
- File.readlink(rel_path("current")).should == rel_path("releases/#{latest_rev}")
+ expect(File).to be_symlink(rel_path("current"))
+ expect(File.readlink(rel_path("current"))).to eq(rel_path("releases/#{latest_rev}"))
# if callbacks ran, we know the app was deployed and not merely rolled
# back to a (busted) prior deployment.
- callback_order.should == [:before_migrate,
+ expect(callback_order).to eq([:before_migrate,
:before_symlink,
:before_restart,
- :after_restart ]
+ :after_restart ])
end
end
@@ -794,7 +794,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
context "in the `#{callback}' callback" do
before do
- lambda { deploy_that_fails.run_action(:deploy) }.should raise_error(Exception, %r{I am a failed deploy})
+ expect { deploy_that_fails.run_action(:deploy) }.to raise_error(Exception, %r{I am a failed deploy})
deploy_to_latest_with_callback_tracking.run_action(:deploy)
end
@@ -820,7 +820,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
before do
- lambda { deploy_that_fails.run_action(:deploy) }.should raise_error(Chef::Exceptions::Exec)
+ expect { deploy_that_fails.run_action(:deploy) }.to raise_error(Chef::Exceptions::Exec)
deploy_to_latest_with_callback_tracking.run_action(:deploy)
end
@@ -852,7 +852,7 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
before do
- lambda { deploy_that_fails.run_action(:deploy) }.should raise_error(RuntimeError, /network error/)
+ expect { deploy_that_fails.run_action(:deploy) }.to raise_error(RuntimeError, /network error/)
deploy_to_latest_with_callback_tracking.run_action(:deploy)
end
@@ -868,12 +868,12 @@ describe Chef::Resource::DeployRevision, :unix_only => true do
end
before do
- lambda { deploy_that_fails.run_action(:deploy) }.should raise_error(Exception, %r{I am a failed deploy})
+ expect { deploy_that_fails.run_action(:deploy) }.to raise_error(Exception, %r{I am a failed deploy})
deploy_to_latest_rev.run_action(:deploy)
end
it "removes the unsuccessful deploy after a later successful deploy" do
- ::File.should_not exist(File.join(deploy_directory, "releases", previous_rev))
+ expect(::File).not_to exist(File.join(deploy_directory, "releases", previous_rev))
end
end
diff --git a/spec/functional/resource/env_spec.rb b/spec/functional/resource/env_spec.rb
index 8178eeba3d..16caec14bf 100755
--- a/spec/functional/resource/env_spec.rb
+++ b/spec/functional/resource/env_spec.rb
@@ -131,12 +131,12 @@ describe Chef::Resource::Env, :windows_only do
let!(:env_path_before) { ENV['PATH'] }
it 'should expand PATH' do
- path_before.should_not include(env_val)
+ expect(path_before).not_to include(env_val)
test_resource.key_name('PATH')
test_resource.value("#{path_before};#{env_val}")
test_resource.run_action(:create)
- ENV['PATH'].should_not include(env_val)
- ENV['PATH'].should include("#{random_name}")
+ expect(ENV['PATH']).not_to include(env_val)
+ expect(ENV['PATH']).to include("#{random_name}")
end
after(:each) do
diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb
index ff358fe045..39fef76ab0 100644
--- a/spec/functional/resource/execute_spec.rb
+++ b/spec/functional/resource/execute_spec.rb
@@ -47,7 +47,7 @@ describe Chef::Resource::Execute do
true
end
execute_resource.run_action(:run)
- execute_resource.should be_updated_by_last_action
+ expect(execute_resource).to be_updated_by_last_action
end
end
@@ -58,7 +58,7 @@ describe Chef::Resource::Execute do
it "guard inherits :cwd from resource" do
execute_resource.run_action(:run)
- execute_resource.should be_updated_by_last_action
+ expect(execute_resource).to be_updated_by_last_action
end
end
@@ -77,7 +77,7 @@ describe Chef::Resource::Execute do
it "guard inherits :environment value from resource" do
execute_resource.run_action(:run)
- execute_resource.should be_updated_by_last_action
+ expect(execute_resource).to be_updated_by_last_action
end
describe "when guard sets additional values in the :environment" do
@@ -91,7 +91,7 @@ describe Chef::Resource::Execute do
it "guard sees merged value for in its ENV" do
execute_resource.run_action(:run)
- execute_resource.should be_updated_by_last_action
+ expect(execute_resource).to be_updated_by_last_action
end
end
@@ -106,7 +106,7 @@ describe Chef::Resource::Execute do
it "guard sees value from guard options in its ENV" do
execute_resource.run_action(:run)
- execute_resource.should be_updated_by_last_action
+ expect(execute_resource).to be_updated_by_last_action
end
end
end
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index 83f051ea06..cf70c349fb 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -77,11 +77,11 @@ describe Chef::Resource::File do
context "and the target file does not exist" do
it "creates the file" do
- File.should exist(path)
+ expect(File).to exist(path)
end
it "is marked updated by last action" do
- resource_without_content.should be_updated_by_last_action
+ expect(resource_without_content).to be_updated_by_last_action
end
end
end
@@ -106,11 +106,11 @@ describe Chef::Resource::File do
end
it "it creates the file" do
- File.should exist(path)
+ expect(File).to exist(path)
end
it "is marked updated by last action" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
end
@@ -128,15 +128,15 @@ describe Chef::Resource::File do
end
it "updates the mtime of the file" do
- File.stat(path).mtime.should > @expected_mtime
+ expect(File.stat(path).mtime).to be > @expected_mtime
end
it "does not change the content" do
- sha256_checksum(path).should == @expected_checksum
+ expect(sha256_checksum(path)).to eq(@expected_checksum)
end
it "is marked as updated by last action" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
end
end
diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb
index f0bd94b0c0..4f462b7cb6 100644
--- a/spec/functional/resource/git_spec.rb
+++ b/spec/functional/resource/git_spec.rb
@@ -130,10 +130,10 @@ E
it "checks out the revision pointed to by the tag commit, not the tag commit itself" do
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == v1_commit
+ expect(head_rev).to eq(v1_commit)
# also verify the tag commit itself is what we expect as an extra sanity check
rev = shell_out!('git rev-parse v1.0.0', :cwd => deploy_directory, :returns => [0]).stdout.strip
- rev.should == v1_tag
+ expect(rev).to eq(v1_tag)
end
it "doesn't update if up-to-date" do
@@ -141,10 +141,10 @@ E
# properly to the pointed to commit.
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == v1_commit
+ expect(head_rev).to eq(v1_commit)
copy_git_resource.run_action(:sync)
- copy_git_resource.should_not be_updated
+ expect(copy_git_resource).not_to be_updated
end
end
@@ -167,25 +167,25 @@ E
basic_git_resource.revision rev_foo
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == rev_foo
+ expect(head_rev).to eq(rev_foo)
end
it "doesn't update if up-to-date" do
basic_git_resource.revision rev_foo
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == rev_foo
+ expect(head_rev).to eq(rev_foo)
copy_git_resource.revision rev_foo
copy_git_resource.run_action(:sync)
- copy_git_resource.should_not be_updated
+ expect(copy_git_resource).not_to be_updated
end
it "checks out the expected revision 972d" do
basic_git_resource.revision rev_testing
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == rev_testing
+ expect(head_rev).to eq(rev_testing)
end
end
@@ -200,7 +200,7 @@ E
it "checks out the expected revision" do
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == rev_head
+ expect(head_rev).to eq(rev_head)
end
end
@@ -215,7 +215,7 @@ E
it "checks out HEAD as the default revision" do
basic_git_resource.run_action(:sync)
head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip
- head_rev.should == rev_head
+ expect(head_rev).to eq(rev_head)
end
end
@@ -244,7 +244,7 @@ E
head_rev = shell_out!('git rev-parse HEAD',
:cwd => deploy_directory,
:returns => [0]).stdout.strip
- head_rev.should == rev_head
+ expect(head_rev).to eq(rev_head)
end
it "checks out the (master) HEAD revision when no revision is specified (ignores tag)" do
@@ -252,7 +252,7 @@ E
head_rev = shell_out!('git rev-parse HEAD',
:cwd => deploy_directory,
:returns => [0]).stdout.strip
- head_rev.should == rev_head
+ expect(head_rev).to eq(rev_head)
end
end
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 9c14232071..01e79f96bf 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
temp_resource.append(true)
temp_resource.run_action(:modify)
members.each do |member|
- user_exist_in_group?(member).should == true
+ expect(user_exist_in_group?(member)).to eq(true)
end
end
@@ -119,7 +119,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
temp_resource.run_action(:create)
group_should_exist(group_name)
included_members.each do |member|
- user_exist_in_group?(member).should == false
+ expect(user_exist_in_group?(member)).to eq(false)
end
end
@@ -149,8 +149,8 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
it "should remove the existing users and add the new users to the group" do
group_resource.run_action(tested_action)
- user_exist_in_group?(spec_members[1]).should == true
- user_exist_in_group?(spec_members[0]).should == false
+ expect(user_exist_in_group?(spec_members[1])).to eq(true)
+ expect(user_exist_in_group?(spec_members[0])).to eq(false)
end
end
@@ -176,10 +176,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
group_resource.run_action(tested_action)
included_members.each do |member|
- user_exist_in_group?(member).should == true
+ expect(user_exist_in_group?(member)).to eq(true)
end
excluded_members.each do |member|
- user_exist_in_group?(member).should == false
+ expect(user_exist_in_group?(member)).to eq(false)
end
end
@@ -192,10 +192,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
group_resource.run_action(tested_action)
included_members.each do |member|
- user_exist_in_group?(member).should == true
+ expect(user_exist_in_group?(member)).to eq(true)
end
excluded_members.each do |member|
- user_exist_in_group?(member).should == false
+ expect(user_exist_in_group?(member)).to eq(false)
end
end
end
@@ -204,13 +204,13 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
describe "when the users doesn't exist" do
describe "when append is not set" do
it "should raise an error" do
- lambda { @grp_resource.run_action(tested_action) }.should raise_error
+ expect { @grp_resource.run_action(tested_action) }.to raise_error
end
end
describe "when append is set" do
it "should raise an error" do
- lambda { @grp_resource.run_action(tested_action) }.should raise_error
+ expect { @grp_resource.run_action(tested_action) }.to raise_error
end
end
end
@@ -231,24 +231,24 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
describe "when updating membership" do
it "raises an error for a non well-formed domain name" do
group_resource.members [invalid_domain_user_name]
- lambda { group_resource.run_action(tested_action) }.should raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
end
it "raises an error for a nonexistent domain" do
group_resource.members [nonexistent_domain_user_name]
- lambda { group_resource.run_action(tested_action) }.should raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
end
end
describe "when removing members" do
it "raises an error for a non well-formed domain name" do
group_resource.excluded_members [invalid_domain_user_name]
- lambda { group_resource.run_action(tested_action) }.should raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
end
it "raises an error for a nonexistent domain" do
group_resource.excluded_members [nonexistent_domain_user_name]
- lambda { group_resource.run_action(tested_action) }.should raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
end
end
end
@@ -264,7 +264,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
}
it "append should be false by default" do
- group_resource.append.should == false
+ expect(group_resource.append).to eq(false)
end
describe "group create action" do
@@ -297,7 +297,7 @@ theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\
downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
it "should not create a group" do
- lambda { group_resource.run_action(:create) }.should raise_error
+ expect { group_resource.run_action(:create) }.to raise_error
group_should_not_exist(group_name)
end
end
@@ -308,7 +308,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
invalid_resource = group_resource.dup
invalid_resource.members(["Jack"])
invalid_resource.excluded_members(["Jack"])
- lambda { invalid_resource.run_action(:create)}.should raise_error(Chef::Exceptions::ConflictingMembersInGroup)
+ expect { invalid_resource.run_action(:create)}.to raise_error(Chef::Exceptions::ConflictingMembersInGroup)
end
end
end
@@ -342,7 +342,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "when there is no group" do
it "should raise an error" do
- lambda { group_resource.run_action(:modify) }.should raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
end
@@ -370,11 +370,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
describe "when there is no group" do
it "raises an error on modify" do
- lambda { group_resource.run_action(:modify) }.should raise_error
+ expect { group_resource.run_action(:modify) }.to raise_error
end
it "does not raise an error on manage" do
- lambda { group_resource.run_action(:manage) }.should_not raise_error
+ expect { group_resource.run_action(:manage) }.not_to raise_error
end
end
@@ -399,15 +399,15 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
let(:excluded_members) { ["Anthony"] }
it ":manage should raise an error" do
- lambda {group_resource.run_action(:manage) }.should raise_error
+ expect {group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- lambda {group_resource.run_action(:modify) }.should raise_error
+ expect {group_resource.run_action(:modify) }.to raise_error
end
it ":create should raise an error" do
- lambda {group_resource.run_action(:create) }.should raise_error
+ expect {group_resource.run_action(:create) }.to raise_error
end
end
@@ -419,11 +419,11 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" }
end
it ":manage should raise an error" do
- lambda {group_resource.run_action(:manage) }.should raise_error
+ expect {group_resource.run_action(:manage) }.to raise_error
end
it ":modify should raise an error" do
- lambda {group_resource.run_action(:modify) }.should raise_error
+ expect {group_resource.run_action(:modify) }.to raise_error
end
end
end
diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb
index c36288498b..9c613544ac 100644
--- a/spec/functional/resource/ifconfig_spec.rb
+++ b/spec/functional/resource/ifconfig_spec.rb
@@ -143,7 +143,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :external => include_flag do
end
it "should disable interface (vip)" do
new_resource.run_action(:disable)
- new_resource.should be_updated_by_last_action
+ expect(new_resource).to be_updated_by_last_action
interface_should_not_exists(network_interface_alias(en0_interface_for_test))
end
end
@@ -155,7 +155,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :external => include_flag do
end
it "should delete interface (vip)" do
new_resource.run_action(:delete)
- new_resource.should be_updated_by_last_action
+ expect(new_resource).to be_updated_by_last_action
interface_should_not_exists(network_interface_alias(en0_interface_for_test))
interface_persistence_should_not_exists(network_interface_alias(en0_interface_for_test))
end
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index 2220e973cf..816f111c60 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -123,8 +123,8 @@ describe Chef::Resource::Link do
describe "when supported on platform", :not_supported_on_win2k3 do
shared_examples_for 'delete errors out' do
it 'delete errors out' do
- lambda { resource.run_action(:delete) }.should raise_error(Chef::Exceptions::Link)
- (File.exist?(target_file) || symlink?(target_file)).should be_true
+ expect { resource.run_action(:delete) }.to raise_error(Chef::Exceptions::Link)
+ expect(File.exist?(target_file) || symlink?(target_file)).to be_truthy
end
end
@@ -132,19 +132,19 @@ describe Chef::Resource::Link do
describe 'the :delete action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:delete)
end
it 'leaves the file deleted' do
- File.exist?(target_file).should be_false
- symlink?(target_file).should be_false
+ expect(File.exist?(target_file)).to be_falsey
+ expect(symlink?(target_file)).to be_falsey
end
it 'does not mark the resource updated' do
- resource.should_not be_updated
+ expect(resource).not_to be_updated
end
it 'does not log that it deleted' do
- @info.include?("link[#{target_file}] deleted").should be_false
+ expect(@info.include?("link[#{target_file}] deleted")).to be_falsey
end
end
end
@@ -153,19 +153,19 @@ describe Chef::Resource::Link do
describe 'the :delete action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:delete)
end
it 'deletes the file' do
- File.exist?(target_file).should be_false
- symlink?(target_file).should be_false
+ expect(File.exist?(target_file)).to be_falsey
+ expect(symlink?(target_file)).to be_falsey
end
it 'marks the resource updated' do
- resource.should be_updated
+ expect(resource).to be_updated
end
it 'logs that it deleted' do
- @info.include?("link[#{target_file}] deleted").should be_true
+ expect(@info.include?("link[#{target_file}] deleted")).to be_truthy
end
end
end
@@ -174,19 +174,19 @@ describe Chef::Resource::Link do
describe 'the :create action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:create)
end
it 'links to the target file' do
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), to)).to be_truthy
end
it 'marks the resource updated' do
- resource.should be_updated
+ expect(resource).to be_updated
end
it 'logs that it created' do
- @info.include?("link[#{target_file}] created").should be_true
+ expect(@info.include?("link[#{target_file}] created")).to be_truthy
end
end
end
@@ -195,19 +195,19 @@ describe Chef::Resource::Link do
describe 'the :create action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:create)
end
it 'leaves the file linked' do
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), to)).to be_truthy
end
it 'does not mark the resource updated' do
- resource.should_not be_updated
+ expect(resource).not_to be_updated
end
it 'does not log that it created' do
- @info.include?("link[#{target_file}] created").should be_false
+ expect(@info.include?("link[#{target_file}] created")).to be_falsey
end
end
end
@@ -216,23 +216,23 @@ describe Chef::Resource::Link do
describe 'the :create action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:create)
end
it 'preserves the hard link' do
- File.exists?(target_file).should be_true
- symlink?(target_file).should be_false
+ expect(File.exists?(target_file)).to be_truthy
+ expect(symlink?(target_file)).to be_falsey
# Writing to one hardlinked file should cause both
# to have the new value.
- IO.read(to).should == IO.read(target_file)
+ expect(IO.read(to)).to eq(IO.read(target_file))
File.open(to, "w") { |file| file.write('wowzers') }
- IO.read(target_file).should == 'wowzers'
+ expect(IO.read(target_file)).to eq('wowzers')
end
it 'marks the resource updated' do
- resource.should be_updated
+ expect(resource).to be_updated
end
it 'logs that it created' do
- @info.include?("link[#{target_file}] created").should be_true
+ expect(@info.include?("link[#{target_file}] created")).to be_truthy
end
end
end
@@ -241,23 +241,23 @@ describe Chef::Resource::Link do
describe 'the :create action' do
before(:each) do
@info = []
- Chef::Log.stub(:info) { |msg| @info << msg }
+ allow(Chef::Log).to receive(:info) { |msg| @info << msg }
resource.run_action(:create)
end
it 'links to the target file' do
- File.exists?(target_file).should be_true
- symlink?(target_file).should be_false
+ expect(File.exists?(target_file)).to be_truthy
+ expect(symlink?(target_file)).to be_falsey
# Writing to one hardlinked file should cause both
# to have the new value.
- IO.read(to).should == IO.read(target_file)
+ expect(IO.read(to)).to eq(IO.read(target_file))
File.open(to, "w") { |file| file.write('wowzers') }
- IO.read(target_file).should == 'wowzers'
+ expect(IO.read(target_file)).to eq('wowzers')
end
it 'does not mark the resource updated' do
- resource.should_not be_updated
+ expect(resource).not_to be_updated
end
it 'does not log that it created' do
- @info.include?("link[#{target_file}] created").should be_false
+ expect(@info.include?("link[#{target_file}] created")).to be_falsey
end
end
end
@@ -278,14 +278,14 @@ describe Chef::Resource::Link do
context 'pointing at the target' do
before(:each) do
symlink(to, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), to)).to be_truthy
end
include_context 'create symbolic link is noop'
include_context 'delete succeeds'
it 'the :delete action does not delete the target file' do
resource.run_action(:delete)
- File.exists?(to).should be_true
+ expect(File.exists?(to)).to be_truthy
end
end
context 'pointing somewhere else' do
@@ -293,8 +293,8 @@ describe Chef::Resource::Link do
@other_target = File.join(test_file_dir, make_tmpname('other_spec'))
File.open(@other_target, 'w') { |file| file.write('eek') }
symlink(@other_target, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), @other_target).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), @other_target)).to be_truthy
end
after(:each) do
File.delete(@other_target)
@@ -303,15 +303,15 @@ describe Chef::Resource::Link do
include_context 'delete succeeds'
it 'the :delete action does not delete the target file' do
resource.run_action(:delete)
- File.exists?(to).should be_true
+ expect(File.exists?(to)).to be_truthy
end
end
context 'pointing nowhere' do
before(:each) do
nonexistent = File.join(test_file_dir, make_tmpname('nonexistent_spec'))
symlink(nonexistent, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), nonexistent).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), nonexistent)).to be_truthy
end
include_context 'create symbolic link succeeds'
include_context 'delete succeeds'
@@ -320,8 +320,8 @@ describe Chef::Resource::Link do
context 'and the link already exists and is a hard link to the file' do
before(:each) do
link(to, target_file)
- File.exists?(target_file).should be_true
- symlink?(target_file).should be_false
+ expect(File.exists?(target_file)).to be_truthy
+ expect(symlink?(target_file)).to be_falsey
end
include_context 'create symbolic link succeeds'
it_behaves_like 'delete errors out'
@@ -339,11 +339,11 @@ describe Chef::Resource::Link do
end
it 'create errors out' do
if windows?
- lambda { resource.run_action(:create) }.should raise_error(Errno::EACCES)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EACCES)
elsif os_x? or solaris? or freebsd? or aix?
- lambda { resource.run_action(:create) }.should raise_error(Errno::EPERM)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EPERM)
else
- lambda { resource.run_action(:create) }.should raise_error(Errno::EISDIR)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR)
end
end
it_behaves_like 'delete errors out'
@@ -392,8 +392,8 @@ describe Chef::Resource::Link do
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
File.open(@other_target, "w") { |file| file.write("eek") }
symlink(@other_target, to)
- symlink?(to).should be_true
- paths_eql?(readlink(to), @other_target).should be_true
+ expect(symlink?(to)).to be_truthy
+ expect(paths_eql?(readlink(to), @other_target)).to be_truthy
end
after(:each) do
File.delete(@other_target)
@@ -407,8 +407,8 @@ describe Chef::Resource::Link do
before(:each) do
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
symlink(@other_target, to)
- symlink?(to).should be_true
- paths_eql?(readlink(to), @other_target).should be_true
+ expect(symlink?(to)).to be_truthy
+ expect(paths_eql?(readlink(to), @other_target)).to be_truthy
end
context 'and the link does not yet exist' do
include_context 'create symbolic link succeeds'
@@ -440,8 +440,8 @@ describe Chef::Resource::Link do
context 'when the link already exists and points at the target' do
before(:each) do
symlink(to, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), to)).to be_truthy
end
include_context 'create symbolic link is noop'
include_context 'delete succeeds'
@@ -449,8 +449,8 @@ describe Chef::Resource::Link do
context 'when the link already exists and points at the target with an absolute path' do
before(:each) do
symlink(absolute_to, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), absolute_to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), absolute_to)).to be_truthy
end
include_context 'create symbolic link succeeds'
include_context 'delete succeeds'
@@ -477,8 +477,8 @@ describe Chef::Resource::Link do
context "and the link already exists and is a symbolic link pointing at the same file" do
before(:each) do
symlink(to, target_file)
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), to).should be_true
+ expect(symlink?(target_file)).to be_truthy
+ expect(paths_eql?(readlink(target_file), to)).to be_truthy
end
include_context 'create hard link succeeds'
it_behaves_like 'delete errors out'
@@ -486,14 +486,14 @@ describe Chef::Resource::Link do
context 'and the link already exists and is a hard link to the file' do
before(:each) do
link(to, target_file)
- File.exists?(target_file).should be_true
- symlink?(target_file).should be_false
+ expect(File.exists?(target_file)).to be_truthy
+ expect(symlink?(target_file)).to be_falsey
end
include_context 'create hard link is noop'
include_context 'delete succeeds'
it 'the :delete action does not delete the target file' do
resource.run_action(:delete)
- File.exists?(to).should be_true
+ expect(File.exists?(to)).to be_truthy
end
end
context "and the link already exists and is a file" do
@@ -509,11 +509,11 @@ describe Chef::Resource::Link do
end
it 'errors out' do
if windows?
- lambda { resource.run_action(:create) }.should raise_error(Errno::EACCES)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EACCES)
elsif os_x? or solaris? or freebsd? or aix?
- lambda { resource.run_action(:create) }.should raise_error(Errno::EPERM)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EPERM)
else
- lambda { resource.run_action(:create) }.should raise_error(Errno::EISDIR)
+ expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR)
end
end
it_behaves_like 'delete errors out'
@@ -527,9 +527,9 @@ describe Chef::Resource::Link do
it 'ignores them' do
resource.run_action(:create)
if windows?
- Chef::ReservedNames::Win32::Security.get_named_security_info(target_file).owner.should_not == SID.Guest
+ expect(Chef::ReservedNames::Win32::Security.get_named_security_info(target_file).owner).not_to eq(SID.Guest)
else
- File.lstat(target_file).uid.should_not == Etc.getpwnam('nobody').uid
+ expect(File.lstat(target_file).uid).not_to eq(Etc.getpwnam('nobody').uid)
end
end
end
@@ -540,7 +540,7 @@ describe Chef::Resource::Link do
end
context 'and the link does not yet exist' do
it 'create errors out' do
- lambda { resource.run_action(:create) }.should raise_error(windows? ? Chef::Exceptions::Win32APIError : Errno::EPERM)
+ expect { resource.run_action(:create) }.to raise_error(windows? ? Chef::Exceptions::Win32APIError : Errno::EPERM)
end
include_context 'delete is noop'
end
@@ -551,8 +551,8 @@ describe Chef::Resource::Link do
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
File.open(@other_target, "w") { |file| file.write("eek") }
symlink(@other_target, to)
- symlink?(to).should be_true
- paths_eql?(readlink(to), @other_target).should be_true
+ expect(symlink?(to)).to be_truthy
+ expect(paths_eql?(readlink(to), @other_target)).to be_truthy
end
after(:each) do
File.delete(@other_target)
@@ -560,12 +560,11 @@ describe Chef::Resource::Link do
context 'and the link does not yet exist' do
it 'links to the target file' do
resource.run_action(:create)
- File.exists?(target_file).should be_true
+ expect(File.exists?(target_file)).to be_truthy
# OS X gets angry about this sort of link. Bug in OS X, IMO.
- pending('OS X/FreeBSD/AIX symlink? and readlink working on hard links to symlinks', :if => (os_x? or freebsd? or aix?)) do
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), @other_target).should be_true
- end
+ pending('OS X/FreeBSD/AIX symlink? and readlink working on hard links to symlinks')
+ expect(symlink?(target_file)).to be_truthy
+ paths_eql?(readlink(target_file), @other_target).should be_truthy
end
include_context 'delete is noop'
end
@@ -574,22 +573,21 @@ describe Chef::Resource::Link do
before(:each) do
@other_target = File.join(test_file_dir, make_tmpname("other_spec"))
symlink(@other_target, to)
- symlink?(to).should be_true
- paths_eql?(readlink(to), @other_target).should be_true
+ expect(symlink?(to)).to be_truthy
+ expect(paths_eql?(readlink(to), @other_target)).to be_truthy
end
context 'and the link does not yet exist' do
it 'links to the target file' do
- pending('OS X/FreeBSD/AIX fails to create hardlinks to broken symlinks', :if => (os_x? or freebsd? or aix?)) do
- resource.run_action(:create)
- # Windows and Unix have different definitions of exists? here, and that's OK.
- if windows?
- File.exists?(target_file).should be_true
- else
- File.exists?(target_file).should be_false
- end
- symlink?(target_file).should be_true
- paths_eql?(readlink(target_file), @other_target).should be_true
+ pending('OS X/FreeBSD/AIX fails to create hardlinks to broken symlinks')
+ resource.run_action(:create)
+ # Windows and Unix have different definitions of exists? here, and that's OK.
+ if windows?
+ File.exists?(target_file).should be_truthy
+ else
+ File.exists?(target_file).should be_falsey
end
+ symlink?(target_file).should be_truthy
+ paths_eql?(readlink(target_file), @other_target).should be_truthy
end
include_context 'delete is noop'
end
@@ -600,7 +598,7 @@ describe Chef::Resource::Link do
context "when the link destination does not exist" do
context 'and the link does not yet exist' do
it 'create errors out' do
- lambda { resource.run_action(:create) }.should raise_error(Errno::ENOENT)
+ expect { resource.run_action(:create) }.to raise_error(Errno::ENOENT)
end
include_context 'delete is noop'
end
@@ -610,7 +608,7 @@ describe Chef::Resource::Link do
describe "when not supported on platform", :win2k3_only do
it "raises error" do
- lambda {resource}.should raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
+ expect {resource}.to raise_error(Chef::Exceptions::Win32APIFunctionNotImplemented)
end
end
end
diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb
index 962c02670c..a016d12293 100644
--- a/spec/functional/resource/mount_spec.rb
+++ b/spec/functional/resource/mount_spec.rb
@@ -82,7 +82,7 @@ describe Chef::Resource::Mount, :requires_root, :external => include_flag do
end
def mount_should_not_exists(mount_point)
- shell_out("mount").stdout.should_not include(mount_point)
+ expect(shell_out("mount").stdout).not_to include(mount_point)
end
def unix_mount_config_file
@@ -106,7 +106,7 @@ describe Chef::Resource::Mount, :requires_root, :external => include_flag do
end
def mount_should_be_disabled(mount_point)
- shell_out("cat #{unix_mount_config_file}").stdout.should_not include("#{mount_point}:")
+ expect(shell_out("cat #{unix_mount_config_file}").stdout).not_to include("#{mount_point}:")
end
let(:new_resource) do
@@ -155,10 +155,10 @@ describe Chef::Resource::Mount, :requires_root, :external => include_flag do
describe "when the target state is a mounted filesystem" do
it "should mount the filesystem if it isn't mounted" do
- current_resource.enabled.should be_false
- current_resource.mounted.should be_false
+ expect(current_resource.enabled).to be_falsey
+ expect(current_resource.mounted).to be_falsey
new_resource.run_action(:mount)
- new_resource.should be_updated
+ expect(new_resource).to be_updated
mount_should_exist(new_resource.mount_point, new_resource.device)
end
end
diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb
index b1e4891293..da47b9e140 100644
--- a/spec/functional/resource/ohai_spec.rb
+++ b/spec/functional/resource/ohai_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Resource::Ohai do
sleep 1
ohai_resource.run_action(:reload)
- node[:uptime].should_not == initial_uptime
+ expect(node[:uptime]).not_to eq(initial_uptime)
end
end
diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb
index 548db40e79..5c17ca0107 100644
--- a/spec/functional/resource/package_spec.rb
+++ b/spec/functional/resource/package_spec.rb
@@ -159,25 +159,25 @@ describe Chef::Resource::Package, metadata do
it "installs the package with action :install" do
package_resource.run_action(:install)
shell_out!("dpkg -l chef-integration-test")
- package_resource.should be_updated_by_last_action
+ expect(package_resource).to be_updated_by_last_action
end
it "installs the package for action :upgrade" do
package_resource.run_action(:upgrade)
shell_out!("dpkg -l chef-integration-test")
- package_resource.should be_updated_by_last_action
+ expect(package_resource).to be_updated_by_last_action
end
it "does nothing for action :remove" do
package_resource.run_action(:remove)
shell_out!("dpkg -l chef-integration-test", :returns => [1])
- package_resource.should_not be_updated_by_last_action
+ expect(package_resource).not_to be_updated_by_last_action
end
it "does nothing for action :purge" do
package_resource.run_action(:purge)
shell_out!("dpkg -l chef-integration-test", :returns => [1])
- package_resource.should_not be_updated_by_last_action
+ expect(package_resource).not_to be_updated_by_last_action
end
context "and a not-available package version is specified" do
@@ -221,8 +221,8 @@ describe Chef::Resource::Package, metadata do
it "preseeds the package, then installs it" do
package_resource.run_action(:install)
cmd = shell_out!("debconf-show chef-integration-test")
- cmd.stdout.should include('chef-integration-test/sample-var: "hello world"')
- package_resource.should be_updated_by_last_action
+ expect(cmd.stdout).to include('chef-integration-test/sample-var: "hello world"')
+ expect(package_resource).to be_updated_by_last_action
end
context "and the preseed file exists and is up-to-date" do
@@ -239,8 +239,8 @@ describe Chef::Resource::Package, metadata do
it "does not update the package configuration" do
package_resource.run_action(:install)
cmd = shell_out!("debconf-show chef-integration-test")
- cmd.stdout.should include('chef-integration-test/sample-var: INVALID')
- package_resource.should be_updated_by_last_action
+ expect(cmd.stdout).to include('chef-integration-test/sample-var: INVALID')
+ expect(package_resource).to be_updated_by_last_action
end
end
@@ -267,8 +267,8 @@ describe Chef::Resource::Package, metadata do
it "preseeds the package, then installs it" do
package_resource.run_action(:install)
cmd = shell_out!("debconf-show chef-integration-test")
- cmd.stdout.should include('chef-integration-test/sample-var: "FROM TEMPLATE"')
- package_resource.should be_updated_by_last_action
+ expect(cmd.stdout).to include('chef-integration-test/sample-var: "FROM TEMPLATE"')
+ expect(package_resource).to be_updated_by_last_action
end
context "with variables" do
@@ -283,8 +283,8 @@ describe Chef::Resource::Package, metadata do
it "preseeds the package, then installs it" do
package_resource.run_action(:install)
cmd = shell_out!("debconf-show chef-integration-test")
- cmd.stdout.should include('chef-integration-test/sample-var: "SUPPORTS VARIABLES"')
- package_resource.should be_updated_by_last_action
+ expect(cmd.stdout).to include('chef-integration-test/sample-var: "SUPPORTS VARIABLES"')
+ expect(package_resource).to be_updated_by_last_action
end
end
@@ -302,13 +302,13 @@ describe Chef::Resource::Package, metadata do
it "does nothing for action :install" do
package_resource.run_action(:install)
shell_out!("dpkg -l chef-integration-test", :returns => [0])
- package_resource.should_not be_updated_by_last_action
+ expect(package_resource).not_to be_updated_by_last_action
end
it "does nothing for action :upgrade" do
package_resource.run_action(:upgrade)
shell_out!("dpkg -l chef-integration-test", :returns => [0])
- package_resource.should_not be_updated_by_last_action
+ expect(package_resource).not_to be_updated_by_last_action
end
# Verify that the package is removed by running `dpkg -l PACKAGE`
@@ -328,7 +328,7 @@ describe Chef::Resource::Package, metadata do
pkg_check = shell_out!("dpkg -l chef-integration-test", :returns => [0,1])
if pkg_check.exitstatus == 0
- pkg_check.stdout.should =~ /un[\s]+chef-integration-test/
+ expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/)
end
end
@@ -336,13 +336,13 @@ describe Chef::Resource::Package, metadata do
it "removes the package for action :remove" do
package_resource.run_action(:remove)
pkg_should_be_removed
- package_resource.should be_updated_by_last_action
+ expect(package_resource).to be_updated_by_last_action
end
it "removes the package for action :purge" do
package_resource.run_action(:purge)
pkg_should_be_removed
- package_resource.should be_updated_by_last_action
+ expect(package_resource).to be_updated_by_last_action
end
end
@@ -356,14 +356,14 @@ describe Chef::Resource::Package, metadata do
it "does nothing for action :install" do
package_resource.run_action(:install)
shell_out!("dpkg -l chef-integration-test", :returns => [0])
- package_resource.should_not be_updated_by_last_action
+ expect(package_resource).not_to be_updated_by_last_action
end
it "upgrades the package for action :upgrade" do
package_resource.run_action(:upgrade)
dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0])
- dpkg_l.stdout.should =~ /chef\-integration\-test[\s]+1\.1\-1/
- package_resource.should be_updated_by_last_action
+ expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
+ expect(package_resource).to be_updated_by_last_action
end
context "and the resource specifies the new version" do
@@ -376,8 +376,8 @@ describe Chef::Resource::Package, metadata do
it "upgrades the package for action :install" do
package_resource.run_action(:install)
dpkg_l = shell_out!("dpkg -l chef-integration-test", :returns => [0])
- dpkg_l.stdout.should =~ /chef\-integration\-test[\s]+1\.1\-1/
- package_resource.should be_updated_by_last_action
+ expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
+ expect(package_resource).to be_updated_by_last_action
end
end
diff --git a/spec/functional/resource/powershell_spec.rb b/spec/functional/resource/powershell_spec.rb
index e1e9f787a3..033f34e256 100644
--- a/spec/functional/resource/powershell_spec.rb
+++ b/spec/functional/resource/powershell_spec.rb
@@ -153,7 +153,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
detected_64_bit = source_contains_case_insensitive_content?( get_script_output, 'AMD64' )
- is_64_bit.should == detected_64_bit
+ expect(is_64_bit).to eq(detected_64_bit)
end
it "returns 1 if an invalid flag is passed to the interpreter" do
@@ -186,12 +186,12 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.returns(0)
resource.run_action(:run)
- source_contains_case_insensitive_content?( get_script_output, 'x86' ).should == true
+ expect(source_contains_case_insensitive_content?( get_script_output, 'x86' )).to eq(true)
end
it "raises an exception if :x86_64 process architecture is specified" do
begin
- resource.architecture(:x86_64).should raise_error Chef::Exceptions::Win32ArchitectureIncorrect
+ expect(resource.architecture(:x86_64)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
rescue Chef::Exceptions::Win32ArchitectureIncorrect
end
end
@@ -204,7 +204,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.returns(0)
resource.run_action(:run)
- source_contains_case_insensitive_content?( get_script_output, 'AMD64' ).should == true
+ expect(source_contains_case_insensitive_content?( get_script_output, 'AMD64' )).to eq(true)
end
it "executes a script with a 32-bit process if :i386 arch is specified" do
@@ -213,7 +213,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.returns(0)
resource.run_action(:run)
- source_contains_case_insensitive_content?( get_script_output, 'x86' ).should == true
+ expect(source_contains_case_insensitive_content?( get_script_output, 'x86' )).to eq(true)
end
end
@@ -230,22 +230,22 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "evaluates a succeeding not_if block using cmd.exe as false by default" do
resource.not_if "exit /b 0"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failing not_if block using cmd.exe as true by default" do
resource.not_if "exit /b 2"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates an succeeding only_if block using cmd.exe as true by default" do
resource.only_if "exit /b 0"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failing only_if block using cmd.exe as false by default" do
resource.only_if "exit /b 2"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
end
@@ -257,7 +257,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "evaluates a powershell $true for a only_if block as true" do
resource.only_if "$true"
resource.guard_interpreter :powershell_script
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
end
@@ -269,184 +269,184 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "evaluates a powershell $false for a not_if block as true" do
resource.not_if "$false"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a powershell $true for a not_if block as false" do
resource.not_if "$true"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $false for an only_if block as false" do
resource.only_if "$false"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a powershell $true for a only_if block as true" do
resource.only_if "$true"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using powershell.exe" do
resource.not_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using powershell.exe" do
resource.only_if "exit([int32](![System.Environment]::CommandLine.Contains('powershell.exe')))"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a non-zero powershell exit status for not_if as true" do
resource.not_if "exit 37"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a zero powershell exit status for not_if as false" do
resource.not_if "exit 0"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for not_if as false" do
resource.not_if windows_process_exit_code_not_found_content
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a successful executable exit status for not_if as true" do
resource.not_if windows_process_exit_code_success_content
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed executable exit status for only_if as false" do
resource.only_if windows_process_exit_code_not_found_content
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful executable exit status for only_if as true" do
resource.only_if windows_process_exit_code_success_content
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a failed cmdlet exit status for not_if as true" do
resource.not_if "throw 'up'"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a successful cmdlet exit status for not_if as true" do
resource.not_if "cd ."
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a failed cmdlet exit status for only_if as false" do
resource.only_if "throw 'up'"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a successful cmdlet exit status for only_if as true" do
resource.only_if "cd ."
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a not_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates an only_if block using the cwd guard parameter" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')", :cwd => custom_cwd
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for only_if" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.cwd custom_cwd
resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "inherits cwd from the parent resource for not_if" do
custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
resource.cwd custom_cwd
resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean false as zero status code", :windows64_only do
resource.architecture :x86_64
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean true as nonzero status code", :windows64_only do
resource.architecture :x86_64
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code" do
resource.architecture :i386
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'X86')"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code" do
resource.architecture :i386
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a simple boolean false as nonzero status code when convert_boolean_return is true for only_if" do
resource.convert_boolean_return true
resource.only_if "$false"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a simple boolean false as nonzero status code when convert_boolean_return is true for not_if" do
resource.convert_boolean_return true
resource.not_if "$false"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for only_if" do
resource.convert_boolean_return true
resource.only_if "$true"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for not_if" do
resource.convert_boolean_return true
resource.not_if "$true"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for only_if" do
resource.convert_boolean_return true
resource.architecture :i386
resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for not_if" do
resource.convert_boolean_return true
resource.architecture :i386
resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
- resource.should_skip?(:run).should be_false
+ expect(resource.should_skip?(:run)).to be_falsey
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for only_if" do
resource.convert_boolean_return true
resource.architecture :i386
resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for not_if" do
resource.convert_boolean_return true
resource.architecture :i386
resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
- resource.should_skip?(:run).should be_true
+ expect(resource.should_skip?(:run)).to be_truthy
end
end
end
diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb
index 735ca994c8..99de136827 100644
--- a/spec/functional/resource/reboot_spec.rb
+++ b/spec/functional/resource/reboot_spec.rb
@@ -50,7 +50,7 @@ describe Chef::Resource::Reboot do
expect(reboot_info[:reason]).to eq(expected[:reason])
expect(reboot_info[:requested_by]).to eq(expected[:requested_by])
- expect(resource.run_context.reboot_requested?).to be_true
+ expect(resource.run_context.reboot_requested?).to be_truthy
end
end
@@ -97,7 +97,7 @@ describe Chef::Resource::Reboot do
it 'should have cleared the reboot request' do
# arguably we shouldn't be querying RunContext's internal data directly.
expect(resource.run_context.reboot_info).to eq({})
- expect(resource.run_context.reboot_requested?).to be_false
+ expect(resource.run_context.reboot_requested?).to be_falsey
end
end
end
diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb
index 2d24eee6a3..bdd9b00511 100644
--- a/spec/functional/resource/registry_spec.rb
+++ b/spec/functional/resource/registry_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Resource::RegistryKey, :unix_only do
it "throws an exception because you don't have a windows registry (derp)" do
@resource.key("HKCU\\Software\\Opscode")
@resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
- lambda{@resource.run_action(:create)}.should raise_error(Chef::Exceptions::Win32NotWindows)
+ expect{@resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32NotWindows)
end
end
end
@@ -112,9 +112,9 @@ describe Chef::Resource::RegistryKey, :windows_only do
@node.name("windowsbox")
@rest_client = double("Chef::REST (mock)")
- @rest_client.stub(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}");
- @rest_client.stub(:raw_http_request).and_return({"result"=>"ok"});
- @rest_client.stub(:post_rest).and_return({"uri"=>"https://example.com/reports/nodes/windowsbox/runs/#{@run_id}"});
+ allow(@rest_client).to receive(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}");
+ allow(@rest_client).to receive(:raw_http_request).and_return({"result"=>"ok"});
+ allow(@rest_client).to receive(:post_rest).and_return({"uri"=>"https://example.com/reports/nodes/windowsbox/runs/#{@run_id}"});
@resource_reporter = Chef::ResourceReporter.new(@rest_client)
@events.register(@resource_reporter)
@@ -125,7 +125,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.cookbook_name = "monkey"
@cookbook_version = double("Cookbook::Version", :version => "1.2.3")
- @new_resource.stub(:cookbook_version).and_return(@cookbook_version)
+ allow(@new_resource).to receive(:cookbook_version).and_return(@cookbook_version)
end
after (:all) do
@@ -141,8 +141,8 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
@new_resource.run_action(:create)
- @registry.key_exists?(reg_child).should == true
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.key_exists?(reg_child)).to eq(true)
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@@ -150,8 +150,8 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
@new_resource.run_action(:create)
- @registry.key_exists?(reg_child).should == true
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.key_exists?(reg_child)).to eq(true)
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
end
it "creates a value if it does not exist" do
@@ -159,7 +159,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
@new_resource.run_action(:create)
- @registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"}).should == true
+ expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
end
it "modifies the data if the key and value exist and type matches" do
@@ -167,7 +167,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"}])
@new_resource.run_action(:create)
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"}).should == true
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Not just Orange - OpscodeOrange!"})).to eq(true)
end
it "modifys the type if the key and value exist and the type does not match" do
@@ -175,7 +175,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]}])
@new_resource.run_action(:create)
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]}).should == true
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:multi_string, :data=>["Not just Orange - OpscodeOrange!"]})).to eq(true)
end
it "creates subkey if parent exists" do
@@ -184,15 +184,15 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:create)
- @registry.key_exists?(reg_child + '\OpscodeTest').should == true
- @registry.value_exists?(reg_child + '\OpscodeTest', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}).should == true
+ expect(@registry.key_exists?(reg_child + '\OpscodeTest')).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\OpscodeTest', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Missing1\Missing2')
@new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
@new_resource.recursive(false)
- lambda{@new_resource.run_action(:create)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect{@new_resource.run_action(:create)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@@ -201,8 +201,8 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(true)
@new_resource.run_action(:create)
- @registry.key_exists?(reg_child + '\Missing1\Missing2').should == true
- @registry.value_exists?(reg_child + '\Missing1\Missing2', {:name=>"OC", :type=>:string, :data=>"MissingData"}).should == true
+ expect(@registry.key_exists?(reg_child + '\Missing1\Missing2')).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Missing1\Missing2', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
end
it "creates key with multiple value as specified" do
@@ -212,7 +212,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.run_action(:create)
@new_resource.values.each do |value|
- @registry.value_exists?(reg_child, value).should == true
+ expect(@registry.value_exists?(reg_child, value)).to eq(true)
end
end
@@ -231,9 +231,9 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.architecture(:i386)
@new_resource.run_action(:create)
@registry.architecture = :i386
- @registry.data_exists?(reg_child + '\Atraxi', {:name=>"OC", :type=>:string, :data=>"Data"}).should == true
+ expect(@registry.data_exists?(reg_child + '\Atraxi', {:name=>"OC", :type=>:string, :data=>"Data"})).to eq(true)
@registry.architecture = :x86_64
- @registry.key_exists?(reg_child + '\Atraxi').should == false
+ expect(@registry.key_exists?(reg_child + '\Atraxi')).to eq(false)
end
end
@@ -244,16 +244,16 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.run_action(:create)
@report = @resource_reporter.prepare_run_data
- @report["action"].should == "end"
- @report["resources"][0]["type"].should == "registry_key"
- @report["resources"][0]["name"].should == resource_name
- @report["resources"][0]["id"].should == reg_child + '\Ood'
- @report["resources"][0]["after"][:values].should == [{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},
- {:name=>"ReportingVal2", :type=>:string, :data=>"report2"}]
- @report["resources"][0]["before"][:values].should == []
- @report["resources"][0]["result"].should == "create"
- @report["status"].should == "success"
- @report["total_res_count"].should == "1"
+ expect(@report["action"]).to eq("end")
+ expect(@report["resources"][0]["type"]).to eq("registry_key")
+ expect(@report["resources"][0]["name"]).to eq(resource_name)
+ expect(@report["resources"][0]["id"]).to eq(reg_child + '\Ood')
+ expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal1", :type=>:string, :data=>"report1"},
+ {:name=>"ReportingVal2", :type=>:string, :data=>"report2"}])
+ expect(@report["resources"][0]["before"][:values]).to eq([])
+ expect(@report["resources"][0]["result"]).to eq("create")
+ expect(@report["status"]).to eq("success")
+ expect(@report["total_res_count"]).to eq("1")
end
context "while running in whyrun mode" do
@@ -266,15 +266,15 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
@new_resource.recursive(false)
@new_resource.run_action(:create) # should not raise_error
- @registry.key_exists?(reg_child + '\Slitheen').should == false
- @registry.key_exists?(reg_child + '\Slitheen\Raxicoricofallapatorius').should == false
+ expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
+ expect(@registry.key_exists?(reg_child + '\Slitheen\Raxicoricofallapatorius')).to eq(false)
end
it "does not create key if the action is create" do
@new_resource.key(reg_child + '\Slitheen')
@new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
@new_resource.recursive(false)
@new_resource.run_action(:create)
- @registry.key_exists?(reg_child + '\Slitheen').should == false
+ expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
end
end
end
@@ -289,9 +289,9 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
@new_resource.run_action(:create_if_missing)
- @registry.key_exists?(reg_parent).should == true
- @registry.key_exists?(reg_child).should == true
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.key_exists?(reg_parent)).to eq(true)
+ expect(@registry.key_exists?(reg_child)).to eq(true)
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
end
it "does not create the key if it already exists with same value, type and data" do
@@ -299,8 +299,8 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Color", :type=>:string, :data=>"Orange"}])
@new_resource.run_action(:create_if_missing)
- @registry.key_exists?(reg_child).should == true
- @registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.key_exists?(reg_child)).to eq(true)
+ expect(@registry.data_exists?(reg_child, {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
end
it "creates a value if it does not exist" do
@@ -308,7 +308,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"Mango", :type=>:string, :data=>"Yellow"}])
@new_resource.run_action(:create_if_missing)
- @registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"}).should == true
+ expect(@registry.data_exists?(reg_child, {:name=>"Mango", :type=>:string, :data=>"Yellow"})).to eq(true)
end
it "creates subkey if parent exists" do
@@ -317,15 +317,15 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
- @registry.key_exists?(reg_child + '\Pyrovile').should == true
- @registry.value_exists?(reg_child + '\Pyrovile', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]}).should == true
+ expect(@registry.key_exists?(reg_child + '\Pyrovile')).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Pyrovile', {:name=>"Chef", :type=>:multi_string, :data=>["OpscodeOrange", "Rules"]})).to eq(true)
end
it "gives error if action create and parent does not exist and recursive is set to false" do
@new_resource.key(reg_child + '\Sontaran\Sontar')
@new_resource.values([{:name=>"OC", :type=>:string, :data=>"MissingData"}])
@new_resource.recursive(false)
- lambda{@new_resource.run_action(:create_if_missing)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect{@new_resource.run_action(:create_if_missing)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
@@ -334,8 +334,8 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(true)
@new_resource.run_action(:create_if_missing)
- @registry.key_exists?(reg_child + '\Sontaran\Sontar').should == true
- @registry.value_exists?(reg_child + '\Sontaran\Sontar', {:name=>"OC", :type=>:string, :data=>"MissingData"}).should == true
+ expect(@registry.key_exists?(reg_child + '\Sontaran\Sontar')).to eq(true)
+ expect(@registry.value_exists?(reg_child + '\Sontaran\Sontar', {:name=>"OC", :type=>:string, :data=>"MissingData"})).to eq(true)
end
it "creates key with multiple value as specified" do
@@ -345,7 +345,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.run_action(:create_if_missing)
@new_resource.values.each do |value|
- @registry.value_exists?(reg_child + '\Adipose', value).should == true
+ expect(@registry.value_exists?(reg_child + '\Adipose', value)).to eq(true)
end
end
@@ -356,15 +356,15 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.run_action(:create_if_missing)
@report = @resource_reporter.prepare_run_data
- @report["action"].should == "end"
- @report["resources"][0]["type"].should == "registry_key"
- @report["resources"][0]["name"].should == resource_name
- @report["resources"][0]["id"].should == reg_child + '\Judoon'
- @report["resources"][0]["after"][:values].should == [{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}]
- @report["resources"][0]["before"][:values].should == []
- @report["resources"][0]["result"].should == "create_if_missing"
- @report["status"].should == "success"
- @report["total_res_count"].should == "1"
+ expect(@report["action"]).to eq("end")
+ expect(@report["resources"][0]["type"]).to eq("registry_key")
+ expect(@report["resources"][0]["name"]).to eq(resource_name)
+ expect(@report["resources"][0]["id"]).to eq(reg_child + '\Judoon')
+ expect(@report["resources"][0]["after"][:values]).to eq([{:name=>"ReportingVal3", :type=>:string, :data=>"report3"}])
+ expect(@report["resources"][0]["before"][:values]).to eq([])
+ expect(@report["resources"][0]["result"]).to eq("create_if_missing")
+ expect(@report["status"]).to eq("success")
+ expect(@report["total_res_count"]).to eq("1")
end
context "while running in whyrun mode" do
@@ -377,15 +377,15 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing) # should not raise_error
- @registry.key_exists?(reg_child + '\Zygons').should == false
- @registry.key_exists?(reg_child + '\Zygons\Zygor').should == false
+ expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
+ expect(@registry.key_exists?(reg_child + '\Zygons\Zygor')).to eq(false)
end
it "does nothing if the action is create_if_missing" do
@new_resource.key(reg_child + '\Zygons')
@new_resource.values([{:name=>"BriskWalk",:type=>:string,:data=>"is good for health"}])
@new_resource.recursive(false)
@new_resource.run_action(:create_if_missing)
- @registry.key_exists?(reg_child + '\Zygons').should == false
+ expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
end
end
end
@@ -397,24 +397,24 @@ describe Chef::Resource::RegistryKey, :windows_only do
end
it "takes no action if the specified key path does not exist in the system" do
- @registry.key_exists?(reg_parent + '\Osirian').should == false
+ expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
@new_resource.key(reg_parent+ '\Osirian')
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- @registry.key_exists?(reg_parent + '\Osirian').should == false
+ expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
end
it "takes no action if the key exists but the value does not" do
- @registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
@new_resource.key(reg_parent + '\Opscode')
@new_resource.values([{:name=>"LooksLike", :type=>:multi_string, :data=>["SeattleGrey", "OCOrange"]}])
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- @registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
+ expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
end
it "deletes only specified values under a key path" do
@@ -423,9 +423,9 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- @registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"}).should == true
- @registry.value_exists?(reg_parent + '\Opscode', {:name=>"AKA", :type=>:string, :data=>"OC"}).should == false
- @registry.value_exists?(reg_parent + '\Opscode', {:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]}).should == false
+ expect(@registry.data_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(true)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"AKA", :type=>:string, :data=>"OC"})).to eq(false)
+ expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Opscode", :type=>:multi_string, :data=>["Seattle", "Washington"]})).to eq(false)
end
it "it deletes the values with the same name irrespective of it type and data" do
@@ -434,7 +434,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- @registry.value_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"}).should == false
+ expect(@registry.value_exists?(reg_parent + '\Opscode', {:name=>"Color", :type=>:string, :data=>"Orange"})).to eq(false)
end
it "prepares the reporting data for action :delete" do
@@ -445,19 +445,19 @@ describe Chef::Resource::RegistryKey, :windows_only do
@report = @resource_reporter.prepare_run_data
- @registry.value_exists?(reg_parent + '\ReportKey', [{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}]).should == false
+ expect(@registry.value_exists?(reg_parent + '\ReportKey', [{:name=>"ReportVal4", :type=>:string, :data=>"report4"},{:name=>"ReportVal5", :type=>:string, :data=>"report5"}])).to eq(false)
- @report["action"].should == "end"
- @report["resources"].count.should == 1
- @report["resources"][0]["type"].should == "registry_key"
- @report["resources"][0]["name"].should == resource_name
- @report["resources"][0]["id"].should == reg_parent + '\ReportKey'
- @report["resources"][0]["before"][:values].should == [{:name=>"ReportVal4", :type=>:string, :data=>"report4"},
- {:name=>"ReportVal5", :type=>:string, :data=>"report5"}]
+ expect(@report["action"]).to eq("end")
+ expect(@report["resources"].count).to eq(1)
+ expect(@report["resources"][0]["type"]).to eq("registry_key")
+ expect(@report["resources"][0]["name"]).to eq(resource_name)
+ expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
+ expect(@report["resources"][0]["before"][:values]).to eq([{:name=>"ReportVal4", :type=>:string, :data=>"report4"},
+ {:name=>"ReportVal5", :type=>:string, :data=>"report5"}])
#Not testing for after values to match since after -> new_resource values.
- @report["resources"][0]["result"].should == "delete"
- @report["status"].should == "success"
- @report["total_res_count"].should == "1"
+ expect(@report["resources"][0]["result"]).to eq("delete")
+ expect(@report["status"]).to eq("success")
+ expect(@report["total_res_count"]).to eq("1")
end
context "while running in whyrun mode" do
@@ -470,7 +470,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:delete)
- @registry.key_exists?(reg_parent + '\OpscodeWhyRun').should == true
+ expect(@registry.key_exists?(reg_parent + '\OpscodeWhyRun')).to eq(true)
end
end
end
@@ -482,13 +482,13 @@ describe Chef::Resource::RegistryKey, :windows_only do
end
it "takes no action if the specified key path does not exist in the system" do
- @registry.key_exists?(reg_parent + '\Osirian').should == false
+ expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
@new_resource.key(reg_parent + '\Osirian')
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
- @registry.key_exists?(reg_parent + '\Osirian').should == false
+ expect(@registry.key_exists?(reg_parent + '\Osirian')).to eq(false)
end
it "deletes key if it has no subkeys and recursive == false" do
@@ -496,13 +496,13 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
- @registry.key_exists?(reg_parent + '\OpscodeTest').should == false
+ expect(@registry.key_exists?(reg_parent + '\OpscodeTest')).to eq(false)
end
it "raises an exception if the key has subkeys and recursive == false" do
@new_resource.key(reg_parent)
@new_resource.recursive(false)
- lambda{@new_resource.run_action(:delete_key)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect{@new_resource.run_action(:delete_key)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
end
it "ignores the values under a key" do
@@ -517,7 +517,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(true)
@new_resource.run_action(:delete_key)
- @registry.key_exists?(reg_parent + '\Opscode').should == false
+ expect(@registry.key_exists?(reg_parent + '\Opscode')).to eq(false)
end
it "prepares the reporting data for action :delete_key" do
@@ -526,16 +526,16 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.run_action(:delete_key)
@report = @resource_reporter.prepare_run_data
- @report["action"].should == "end"
- @report["resources"][0]["type"].should == "registry_key"
- @report["resources"][0]["name"].should == resource_name
- @report["resources"][0]["id"].should == reg_parent + '\ReportKey'
+ expect(@report["action"]).to eq("end")
+ expect(@report["resources"][0]["type"]).to eq("registry_key")
+ expect(@report["resources"][0]["name"]).to eq(resource_name)
+ expect(@report["resources"][0]["id"]).to eq(reg_parent + '\ReportKey')
#Not testing for before or after values to match since
#after -> new_resource.values and
#before -> current_resource.values
- @report["resources"][0]["result"].should == "delete_key"
- @report["status"].should == "success"
- @report["total_res_count"].should == "1"
+ expect(@report["resources"][0]["result"]).to eq("delete_key")
+ expect(@report["status"]).to eq("success")
+ expect(@report["total_res_count"]).to eq("1")
end
context "while running in whyrun mode" do
before (:each) do
@@ -554,7 +554,7 @@ describe Chef::Resource::RegistryKey, :windows_only do
@new_resource.recursive(false)
@new_resource.run_action(:delete_key)
- @registry.key_exists?(reg_parent + '\OpscodeWhyRun').should == true
+ expect(@registry.key_exists?(reg_parent + '\OpscodeWhyRun')).to eq(true)
end
end
end
diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb
index f9eb20711e..bcafca7399 100644
--- a/spec/functional/resource/remote_directory_spec.rb
+++ b/spec/functional/resource/remote_directory_spec.rb
@@ -81,12 +81,12 @@ describe Chef::Resource::RemoteDirectory do
it "transfers the directory with all contents" do
expected_files.each do |file_path|
- File.should exist(file_path)
+ expect(File).to exist(file_path)
end
end
it "is marked as updated by last action" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
end
@@ -98,13 +98,13 @@ describe Chef::Resource::RemoteDirectory do
it "does not modify the expected state of the directory" do
expected_files.each do |file_path|
- File.should exist(file_path)
+ expect(File).to exist(file_path)
end
end
it "does not remove unmanaged files" do
- File.should exist(@existing1)
- File.should exist(@existing2)
+ expect(File).to exist(@existing1)
+ expect(File).to exist(@existing2)
end
end
@@ -116,12 +116,12 @@ describe Chef::Resource::RemoteDirectory do
it "does not modify the expected state of the directory" do
expected_files.each do |file_path|
- File.should exist(file_path)
+ expect(File).to exist(file_path)
end
end
it "is not marked as updated by last action" do
- resource_second_pass.should_not be_updated_by_last_action
+ expect(resource_second_pass).not_to be_updated_by_last_action
end
end
@@ -142,8 +142,8 @@ describe Chef::Resource::RemoteDirectory do
modified_subdir_file_checksum = sha256_checksum(modified_subdir_file)
resource.run_action(:create)
- sha256_checksum(modified_file).should == modified_file_checksum
- sha256_checksum(modified_subdir_file).should == modified_subdir_file_checksum
+ expect(sha256_checksum(modified_file)).to eq(modified_file_checksum)
+ expect(sha256_checksum(modified_subdir_file)).to eq(modified_subdir_file_checksum)
end
end
end
@@ -160,7 +160,7 @@ describe Chef::Resource::RemoteDirectory do
it "creates the directory contents as normal" do
expected_files.each do |file_path|
- File.should exist(file_path)
+ expect(File).to exist(file_path)
end
end
@@ -173,18 +173,18 @@ describe Chef::Resource::RemoteDirectory do
end
it "removes unmanaged files" do
- File.should_not exist(@existing1)
- File.should_not exist(@existing2)
+ expect(File).not_to exist(@existing1)
+ expect(File).not_to exist(@existing2)
end
it "does not modify managed files" do
expected_files.each do |file_path|
- File.should exist(file_path)
+ expect(File).to exist(file_path)
end
end
it "is marked as updated by last action" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
end
@@ -204,14 +204,14 @@ describe Chef::Resource::RemoteDirectory do
end
it "removes files in subdirectories before files above" do
- File.should_not exist(@existing1)
- File.should_not exist(@existing2)
- File.should_not exist(@existing3)
- File.should_not exist(@existing4)
+ expect(File).not_to exist(@existing1)
+ expect(File).not_to exist(@existing2)
+ expect(File).not_to exist(@existing3)
+ expect(File).not_to exist(@existing4)
end
it "is marked as updated by last action" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
end
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index ccdf1cb812..29091fd785 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -137,20 +137,20 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
resource.run_action(:create)
end
it "should create the file" do
- File.should exist(path)
+ expect(File).to exist(path)
end
it "should mark the resource as updated" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
it "has the correct content" do
- binread(path).should == expected_content
+ expect(binread(path)).to eq(expected_content)
end
end
@@ -159,20 +159,20 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
resource.run_action(:create)
end
it "should create the file" do
- File.should exist(path)
+ expect(File).to exist(path)
end
it "should mark the resource as updated" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
it "has the correct content" do
- binread(path).should == expected_content
+ expect(binread(path)).to eq(expected_content)
end
end
@@ -180,11 +180,11 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
end
it "should raise ContentLengthMismatch" do
- lambda { resource.run_action(:create) }.should raise_error(Chef::Exceptions::ContentLengthMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
#File.should_not exist(path) # XXX: CHEF-5081
end
end
@@ -193,11 +193,11 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
end
it "should raise ContentLengthMismatch" do
- lambda { resource.run_action(:create) }.should raise_error(Chef::Exceptions::ContentLengthMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ContentLengthMismatch)
#File.should_not exist(path) # XXX: CHEF-5081
end
end
@@ -207,20 +207,20 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
resource.run_action(:create)
end
it "should create the file" do
- File.should exist(path)
+ expect(File).to exist(path)
end
it "should mark the resource as updated" do
- resource.should be_updated_by_last_action
+ expect(resource).to be_updated_by_last_action
end
it "has the correct content" do
- binread(path).should == expected_content
+ expect(binread(path)).to eq(expected_content)
end
end
@@ -228,12 +228,12 @@ describe Chef::Resource::RemoteFile do
let(:source) { 'http://localhost:0000/seattle_capo.png' }
before do
- File.should_not exist(path)
+ expect(File).not_to exist(path)
end
it "should not create the file" do
expect{ resource.run_action(:create) }.to raise_error
- File.should_not exist(path)
+ expect(File).not_to exist(path)
end
end
end
diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb
index fefd995743..d7b35e7450 100644
--- a/spec/functional/resource/template_spec.rb
+++ b/spec/functional/resource/template_spec.rb
@@ -69,7 +69,7 @@ describe Chef::Resource::Template do
resource.source('openldap_variable_stuff.conf.erb')
resource.variables(:secret => "nutella")
resource.run_action(:create)
- IO.read(path).should == "super secret is nutella"
+ expect(IO.read(path)).to eq("super secret is nutella")
end
it "creates the template with the rendered content using a local erb file when the :create action is run" do
@@ -77,7 +77,7 @@ describe Chef::Resource::Template do
resource.cookbook(nil)
resource.local(true)
resource.run_action(:create)
- IO.read(path).should == expected_content
+ expect(IO.read(path)).to eq(expected_content)
end
end
@@ -96,7 +96,7 @@ describe Chef::Resource::Template do
shared_examples "a template with helpers" do
it "generates expected content by calling helper methods" do
resource.run_action(:create)
- binread(path).strip.should == expected_content
+ expect(binread(path).strip).to eq(expected_content)
end
end
@@ -202,7 +202,7 @@ describe Chef::Resource::Template do
it "output should contain platform's line endings" do
resource.run_action(:create)
binread(path).each_line do |line|
- line.should end_with(Chef::Platform.windows? ? "\r\n" : "\n")
+ expect(line).to end_with(Chef::Platform.windows? ? "\r\n" : "\n")
end
end
end
diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb
index ba508e3258..45b6754453 100644
--- a/spec/functional/resource/user/dscl_spec.rb
+++ b/spec/functional/resource/user/dscl_spec.rb
@@ -37,15 +37,15 @@ describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metada
end
def user_should_exist
- shell_out("/usr/bin/dscl . -ls /Users").stdout.should include username
+ expect(shell_out("/usr/bin/dscl . -ls /Users").stdout).to include username
end
def check_password(pass)
# In order to test the password we use dscl passwd command since
# that's the only command that gets the user password from CLI.
- shell_out("dscl . -passwd /Users/greatchef #{pass} new_password").exitstatus.should == 0
+ expect(shell_out("dscl . -passwd /Users/greatchef #{pass} new_password").exitstatus).to eq(0)
# Now reset the password back
- shell_out("dscl . -passwd /Users/greatchef new_password #{pass}").exitstatus.should == 0
+ expect(shell_out("dscl . -passwd /Users/greatchef new_password #{pass}").exitstatus).to eq(0)
end
let(:node) do
@@ -191,7 +191,7 @@ c5adbbac718b7eb99463a7b679571e0f\
user_resource.run_action(:remove)
groups.each do |group|
# Do not raise an error when group is empty
- shell_out("dscl . read /Groups/staff GroupMembership").stdout.should_not include(group)
+ expect(shell_out("dscl . read /Groups/staff GroupMembership").stdout).not_to include(group)
end
end
end
diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb
index 1fbe6fcb4d..6b962c19aa 100644
--- a/spec/functional/resource/user/useradd_spec.rb
+++ b/spec/functional/resource/user/useradd_spec.rb
@@ -70,9 +70,9 @@ describe Chef::Provider::User::Useradd, metadata do
def password_should_be_set
if ohai[:platform] == "aix"
- pw_entry.passwd.should == "!"
+ expect(pw_entry.passwd).to eq("!")
else
- pw_entry.passwd.should == "x"
+ expect(pw_entry.passwd).to eq("x")
end
end
@@ -145,12 +145,12 @@ describe Chef::Provider::User::Useradd, metadata do
pending(reason)
end
user_resource.run_action(:create)
- user_resource.should be_updated_by_last_action
+ expect(user_resource).to be_updated_by_last_action
end
it "ensures the user exists" do
- pw_entry.name.should == username
+ expect(pw_entry.name).to eq(username)
end
# On Debian, the only constraints are that usernames must neither start
@@ -171,7 +171,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:username) { "t'bilisi" }
it "ensures the user exists" do
- pw_entry.name.should == username
+ expect(pw_entry.name).to eq(username)
end
end
@@ -181,7 +181,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:uid) { 1999 }
it "ensures the user has the given uid" do
- pw_entry.uid.should == "1999"
+ expect(pw_entry.uid).to eq("1999")
end
end
@@ -189,14 +189,14 @@ describe Chef::Provider::User::Useradd, metadata do
let(:comment) { "hello this is dog" }
it "ensures the comment is set" do
- pw_entry.gecos.should == "hello this is dog"
+ expect(pw_entry.gecos).to eq("hello this is dog")
end
context "in standard gecos format" do
let(:comment) { "Bobo T. Clown,some building,555-555-5555,@boboclown" }
it "ensures the comment is set" do
- pw_entry.gecos.should == comment
+ expect(pw_entry.gecos).to eq(comment)
end
end
@@ -206,7 +206,7 @@ describe Chef::Provider::User::Useradd, metadata do
it "ensures the comment is set" do
actual = pw_entry.gecos
actual.force_encoding(Encoding::UTF_8) if "".respond_to?(:force_encoding)
- actual.should == comment
+ expect(actual).to eq(comment)
end
end
@@ -214,7 +214,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:comment) { "don't go" }
it "ensures the comment is set" do
- pw_entry.gecos.should == comment
+ expect(pw_entry.gecos).to eq(comment)
end
end
end
@@ -223,17 +223,17 @@ describe Chef::Provider::User::Useradd, metadata do
let(:home) { "/home/#{username}" }
it "ensures the user's home is set to the given path" do
- pw_entry.home.should == "/home/#{username}"
+ expect(pw_entry.home).to eq("/home/#{username}")
end
if %w{rhel fedora}.include?(OHAI_SYSTEM["platform_family"])
# Inconsistent behavior. See: CHEF-2205
it "creates the home dir when not explicitly asked to on RHEL (XXX)" do
- File.should exist("/home/#{username}")
+ expect(File).to exist("/home/#{username}")
end
else
it "does not create the home dir without `manage_home'" do
- File.should_not exist("/home/#{username}")
+ expect(File).not_to exist("/home/#{username}")
end
end
@@ -241,7 +241,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:manage_home) { true }
it "ensures the user's home directory exists" do
- File.should exist("/home/#{username}")
+ expect(File).to exist("/home/#{username}")
end
end
end
@@ -259,7 +259,7 @@ describe Chef::Provider::User::Useradd, metadata do
it "sets the user's shadow password" do
password_should_be_set
- etc_shadow.should include(expected_shadow)
+ expect(etc_shadow).to include(expected_shadow)
end
end
@@ -284,7 +284,7 @@ describe Chef::Provider::User::Useradd, metadata do
end
it "ensures the user has the properties of a system user" do
- pw_entry.uid.to_i.should be < uid_min.to_i
+ expect(pw_entry.uid.to_i).to be < uid_min.to_i
end
end
end # when the user does not exist beforehand
@@ -318,9 +318,9 @@ describe Chef::Provider::User::Useradd, metadata do
pending(reason)
end
existing_user.run_action(:create)
- existing_user.should be_updated_by_last_action
+ expect(existing_user).to be_updated_by_last_action
user_resource.run_action(:create)
- user_resource.updated_by_last_action?.should == expect_updated?
+ expect(user_resource.updated_by_last_action?).to eq(expect_updated?)
end
context "and all properties are in the desired state" do
@@ -350,7 +350,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:expect_updated?) { false }
it "does not update the user" do
- user_resource.should_not be_updated
+ expect(user_resource).not_to be_updated
end
end
@@ -359,7 +359,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:existing_uid) { 1998 }
it "ensures the uid is set to the desired value" do
- pw_entry.uid.should == "1999"
+ expect(pw_entry.uid).to eq("1999")
end
end
@@ -368,7 +368,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:existing_comment) { "woof" }
it "ensures the comment field is set to the desired value" do
- pw_entry.gecos.should == "hello this is dog"
+ expect(pw_entry.gecos).to eq("hello this is dog")
end
end
@@ -376,15 +376,15 @@ describe Chef::Provider::User::Useradd, metadata do
let(:existing_home) { "/home/foo" }
let(:home) { "/home/bar" }
it "ensures the home directory is set to the desired value" do
- pw_entry.home.should == "/home/bar"
+ expect(pw_entry.home).to eq("/home/bar")
end
context "and manage_home is enabled" do
let(:existing_manage_home) { true }
let(:manage_home) { true }
it "moves the home directory to the new location" do
- File.should_not exist("/home/foo")
- File.should exist("/home/bar")
+ expect(File).not_to exist("/home/foo")
+ expect(File).to exist("/home/bar")
end
end
@@ -396,19 +396,19 @@ describe Chef::Provider::User::Useradd, metadata do
# Inconsistent behavior. See: CHEF-2205
it "created the home dir b/c of CHEF-2205 so it still exists" do
# This behavior seems contrary to expectation and non-convergent.
- File.should_not exist("/home/foo")
- File.should exist("/home/bar")
+ expect(File).not_to exist("/home/foo")
+ expect(File).to exist("/home/bar")
end
elsif ohai[:platform] == "aix"
it "creates the home dir in the desired location" do
- File.should_not exist("/home/foo")
- File.should exist("/home/bar")
+ expect(File).not_to exist("/home/foo")
+ expect(File).to exist("/home/bar")
end
else
it "does not create the home dir in the desired location (XXX)" do
# This behavior seems contrary to expectation and non-convergent.
- File.should_not exist("/home/foo")
- File.should_not exist("/home/bar")
+ expect(File).not_to exist("/home/foo")
+ expect(File).not_to exist("/home/bar")
end
end
end
@@ -419,8 +419,8 @@ describe Chef::Provider::User::Useradd, metadata do
it "leaves the old home directory around (XXX)" do
# Would it be better to remove the old home?
- File.should exist("/home/foo")
- File.should_not exist("/home/bar")
+ expect(File).to exist("/home/foo")
+ expect(File).not_to exist("/home/bar")
end
end
end
@@ -439,7 +439,7 @@ describe Chef::Provider::User::Useradd, metadata do
it "ensures the password is set" do
password_should_be_set
- etc_shadow.should include(expected_shadow)
+ expect(etc_shadow).to include(expected_shadow)
end
end
@@ -468,7 +468,7 @@ describe Chef::Provider::User::Useradd, metadata do
it "ensures the password is set to the desired value" do
password_should_be_set
- etc_shadow.should include(expected_shadow)
+ expect(etc_shadow).to include(expected_shadow)
end
end
@@ -514,18 +514,18 @@ describe Chef::Provider::User::Useradd, metadata do
def user_account_should_be_locked
case ohai[:platform]
when "aix"
- aix_user_lock_status.should == "true"
+ expect(aix_user_lock_status).to eq("true")
else
- shadow_password.should include("!")
+ expect(shadow_password).to include("!")
end
end
def user_account_should_be_unlocked
case ohai[:platform]
when "aix"
- aix_user_lock_status.should == "false"
+ expect(aix_user_lock_status).to eq("false")
else
- shadow_password.should_not include("!")
+ expect(shadow_password).not_to include("!")
end
end
@@ -596,7 +596,7 @@ describe Chef::Provider::User::Useradd, metadata do
let(:user_locked_context?) { true }
it "does not update the user" do
- user_resource.should_not be_updated_by_last_action
+ expect(user_resource).not_to be_updated_by_last_action
end
end
end
@@ -628,8 +628,8 @@ describe Chef::Provider::User::Useradd, metadata do
if %w[suse opensuse].include?(OHAI_SYSTEM["platform_family"])
# suse gets this right:
it "errors out trying to unlock the user" do
- @error.should be_a(Mixlib::ShellOut::ShellCommandFailed)
- @error.message.should include("Cannot unlock the password")
+ expect(@error).to be_a(Mixlib::ShellOut::ShellCommandFailed)
+ expect(@error.message).to include("Cannot unlock the password")
end
else
@@ -644,13 +644,13 @@ describe Chef::Provider::User::Useradd, metadata do
# You should set a password with usermod -p to unlock this user's password.
# DEBUG: ---- End output of usermod -U chef-functional-test ----
# DEBUG: Ran usermod -U chef-functional-test returned 0
- @error.should be_nil
+ expect(@error).to be_nil
if ohai[:platform] == "aix"
- pw_entry.passwd.should == '*'
+ expect(pw_entry.passwd).to eq('*')
user_account_should_be_unlocked
else
- pw_entry.passwd.should == 'x'
- shadow_password.should include("!")
+ expect(pw_entry.passwd).to eq('x')
+ expect(shadow_password).to include("!")
end
end
end
@@ -668,7 +668,7 @@ describe Chef::Provider::User::Useradd, metadata do
context "and the user is not locked" do
it "does not update the user" do
- user_resource.should_not be_updated_by_last_action
+ expect(user_resource).not_to be_updated_by_last_action
end
end