summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-10-29 15:14:22 -0700
committerClaire McQuin <claire@getchef.com>2014-10-29 15:59:04 -0700
commit5fed7a65a2f024d964ecf2de1bcf2911cf8a600c (patch)
tree14cc6968e4fe4fd2485c0211088b25c645a80a4b /spec/functional
parentb92c309b0f1aa0837f76ab89d6c81c36076ceca9 (diff)
downloadchef-5fed7a65a2f024d964ecf2de1bcf2911cf8a600c.tar.gz
Update to RSpec 3.
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/application_spec.rb2
-rw-r--r--spec/functional/dsl/reboot_pending_spec.rb10
-rw-r--r--spec/functional/dsl/registry_helper_spec.rb12
-rw-r--r--spec/functional/event_loggers/windows_eventlog_spec.rb10
-rw-r--r--spec/functional/file_content_management/deploy_strategies_spec.rb24
-rw-r--r--spec/functional/http/simple_spec.rb2
-rw-r--r--spec/functional/knife/cookbook_delete_spec.rb48
-rw-r--r--spec/functional/knife/exec_spec.rb4
-rw-r--r--spec/functional/knife/smoke_test.rb2
-rw-r--r--spec/functional/knife/ssh_spec.rb44
-rwxr-xr-xspec/functional/provider/remote_file/cache_control_data_spec.rb16
-rw-r--r--spec/functional/provider/whyrun_safe_ruby_block_spec.rb4
-rw-r--r--spec/functional/rebooter_spec.rb2
-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
-rw-r--r--spec/functional/run_lock_spec.rb18
-rw-r--r--spec/functional/shell_spec.rb6
-rw-r--r--spec/functional/tiny_server_spec.rb24
-rw-r--r--spec/functional/util/path_helper_spec.rb2
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/functional/win32/registry_helper_spec.rb250
-rw-r--r--spec/functional/win32/security_spec.rb2
-rw-r--r--spec/functional/win32/service_manager_spec.rb56
-rw-r--r--spec/functional/win32/versions_spec.rb12
42 files changed, 770 insertions, 772 deletions
diff --git a/spec/functional/application_spec.rb b/spec/functional/application_spec.rb
index 4a0fdff8f8..00ff0f702a 100644
--- a/spec/functional/application_spec.rb
+++ b/spec/functional/application_spec.rb
@@ -52,7 +52,7 @@ describe Chef::Application do
shell_out("echo $http_proxy")
end
- so.stdout.chomp.should == "http://proxy.example.org:8080"
+ expect(so.stdout.chomp).to eq("http://proxy.example.org:8080")
end
end
end
diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb
index 114754ccba..e44e65fd49 100644
--- a/spec/functional/dsl/reboot_pending_spec.rb
+++ b/spec/functional/dsl/reboot_pending_spec.rb
@@ -49,7 +49,7 @@ describe Chef::DSL::RebootPending, :windows_only do
describe "when there is nothing to indicate a reboot is pending" do
it "should return false" do
pending "Found existing registry keys" unless registry_safe?
- expect(recipe.reboot_pending?).to be_false
+ expect(recipe.reboot_pending?).to be_falsey
end
end
@@ -59,7 +59,7 @@ describe Chef::DSL::RebootPending, :windows_only do
registry.set_value('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager',
{ :name => 'PendingFileRenameOperations', :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] })
- expect(recipe.reboot_pending?).to be_true
+ expect(recipe.reboot_pending?).to be_truthy
end
after do
@@ -74,7 +74,7 @@ describe Chef::DSL::RebootPending, :windows_only do
pending "Found existing registry keys" unless registry_safe?
registry.create_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired', false)
- expect(recipe.reboot_pending?).to be_true
+ expect(recipe.reboot_pending?).to be_truthy
end
after do
@@ -90,7 +90,7 @@ describe Chef::DSL::RebootPending, :windows_only do
pending "Found existing registry keys" unless registry_safe?
registry.create_key('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired', false)
- expect(recipe.reboot_pending?).to be_true
+ expect(recipe.reboot_pending?).to be_truthy
end
after do
@@ -107,7 +107,7 @@ describe Chef::DSL::RebootPending, :windows_only do
registry.set_value('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile',
{ :name => 'Flags', :type => :dword, :data => 3 })
- expect(recipe.reboot_pending?).to be_true
+ expect(recipe.reboot_pending?).to be_truthy
end
after do
diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb
index 452c4c2799..df5b09f1f6 100644
--- a/spec/functional/dsl/registry_helper_spec.rb
+++ b/spec/functional/dsl/registry_helper_spec.rb
@@ -40,24 +40,24 @@ describe Chef::Resource::RegistryKey, :windows_only do
context "tests registry dsl" do
it "returns true if registry_key_exists" do
- @resource.registry_key_exists?("HKCU\\Software\\Root").should == true
+ expect(@resource.registry_key_exists?("HKCU\\Software\\Root")).to eq(true)
end
it "returns true if registry has specified value" do
values = @resource.registry_get_values("HKCU\\Software\\Root")
- values.include?({:name=>"RootType1",:type=>:string,:data=>"fibrous"}).should == true
+ expect(values.include?({:name=>"RootType1",:type=>:string,:data=>"fibrous"})).to eq(true)
end
it "returns true if specified registry_has_subkey" do
- @resource.registry_has_subkeys?("HKCU\\Software\\Root").should == true
+ expect(@resource.registry_has_subkeys?("HKCU\\Software\\Root")).to eq(true)
end
it "returns true if specified key has specified subkey" do
subkeys = @resource.registry_get_subkeys("HKCU\\Software\\Root")
- subkeys.include?("Branch").should == true
+ expect(subkeys.include?("Branch")).to eq(true)
end
it "returns true if registry_value_exists" do
- @resource.registry_value_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"}).should == true
+ expect(@resource.registry_value_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"})).to eq(true)
end
it "returns true if data_value_exists" do
- @resource.registry_data_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"}).should == true
+ expect(@resource.registry_data_exists?("HKCU\\Software\\Root", {:name=>"RootType1", :type=>:string, :data=>"fibrous"})).to eq(true)
end
end
end
diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb
index 9da9f60fa9..2a87262fe1 100644
--- a/spec/functional/event_loggers/windows_eventlog_spec.rb
+++ b/spec/functional/event_loggers/windows_eventlog_spec.rb
@@ -37,21 +37,21 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
let(:mock_exception) { double('Exception', {message: SecureRandom.uuid, backtrace:[SecureRandom.uuid, SecureRandom.uuid]})}
it 'is available' do
- Chef::EventLoggers::WindowsEventLogger.available?.should be_true
+ expect(Chef::EventLoggers::WindowsEventLogger.available?).to be_truthy
end
it 'writes run_start event with event_id 10000 and contains version' do
logger.run_start(version)
expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10000 &&
- e.string_inserts[0].include?(version)}).to be_true
+ e.string_inserts[0].include?(version)}).to be_truthy
end
it 'writes run_started event with event_id 10001 and contains the run_id' do
logger.run_started(run_status)
expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10001 &&
- e.string_inserts[0].include?(run_id)}).to be_true
+ e.string_inserts[0].include?(run_id)}).to be_truthy
end
it 'writes run_completed event with event_id 10002 and contains the run_id and elapsed time' do
@@ -61,7 +61,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10002 &&
e.string_inserts[0].include?(run_id) &&
e.string_inserts[1].include?(elapsed_time.to_s)
- }).to be_true
+ }).to be_truthy
end
it 'writes run_failed event with event_id 10003 and contains the run_id, elapsed time, and exception info' do
@@ -76,7 +76,7 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only do
e.string_inserts[3].include?(mock_exception.message) &&
e.string_inserts[4].include?(mock_exception.backtrace[0]) &&
e.string_inserts[4].include?(mock_exception.backtrace[1])
- end).to be_true
+ end).to be_truthy
end
end
diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb
index dd1ef6228f..bcd171eb73 100644
--- a/spec/functional/file_content_management/deploy_strategies_spec.rb
+++ b/spec/functional/file_content_management/deploy_strategies_spec.rb
@@ -56,11 +56,11 @@ shared_examples_for "a content deploy strategy" do
it "touches the file to create it (UNIX)", :unix_only do
content_deployer.create(target_file_path)
- File.should exist(target_file_path)
+ expect(File).to exist(target_file_path)
file_info = File.stat(target_file_path)
- file_info.should be_owned
- file_info.should be_file
- normalize_mode(file_info.mode).should == default_mode
+ expect(file_info).to be_owned
+ expect(file_info).to be_file
+ expect(normalize_mode(file_info.mode)).to eq(default_mode)
end
##
@@ -89,10 +89,10 @@ shared_examples_for "a content deploy strategy" do
it "touches the file to create it (Windows)", :windows_only do
content_deployer.create(target_file_path)
- File.should exist(target_file_path)
+ expect(File).to exist(target_file_path)
file_info = File.stat(target_file_path)
- file_info.should be_owned
- file_info.should be_file
+ expect(file_info).to be_owned
+ expect(file_info).to be_file
parent_aces = parent_inheritable_aces
security_obj = Chef::ReservedNames::Win32::Security::SecurableObject.new(target_file_path)
@@ -106,7 +106,7 @@ shared_examples_for "a content deploy strategy" do
end
self_aces.each_with_index do |ace, index|
- ace.mask.should == parent_aces[index].mask
+ expect(ace.mask).to eq(parent_aces[index].mask)
end
end
end
@@ -147,7 +147,7 @@ shared_examples_for "a content deploy strategy" do
content_deployer.deploy(staging_file_path, target_file_path)
updated_info = File.stat(target_file_path)
- unix_invariant_properies(original_info).should == unix_invariant_properies(updated_info)
+ expect(unix_invariant_properies(original_info)).to eq(unix_invariant_properies(updated_info))
end
it "maintains invariant properties on Windows", :windows_only do
@@ -155,12 +155,12 @@ shared_examples_for "a content deploy strategy" do
content_deployer.deploy(staging_file_path, target_file_path)
updated_info = Chef::ReservedNames::Win32::Security::SecurableObject.new(target_file_path)
- win_invariant_properties(original_info).should == win_invariant_properties(updated_info)
+ expect(win_invariant_properties(original_info)).to eq(win_invariant_properties(updated_info))
end
it "updates the target with content from staged" do
content_deployer.deploy(staging_file_path, target_file_path)
- binread(target_file_path).should == staging_file_content
+ expect(binread(target_file_path)).to eq(staging_file_content)
end
context "when the owner of the target file is not the owner of the staging file", :requires_root do
@@ -174,7 +174,7 @@ shared_examples_for "a content deploy strategy" do
content_deployer.deploy(staging_file_path, target_file_path)
updated_info = File.stat(target_file_path)
- unix_invariant_properies(original_info).should == unix_invariant_properies(updated_info)
+ expect(unix_invariant_properies(original_info)).to eq(unix_invariant_properies(updated_info))
end
end
diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb
index fec71351df..36468b4eba 100644
--- a/spec/functional/http/simple_spec.rb
+++ b/spec/functional/http/simple_spec.rb
@@ -85,7 +85,7 @@ describe Chef::HTTP::Simple do
before do
Chef::Log.level = :debug
@debug_log = ''
- Chef::Log.stub(:debug) { |str| @debug_log << str }
+ allow(Chef::Log).to receive(:debug) { |str| @debug_log << str }
end
let(:source) { 'http://localhost:9000' }
diff --git a/spec/functional/knife/cookbook_delete_spec.rb b/spec/functional/knife/cookbook_delete_spec.rb
index 4773fd2185..15ac8f55ab 100644
--- a/spec/functional/knife/cookbook_delete_spec.rb
+++ b/spec/functional/knife/cookbook_delete_spec.rb
@@ -51,9 +51,9 @@ describe Chef::Knife::CookbookDelete do
end
it "logs an error and exits" do
- @knife.ui.stub(:stderr).and_return(@log_output)
- lambda {@knife.run}.should raise_error(SystemExit)
- @log_output.string.should match(/Cannot find a cookbook named no-such-cookbook to delete/)
+ allow(@knife.ui).to receive(:stderr).and_return(@log_output)
+ expect {@knife.run}.to raise_error(SystemExit)
+ expect(@log_output.string).to match(/Cannot find a cookbook named no-such-cookbook to delete/)
end
end
@@ -67,33 +67,33 @@ describe Chef::Knife::CookbookDelete do
it "asks for confirmation, then deletes the cookbook" do
stdin, stdout = StringIO.new("y\n"), StringIO.new
- @knife.ui.stub(:stdin).and_return(stdin)
- @knife.ui.stub(:stdout).and_return(stdout)
+ allow(@knife.ui).to receive(:stdin).and_return(stdin)
+ allow(@knife.ui).to receive(:stdout).and_return(stdout)
cb100_deleted = false
@api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
@knife.run
- stdout.string.should match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
- cb100_deleted.should be_true
+ expect(stdout.string).to match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
+ expect(cb100_deleted).to be_truthy
end
it "asks for confirmation before purging" do
@knife.config[:purge] = true
stdin, stdout = StringIO.new("y\ny\n"), StringIO.new
- @knife.ui.stub(:stdin).and_return(stdin)
- @knife.ui.stub(:stdout).and_return(stdout)
+ allow(@knife.ui).to receive(:stdin).and_return(stdin)
+ allow(@knife.ui).to receive(:stdout).and_return(stdout)
cb100_deleted = false
@api.delete("/cookbooks/obsolete-cookbook/1.0.0?purge=true", 200) { cb100_deleted = true; "[\"true\"]" }
@knife.run
- stdout.string.should match(/#{Regexp.escape('Are you sure you want to purge files')}/)
- stdout.string.should match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
- cb100_deleted.should be_true
+ expect(stdout.string).to match(/#{Regexp.escape('Are you sure you want to purge files')}/)
+ expect(stdout.string).to match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
+ expect(cb100_deleted).to be_truthy
end
@@ -117,22 +117,22 @@ describe Chef::Knife::CookbookDelete do
@api.delete("/cookbooks/obsolete-cookbook/1.2.0", 200) { cb120_deleted = true; "[\"true\"]" }
@knife.run
- cb100_deleted.should be_true
- cb110_deleted.should be_true
- cb120_deleted.should be_true
+ expect(cb100_deleted).to be_truthy
+ expect(cb110_deleted).to be_truthy
+ expect(cb120_deleted).to be_truthy
end
it "asks which version to delete and deletes that when not given the -a flag" do
cb100_deleted = cb110_deleted = cb120_deleted = nil
@api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
stdin, stdout = StringIO.new, StringIO.new
- @knife.ui.stub(:stdin).and_return(stdin)
- @knife.ui.stub(:stdout).and_return(stdout)
+ allow(@knife.ui).to receive(:stdin).and_return(stdin)
+ allow(@knife.ui).to receive(:stdout).and_return(stdout)
stdin << "1\n"
stdin.rewind
@knife.run
- cb100_deleted.should be_true
- stdout.string.should match(/Which version\(s\) do you want to delete\?/)
+ expect(cb100_deleted).to be_truthy
+ expect(stdout.string).to match(/Which version\(s\) do you want to delete\?/)
end
it "deletes all versions of the cookbook when not given the -a flag and the user chooses to delete all" do
@@ -142,14 +142,14 @@ describe Chef::Knife::CookbookDelete do
@api.delete("/cookbooks/obsolete-cookbook/1.2.0", 200) { cb120_deleted = true; "[\"true\"]" }
stdin, stdout = StringIO.new("4\n"), StringIO.new
- @knife.ui.stub(:stdin).and_return(stdin)
- @knife.ui.stub(:stdout).and_return(stdout)
+ allow(@knife.ui).to receive(:stdin).and_return(stdin)
+ allow(@knife.ui).to receive(:stdout).and_return(stdout)
@knife.run
- cb100_deleted.should be_true
- cb110_deleted.should be_true
- cb120_deleted.should be_true
+ expect(cb100_deleted).to be_truthy
+ expect(cb110_deleted).to be_truthy
+ expect(cb120_deleted).to be_truthy
end
end
diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb
index 7eb52d01df..0a9177b5e8 100644
--- a/spec/functional/knife/exec_spec.rb
+++ b/spec/functional/knife/exec_spec.rb
@@ -41,7 +41,7 @@ describe Chef::Knife::Exec do
@server.stop
end
- pending "executes a script in the context of the chef-shell main context", :ruby_18_only
+ skip "executes a script in the context of the chef-shell main context", :ruby_18_only
it "executes a script in the context of the chef-shell main context", :ruby_gte_19_only do
@node = Chef::Node.new
@@ -51,7 +51,7 @@ describe Chef::Knife::Exec do
code = "$output.puts nodes.all"
@knife.config[:exec] = code
@knife.run
- $output.string.should match(%r{node\[ohai-world\]})
+ expect($output.string).to match(%r{node\[ohai-world\]})
end
end
diff --git a/spec/functional/knife/smoke_test.rb b/spec/functional/knife/smoke_test.rb
index 6ccd462516..607e8065cf 100644
--- a/spec/functional/knife/smoke_test.rb
+++ b/spec/functional/knife/smoke_test.rb
@@ -29,6 +29,6 @@ describe "knife smoke tests" do
knife_cmd = Mixlib::ShellOut.new("#{knife_path} -v")
knife_cmd.run_command
knife_cmd.error!
- knife_cmd.stdout.should include(Chef::VERSION)
+ expect(knife_cmd.stdout).to include(Chef::VERSION)
end
end
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index 40d71859c7..cde702e8b2 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_identity_file" do
@knife.run
- @knife.config[:identity_file].should == "~/.ssh/aws.rsa"
+ expect(@knife.config[:identity_file]).to eq("~/.ssh/aws.rsa")
end
end
@@ -52,7 +52,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_identity_file" do
@knife.run
- @knife.config[:identity_file].should == "~/.ssh/aws.rsa"
+ expect(@knife.config[:identity_file]).to eq("~/.ssh/aws.rsa")
end
end
@@ -64,13 +64,13 @@ describe Chef::Knife::Ssh do
it "should use the value on the command line" do
@knife.run
- @knife.config[:identity_file].should == "~/.ssh/aws.rsa"
+ expect(@knife.config[:identity_file]).to eq("~/.ssh/aws.rsa")
end
it "should override what is set in knife.rb" do
Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/other.rsa"
@knife.run
- @knife.config[:identity_file].should == "~/.ssh/aws.rsa"
+ expect(@knife.config[:identity_file]).to eq("~/.ssh/aws.rsa")
end
end
@@ -82,7 +82,7 @@ describe Chef::Knife::Ssh do
it "uses the default" do
@knife.run
- @knife.config[:identity_file].should == nil
+ expect(@knife.config[:identity_file]).to eq(nil)
end
end
end
@@ -95,7 +95,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_port" do
@knife.run
- @knife.config[:ssh_port].should == "31337"
+ expect(@knife.config[:ssh_port]).to eq("31337")
end
end
end
@@ -109,7 +109,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_user" do
@knife.run
- @knife.config[:ssh_user].should == "ubuntu"
+ expect(@knife.config[:ssh_user]).to eq("ubuntu")
end
end
@@ -121,7 +121,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_user" do
@knife.run
- @knife.config[:ssh_user].should == "ubuntu"
+ expect(@knife.config[:ssh_user]).to eq("ubuntu")
end
end
@@ -133,13 +133,13 @@ describe Chef::Knife::Ssh do
it "should use the value on the command line" do
@knife.run
- @knife.config[:ssh_user].should == "ubuntu"
+ expect(@knife.config[:ssh_user]).to eq("ubuntu")
end
it "should override what is set in knife.rb" do
Chef::Config[:knife][:ssh_user] = "root"
@knife.run
- @knife.config[:ssh_user].should == "ubuntu"
+ expect(@knife.config[:ssh_user]).to eq("ubuntu")
end
end
@@ -151,7 +151,7 @@ describe Chef::Knife::Ssh do
it "uses the default (current user)" do
@knife.run
- @knife.config[:ssh_user].should == nil
+ expect(@knife.config[:ssh_user]).to eq(nil)
end
end
end
@@ -165,7 +165,7 @@ describe Chef::Knife::Ssh do
it "uses the ssh_attribute" do
@knife.run
- @knife.config[:attribute].should == "ec2.public_hostname"
+ expect(@knife.config[:attribute]).to eq("ec2.public_hostname")
end
end
@@ -177,7 +177,7 @@ describe Chef::Knife::Ssh do
it "uses the default" do
@knife.run
- @knife.config[:attribute].should == "fqdn"
+ expect(@knife.config[:attribute]).to eq("fqdn")
end
end
@@ -189,7 +189,7 @@ describe Chef::Knife::Ssh do
it "should use the value on the command line" do
@knife.run
- @knife.config[:attribute].should == "ec2.public_hostname"
+ expect(@knife.config[:attribute]).to eq("ec2.public_hostname")
end
it "should override what is set in knife.rb" do
@@ -198,7 +198,7 @@ describe Chef::Knife::Ssh do
# Then we run knife with the -a flag, which sets the above variable
setup_knife(['-a ec2.public_hostname', '*:*', 'uptime'])
@knife.run
- @knife.config[:attribute].should == "ec2.public_hostname"
+ expect(@knife.config[:attribute]).to eq("ec2.public_hostname")
end
end
end
@@ -211,9 +211,9 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway" do
- @knife.session.should_receive(:via).with("ec2.public_hostname", "user", {})
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
@knife.run
- @knife.config[:ssh_gateway].should == "user@ec2.public_hostname"
+ expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
end
end
@@ -224,9 +224,9 @@ describe Chef::Knife::Ssh do
end
it "uses the ssh_gateway" do
- @knife.session.should_receive(:via).with("ec2.public_hostname", "user", {})
+ expect(@knife.session).to receive(:via).with("ec2.public_hostname", "user", {})
@knife.run
- @knife.config[:ssh_gateway].should == "user@ec2.public_hostname"
+ expect(@knife.config[:ssh_gateway]).to eq("user@ec2.public_hostname")
end
end
@@ -234,13 +234,13 @@ describe Chef::Knife::Ssh do
before do
setup_knife(['-G user@ec2.public_hostname', '*:*', 'uptime'])
Chef::Config[:knife][:ssh_gateway] = nil
- @knife.session.stub(:via) do |host, user, options|
+ allow(@knife.session).to receive(:via) do |host, user, options|
raise Net::SSH::AuthenticationFailed unless options[:password]
end
end
it "should prompt the user for a password" do
- @knife.ui.should_receive(:ask).with("Enter the password for user@ec2.public_hostname: ").and_return("password")
+ expect(@knife.ui).to receive(:ask).with("Enter the password for user@ec2.public_hostname: ").and_return("password")
@knife.run
end
end
@@ -252,7 +252,7 @@ describe Chef::Knife::Ssh do
# if available, but #merge_configs (which is called by #configure_chef) is
# necessary to have default options merged in.
@knife.merge_configs
- @knife.stub(:ssh_command).and_return { 0 }
+ allow(@knife).to receive(:ssh_command) { 0 }
@api = TinyServer::API.instance
@api.clear
diff --git a/spec/functional/provider/remote_file/cache_control_data_spec.rb b/spec/functional/provider/remote_file/cache_control_data_spec.rb
index 63a4578c69..41f228ae3c 100755
--- a/spec/functional/provider/remote_file/cache_control_data_spec.rb
+++ b/spec/functional/provider/remote_file/cache_control_data_spec.rb
@@ -64,9 +64,9 @@ describe Chef::Provider::RemoteFile::CacheControlData do
it "writes the data to the cache and the same data can be read back" do
cache_control_data.save
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
- saved_cache_control_data.etag.should == cache_control_data.etag
- saved_cache_control_data.mtime.should == cache_control_data.mtime
- saved_cache_control_data.checksum.should == cache_control_data.checksum
+ expect(saved_cache_control_data.etag).to eq(cache_control_data.etag)
+ expect(saved_cache_control_data.mtime).to eq(cache_control_data.mtime)
+ expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
end
# Cover the very long remote file path case -- see CHEF-4422 where
@@ -81,17 +81,17 @@ describe Chef::Provider::RemoteFile::CacheControlData do
let(:uri) { uri_exceeds_file_system_limit }
it "writes data to the cache" do
- lambda do
+ expect do
cache_control_data.save
- end.should_not raise_error
+ end.not_to raise_error
end
it "writes the data to the cache and the same data can be read back" do
cache_control_data.save
saved_cache_control_data = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(uri, file_checksum)
- saved_cache_control_data.etag.should == cache_control_data.etag
- saved_cache_control_data.mtime.should == cache_control_data.mtime
- saved_cache_control_data.checksum.should == cache_control_data.checksum
+ expect(saved_cache_control_data.etag).to eq(cache_control_data.etag)
+ expect(saved_cache_control_data.mtime).to eq(cache_control_data.mtime)
+ expect(saved_cache_control_data.checksum).to eq(cache_control_data.checksum)
end
end
diff --git a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
index 150d46d384..b3c2333e9a 100644
--- a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
@@ -44,8 +44,8 @@ describe Chef::Resource::WhyrunSafeRubyBlock do
it "updates the evil laugh, even in why-run mode" do
new_resource.run_action(new_resource.action)
- $evil_global_evil_laugh.should == :mwahahaha
- new_resource.should be_updated
+ expect($evil_global_evil_laugh).to eq(:mwahahaha)
+ expect(new_resource).to be_updated
end
end
end
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 8006580d5c..763021607b 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -70,7 +70,7 @@ describe Chef::Platform::Rebooter do
shared_context 'test a reboot method' do
def test_rebooter_method(method_sym, is_windows, expected_reboot_str)
- Chef::Platform.stub(:windows?).and_return(is_windows)
+ allow(Chef::Platform).to receive(:windows?).and_return(is_windows)
expect(rebooter).to receive(:shell_out!).once.with(expected_reboot_str)
expect(rebooter).to receive(method_sym).once.and_call_original
rebooter.send(method_sym, run_context.node)
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
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 9eec0dab04..0cb8635256 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -163,13 +163,13 @@ describe Chef::RunLock do
let!(:run_lock) { Chef::RunLock.new(lockfile) }
it "creates the full path to the lockfile" do
- lambda { run_lock.acquire }.should_not raise_error
- File.should exist(lockfile)
+ expect { run_lock.acquire }.not_to raise_error
+ expect(File).to exist(lockfile)
end
it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do
run_lock.acquire
- (run_lock.runlock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).should == Fcntl::FD_CLOEXEC
+ expect(run_lock.runlock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).to eq(Fcntl::FD_CLOEXEC)
end
it "allows only one chef client run per lockfile" do
@@ -208,7 +208,7 @@ p1 has lock
p1 releasing lock
p2 has lock
E
- results.should == expected
+ expect(results).to eq(expected)
end
it "clears the lock if the process dies unexpectedly" do
@@ -233,12 +233,12 @@ E
Process.waitpid2(p2)
- results.should =~ /p2 has lock\Z/
+ expect(results).to match(/p2 has lock\Z/)
end
it "test returns true and acquires the lock" do
p1 = fork do
- run_lock.test.should == true
+ expect(run_lock.test).to eq(true)
sleep 2
exit! 1
end
@@ -246,7 +246,7 @@ E
wait_on_lock
p2 = fork do
- run_lock.test.should == false
+ expect(run_lock.test).to eq(false)
exit! 0
end
@@ -263,7 +263,7 @@ E
wait_on_lock
- run_lock.test.should == false
+ expect(run_lock.test).to eq(false)
Process.waitpid2(p1)
end
@@ -277,7 +277,7 @@ E
wait_on_lock
sleep 0.5 # Possible race condition on Solaris which pid is observed as 0
- File.read(lockfile).should == p1.to_s
+ expect(File.read(lockfile)).to eq(p1.to_s)
Process.waitpid2(p1)
end
diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb
index f2ce3f53e4..fa9de77b0e 100644
--- a/spec/functional/shell_spec.rb
+++ b/spec/functional/shell_spec.rb
@@ -105,7 +105,7 @@ describe Shell do
it "boots correctly with -lauto" do
output, exitstatus = run_chef_shell_with("-lauto")
- output.should include("done")
+ expect(output).to include("done")
expect(exitstatus).to eq(0)
end
@@ -115,7 +115,7 @@ describe Shell do
keyboard.puts(show_log_level_code)
read_until(out, show_log_level_code)
end
- output.should include("===fatal===")
+ expect(output).to include("===fatal===")
expect(exitstatus).to eq(0)
end
@@ -125,7 +125,7 @@ describe Shell do
keyboard.puts(show_recipes_code)
read_until(out, show_recipes_code)
end
- output.should include(%q{["override::foo", "override::bar"]})
+ expect(output).to include(%q{["override::foo", "override::bar"]})
expect(exitstatus).to eq(0)
end
end
diff --git a/spec/functional/tiny_server_spec.rb b/spec/functional/tiny_server_spec.rb
index bfa6ff1ddb..87be948a0d 100644
--- a/spec/functional/tiny_server_spec.rb
+++ b/spec/functional/tiny_server_spec.rb
@@ -26,39 +26,39 @@ describe TinyServer::API do
end
it "is a Singleton" do
- lambda {TinyServer::API.new}.should raise_error
+ expect {TinyServer::API.new}.to raise_error
end
it "clears the router" do
@api.get('/blargh', 200, "blargh")
@api.clear
- @api.routes["GET"].should be_empty
+ expect(@api.routes["GET"]).to be_empty
end
it "creates a route for a GET request" do
@api.get('/foo/bar', 200, 'hello foobar')
# WEBrick gives you the full URI with host, Thin only gave the part after scheme+host+port
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => 'http://localhost:1974/foo/bar')
- response.should == [200, {'Content-Type' => 'application/json'}, [ 'hello foobar' ]]
+ expect(response).to eq([200, {'Content-Type' => 'application/json'}, [ 'hello foobar' ]])
end
it "creates a route for a request with a block" do
block_called = false
@api.get('/bar/baz', 200) { block_called = true; 'hello barbaz' }
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => 'http://localhost:1974/bar/baz')
- response.should == [200, {'Content-Type' => 'application/json'}, [ 'hello barbaz' ]]
- block_called.should be_true
+ expect(response).to eq([200, {'Content-Type' => 'application/json'}, [ 'hello barbaz' ]])
+ expect(block_called).to be_truthy
end
it "returns debugging info for 404s" do
response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => '/no_such_thing')
- response[0].should == 404
- response[1].should == {'Content-Type' => 'application/json'}
- response[2].should be_a_kind_of(Array)
+ expect(response[0]).to eq(404)
+ expect(response[1]).to eq({'Content-Type' => 'application/json'})
+ expect(response[2]).to be_a_kind_of(Array)
response_obj = Chef::JSONCompat.from_json(response[2].first)
- response_obj["message"].should == "no data matches the request for /no_such_thing"
- response_obj["available_routes"].should == {"GET"=>[], "PUT"=>[], "POST"=>[], "DELETE"=>[]}
- response_obj["request"].should == {"REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"/no_such_thing"}
+ expect(response_obj["message"]).to eq("no data matches the request for /no_such_thing")
+ expect(response_obj["available_routes"]).to eq({"GET"=>[], "PUT"=>[], "POST"=>[], "DELETE"=>[]})
+ expect(response_obj["request"]).to eq({"REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"/no_such_thing"})
end
end
@@ -71,7 +71,7 @@ describe TinyServer::Manager do
TinyServer::API.instance.get("/index", 200, "[\"hello\"]")
rest = Chef::REST.new('http://localhost:9000', false, false)
- rest.get_rest("index").should == ["hello"]
+ expect(rest.get_rest("index")).to eq(["hello"])
@server.stop
end
diff --git a/spec/functional/util/path_helper_spec.rb b/spec/functional/util/path_helper_spec.rb
index ccdf383c22..0321702bb8 100644
--- a/spec/functional/util/path_helper_spec.rb
+++ b/spec/functional/util/path_helper_spec.rb
@@ -31,7 +31,7 @@ describe Chef::Util::PathHelper, "escape_glob" do
end
pattern = File.join(PathHelper.escape_glob(dir), "*")
- Dir.glob(pattern).map { |x| File.basename(x) }.should match_array(files)
+ expect(Dir.glob(pattern).map { |x| File.basename(x) }).to match_array(files)
end
end
end
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index a342206161..71ba4d5b2f 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -28,7 +28,7 @@ describe "Chef Versions" do
binaries.each do |binary|
it "#{binary} version should be sane" do
- shell_out!("ruby #{File.join("bin", binary)} -v", :cwd => chef_dir).stdout.chomp.should == "Chef: #{Chef::VERSION}"
+ expect(shell_out!("ruby #{File.join("bin", binary)} -v", :cwd => chef_dir).stdout.chomp).to eq("Chef: #{Chef::VERSION}")
end
end
diff --git a/spec/functional/win32/registry_helper_spec.rb b/spec/functional/win32/registry_helper_spec.rb
index 830d6f4777..7b070e6fe1 100644
--- a/spec/functional/win32/registry_helper_spec.rb
+++ b/spec/functional/win32/registry_helper_spec.rb
@@ -34,7 +34,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
@@ -84,197 +84,197 @@ describe 'Chef::Win32::Registry', :windows_only do
describe "hive_exists?" do
it "returns true if the hive exists" do
- @registry.hive_exists?("HKCU\\Software\\Root").should == true
+ expect(@registry.hive_exists?("HKCU\\Software\\Root")).to eq(true)
end
it "returns false if the hive does not exist" do
- hive = @registry.hive_exists?("LYRU\\Software\\Root").should == false
+ hive = expect(@registry.hive_exists?("LYRU\\Software\\Root")).to eq(false)
end
end
describe "key_exists?" do
it "returns true if the key path exists" do
- @registry.key_exists?("HKCU\\Software\\Root\\Branch\\Flower").should == true
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Branch\\Flower")).to eq(true)
end
it "returns false if the key path does not exist" do
- @registry.key_exists?("HKCU\\Software\\Branch\\Flower").should == false
+ expect(@registry.key_exists?("HKCU\\Software\\Branch\\Flower")).to eq(false)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.key_exists?("JKLM\\Software\\Branch\\Flower")}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.key_exists?("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
describe "key_exists!" do
it "returns true if the key path exists" do
- @registry.key_exists!("HKCU\\Software\\Root\\Branch\\Flower").should == true
+ expect(@registry.key_exists!("HKCU\\Software\\Root\\Branch\\Flower")).to eq(true)
end
it "throws an exception if the key path does not exist" do
- lambda {@registry.key_exists!("HKCU\\Software\\Branch\\Flower")}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.key_exists!("HKCU\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.key_exists!("JKLM\\Software\\Branch\\Flower")}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.key_exists!("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
describe "value_exists?" do
it "throws an exception if the hive does not exist" do
- lambda {@registry.value_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.value_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- lambda {@registry.value_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.value_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- @registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"}).should == true
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
end
it "returns false if the value does not exist" do
- @registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"}).should == false
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})).to eq(false)
end
end
describe "value_exists!" do
it "throws an exception if the hive does not exist" do
- lambda {@registry.value_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.value_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- lambda {@registry.value_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.value_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the value exists" do
- @registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"}).should == true
+ expect(@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals"})).to eq(true)
end
it "throws an exception if the value does not exist" do
- lambda {@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})}.should raise_error(Chef::Exceptions::Win32RegValueMissing)
+ expect {@registry.value_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"FOOBAR"})}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
end
end
describe "data_exists?" do
it "throws an exception if the hive does not exist" do
- lambda {@registry.data_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.data_exists?("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- lambda {@registry.data_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.data_exists?("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]}).should == true
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
end
it "returns false if the name does not exist" do
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]}).should == false
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(false)
end
it "returns false if the types do not match" do
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"}).should == false
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"})).to eq(false)
end
it "returns false if the data does not match" do
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]}).should == false
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]})).to eq(false)
end
end
describe "data_exists!" do
it "throws an exception if the hive does not exist" do
- lambda {@registry.data_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.data_exists!("JKLM\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key does not exist" do
- lambda {@registry.data_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.data_exists!("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if all the data matches" do
- @registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]}).should == true
+ expect(@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Pink", "Delicate"]})).to eq(true)
end
it "throws an exception if the name does not exist" do
- lambda {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"slateP", :type=>:multi_string, :data=>["Pink", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the types do not match" do
- lambda {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"})}.should raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Pink"})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
it "throws an exception if the data does not match" do
- lambda {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]})}.should raise_error(Chef::Exceptions::Win32RegDataMissing)
+ expect {@registry.data_exists!("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Mauve", "Delicate"]})}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
end
end
describe "get_values" do
it "returns all values for a key if it exists" do
values = @registry.get_values("HKCU\\Software\\Root")
- values.should be_an_instance_of Array
- values.should == [{:name=>"RootType1", :type=>:string, :data=>"fibrous"},
- {:name=>"Roots", :type=>:multi_string, :data=>["strong roots", "healthy tree"]}]
+ expect(values).to be_an_instance_of Array
+ expect(values).to eq([{:name=>"RootType1", :type=>:string, :data=>"fibrous"},
+ {:name=>"Roots", :type=>:multi_string, :data=>["strong roots", "healthy tree"]}])
end
it "throws an exception if the key does not exist" do
- lambda {@registry.get_values("HKCU\\Software\\Branch\\Flower")}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.get_values("HKCU\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.get_values("JKLM\\Software\\Branch\\Flower")}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.get_values("JKLM\\Software\\Branch\\Flower")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
describe "set_value" do
it "updates a value if the key, value exist and type matches and value different" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
end
it "updates a value if the type does match and the values are different" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == false
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:string, :data=>"Yellow"})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(false)
end
it "creates a value if key exists and value does not" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
end
it "does nothing if data,type and name parameters for the value are same" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == false
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(false)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"Stamen", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})).to eq(true)
end
it "throws an exception if the key does not exist" do
- lambda {@registry.set_value("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.set_value("HKCU\\Software\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.set_value("JKLM\\Software\\Root\\Branch\\Flower", {:name=>"Petals", :type=>:multi_string, :data=>["Yellow", "Changed Color"]})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
# we are validating that the data gets .to_i called on it when type is a :dword
it "casts an integer string given as a dword into an integer" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>"32767"}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>32767}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>"32767"})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe32767", :type=>:dword, :data=>32767})).to eq(true)
end
it "casts a nonsense string given as a dword into zero" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>"whatdoesthisdo"}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>0}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>"whatdoesthisdo"})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeZero", :type=>:dword, :data=>0})).to eq(true)
end
it "throws an exception when trying to cast an array to an int for a dword" do
- lambda {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:dword, :data=>["one","two"]})}.should raise_error
+ expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:dword, :data=>["one","two"]})}.to raise_error
end
# we are validating that the data gets .to_s called on it when type is a :string
it "stores the string representation of an array into a string if you pass it an array" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>["one","two"]}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>'["one", "two"]'}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>["one","two"]})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBePainful", :type=>:string, :data=>'["one", "two"]'})).to eq(true)
end
it "stores the string representation of a number into a string if you pass it an number" do
- @registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>65535}).should == true
- @registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>"65535"}).should == true
+ expect(@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>65535})).to eq(true)
+ expect(@registry.data_exists?("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBe65535", :type=>:string, :data=>"65535"})).to eq(true)
end
# we are validating that the data gets .to_a called on it when type is a :multi_string
it "throws an exception when a multi-string is passed a number" do
- lambda {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:multi_string, :data=>65535})}.should raise_error
+ expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldThrow", :type=>:multi_string, :data=>65535})}.to raise_error
end
it "throws an exception when a multi-string is passed a string" do
- lambda {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeWat", :type=>:multi_string, :data=>"foo"})}.should raise_error
+ expect {@registry.set_value("HKCU\\Software\\Root\\Branch\\Flower", {:name=>"ShouldBeWat", :type=>:multi_string, :data=>"foo"})}.to raise_error
end
end
@@ -289,22 +289,22 @@ describe 'Chef::Win32::Registry', :windows_only do
end
it "throws an exception if the path has missing keys but recursive set to false" do
- lambda {@registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker").should == false
+ expect {@registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker")).to eq(false)
end
it "creates the key_path if the keys were missing but recursive was set to true" do
- @registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", true).should == true
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker").should == true
+ expect(@registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", true)).to eq(true)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker")).to eq(true)
end
it "does nothing if the key already exists" do
- @registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false).should == true
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker").should == true
+ expect(@registry.create_key("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)).to eq(true)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker")).to eq(true)
end
it "throws an exception of the hive does not exist" do
- lambda {@registry.create_key("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.create_key("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", false)}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -317,21 +317,21 @@ describe 'Chef::Win32::Registry', :windows_only do
end
it "deletes values if the value exists" do
- @registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"}).should == true
- @registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"}).should == false
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(false)
end
it "does nothing if value does not exist" do
- @registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"}).should == true
- @registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"}).should == false
+ expect(@registry.delete_value("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(true)
+ expect(@registry.value_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})).to eq(false)
end
it "throws an exception if the key does not exist?" do
- lambda {@registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.delete_value("HKCU\\Software\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.delete_value("JKLM\\Software\\Root\\Trunk\\Peck\\Woodpecker", {:name=>"Peter", :type=>:string, :data=>"Tiny"})}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -348,27 +348,27 @@ describe 'Chef::Win32::Registry', :windows_only do
end
it "deletes a key if it has no subkeys" do
- @registry.delete_key("HKCU\\Software\\Root\\Branch\\Fruit", false).should == true
- @registry.key_exists?("HKCU\\Software\\Root\\Branch\\Fruit").should == false
+ expect(@registry.delete_key("HKCU\\Software\\Root\\Branch\\Fruit", false)).to eq(true)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Branch\\Fruit")).to eq(false)
end
it "throws an exception if key to delete has subkeys and recursive is false" do
- lambda { @registry.delete_key("HKCU\\Software\\Root\\Trunk", false) }.should raise_error(Chef::Exceptions::Win32RegNoRecursive)
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker").should == true
+ expect { @registry.delete_key("HKCU\\Software\\Root\\Trunk", false) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk\\Peck\\Woodpecker")).to eq(true)
end
it "deletes a key if it has subkeys and recursive true" do
- @registry.delete_key("HKCU\\Software\\Root\\Trunk", true).should == true
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk").should == false
+ expect(@registry.delete_key("HKCU\\Software\\Root\\Trunk", true)).to eq(true)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk")).to eq(false)
end
it "does nothing if the key does not exist" do
- @registry.delete_key("HKCU\\Software\\Root\\Trunk", true).should == true
- @registry.key_exists?("HKCU\\Software\\Root\\Trunk").should == false
+ expect(@registry.delete_key("HKCU\\Software\\Root\\Trunk", true)).to eq(true)
+ expect(@registry.key_exists?("HKCU\\Software\\Root\\Trunk")).to eq(false)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.delete_key("JKLM\\Software\\Root\\Branch\\Flower", false)}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.delete_key("JKLM\\Software\\Root\\Branch\\Flower", false)}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
end
@@ -384,29 +384,29 @@ describe 'Chef::Win32::Registry', :windows_only do
end
it "throws an exception if the hive was missing" do
- lambda {@registry.has_subkeys?("LMNO\\Software\\Root")}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.has_subkeys?("LMNO\\Software\\Root")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "throws an exception if the key is missing" do
- lambda {@registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red")}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "returns true if the key has subkeys" do
- @registry.has_subkeys?("HKCU\\Software\\Root").should == true
+ expect(@registry.has_subkeys?("HKCU\\Software\\Root")).to eq(true)
end
it "returns false if the key has no subkeys" do
::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk\\Red"
- @registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red").should == false
+ expect(@registry.has_subkeys?("HKCU\\Software\\Root\\Trunk\\Red")).to eq(false)
end
end
describe "get_subkeys" do
it "throws an exception if the key is missing" do
- lambda {@registry.get_subkeys("HKCU\\Software\\Trunk\\Red")}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect {@registry.get_subkeys("HKCU\\Software\\Trunk\\Red")}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "throws an exception if the hive does not exist" do
- lambda {@registry.get_subkeys("JKLM\\Software\\Root")}.should raise_error(Chef::Exceptions::Win32RegHiveMissing)
+ expect {@registry.get_subkeys("JKLM\\Software\\Root")}.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
end
it "returns the array of subkeys for a given key" do
subkeys = @registry.get_subkeys("HKCU\\Software\\Root")
@@ -414,7 +414,7 @@ describe 'Chef::Win32::Registry', :windows_only do
::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root", Win32::Registry::KEY_ALL_ACCESS) do |reg|
reg.each_key{|name| reg_subkeys << name}
end
- reg_subkeys.should == subkeys
+ expect(reg_subkeys).to eq(subkeys)
end
end
@@ -431,37 +431,37 @@ describe 'Chef::Win32::Registry', :windows_only do
context "registry constructor" do
it "throws an exception if requested architecture is 64bit but running on 32bit" do
- lambda {Chef::Win32::Registry.new(@run_context, :x86_64)}.should raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
+ expect {Chef::Win32::Registry.new(@run_context, :x86_64)}.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
end
it "can correctly set the requested architecture to 32-bit" do
@r = Chef::Win32::Registry.new(@run_context, :i386)
- @r.architecture.should == :i386
- @r.registry_system_architecture.should == 0x0200
+ expect(@r.architecture).to eq(:i386)
+ expect(@r.registry_system_architecture).to eq(0x0200)
end
it "can correctly set the requested architecture to :machine" do
@r = Chef::Win32::Registry.new(@run_context, :machine)
- @r.architecture.should == :machine
- @r.registry_system_architecture.should == 0x0200
+ expect(@r.architecture).to eq(:machine)
+ expect(@r.registry_system_architecture).to eq(0x0200)
end
end
context "architecture setter" do
it "throws an exception if requested architecture is 64bit but running on 32bit" do
- lambda {@registry.architecture = :x86_64}.should raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
+ expect {@registry.architecture = :x86_64}.to raise_error(Chef::Exceptions::Win32RegArchitectureIncorrect)
end
it "sets the requested architecture to :machine if passed :machine" do
@registry.architecture = :machine
- @registry.architecture.should == :machine
- @registry.registry_system_architecture.should == 0x0200
+ expect(@registry.architecture).to eq(:machine)
+ expect(@registry.registry_system_architecture).to eq(0x0200)
end
it "sets the requested architecture to 32-bit if passed i386 as a string" do
@registry.architecture = :i386
- @registry.architecture.should == :i386
- @registry.registry_system_architecture.should == 0x0200
+ expect(@registry.architecture).to eq(:i386)
+ expect(@registry.registry_system_architecture).to eq(0x0200)
end
end
end
@@ -479,40 +479,40 @@ describe 'Chef::Win32::Registry', :windows_only do
context "registry constructor" do
it "can correctly set the requested architecture to 32-bit" do
@r = Chef::Win32::Registry.new(@run_context, :i386)
- @r.architecture.should == :i386
- @r.registry_system_architecture.should == 0x0200
+ expect(@r.architecture).to eq(:i386)
+ expect(@r.registry_system_architecture).to eq(0x0200)
end
it "can correctly set the requested architecture to 64-bit" do
@r = Chef::Win32::Registry.new(@run_context, :x86_64)
- @r.architecture.should == :x86_64
- @r.registry_system_architecture.should == 0x0100
+ expect(@r.architecture).to eq(:x86_64)
+ expect(@r.registry_system_architecture).to eq(0x0100)
end
it "can correctly set the requested architecture to :machine" do
@r = Chef::Win32::Registry.new(@run_context, :machine)
- @r.architecture.should == :machine
- @r.registry_system_architecture.should == 0x0100
+ expect(@r.architecture).to eq(:machine)
+ expect(@r.registry_system_architecture).to eq(0x0100)
end
end
context "architecture setter" do
it "sets the requested architecture to 64-bit if passed 64-bit" do
@registry.architecture = :x86_64
- @registry.architecture.should == :x86_64
- @registry.registry_system_architecture.should == 0x0100
+ expect(@registry.architecture).to eq(:x86_64)
+ expect(@registry.registry_system_architecture).to eq(0x0100)
end
it "sets the requested architecture to :machine if passed :machine" do
@registry.architecture = :machine
- @registry.architecture.should == :machine
- @registry.registry_system_architecture.should == 0x0100
+ expect(@registry.architecture).to eq(:machine)
+ expect(@registry.registry_system_architecture).to eq(0x0100)
end
it "sets the requested architecture to 32-bit if passed 32-bit" do
@registry.architecture = :i386
- @registry.architecture.should == :i386
- @registry.registry_system_architecture.should == 0x0200
+ expect(@registry.architecture).to eq(:i386)
+ expect(@registry.registry_system_architecture).to eq(0x0200)
end
end
end
@@ -555,75 +555,75 @@ describe 'Chef::Win32::Registry', :windows_only do
describe "key_exists?" do
it "does not find 64-bit keys in the 32-bit registry" do
@registry.architecture=:i386
- @registry.key_exists?("HKLM\\Software\\Root\\Mauve").should == false
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Mauve")).to eq(false)
end
it "finds 32-bit keys in the 32-bit registry" do
@registry.architecture=:i386
- @registry.key_exists?("HKLM\\Software\\Root\\Poosh").should == true
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Poosh")).to eq(true)
end
it "does not find 32-bit keys in the 64-bit registry" do
@registry.architecture=:x86_64
- @registry.key_exists?("HKLM\\Software\\Root\\Mauve").should == true
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Mauve")).to eq(true)
end
it "finds 64-bit keys in the 64-bit registry" do
@registry.architecture=:x86_64
- @registry.key_exists?("HKLM\\Software\\Root\\Poosh").should == false
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Poosh")).to eq(false)
end
end
describe "value_exists?" do
it "does not find 64-bit values in the 32-bit registry" do
@registry.architecture=:i386
- lambda{@registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect{@registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit values in the 32-bit registry" do
@registry.architecture=:i386
- @registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"}).should == true
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"})).to eq(true)
end
it "does not find 32-bit values in the 64-bit registry" do
@registry.architecture=:x86_64
- @registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"}).should == true
+ expect(@registry.value_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert"})).to eq(true)
end
it "finds 64-bit values in the 64-bit registry" do
@registry.architecture=:x86_64
- lambda{@registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect{@registry.value_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
describe "data_exists?" do
it "does not find 64-bit keys in the 32-bit registry" do
@registry.architecture=:i386
- lambda{@registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect{@registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
it "finds 32-bit keys in the 32-bit registry" do
@registry.architecture=:i386
- @registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"}).should == true
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"})).to eq(true)
end
it "does not find 32-bit keys in the 64-bit registry" do
@registry.architecture=:x86_64
- @registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"}).should == true
+ expect(@registry.data_exists?("HKLM\\Software\\Root\\Mauve", {:name=>"Alert", :type=>:string, :data=>"Universal"})).to eq(true)
end
it "finds 64-bit keys in the 64-bit registry" do
@registry.architecture=:x86_64
- lambda{@registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"})}.should raise_error(Chef::Exceptions::Win32RegKeyMissing)
+ expect{@registry.data_exists?("HKLM\\Software\\Root\\Poosh", {:name=>"Status", :type=>:string, :data=>"Lost"})}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
end
end
describe "create_key" do
it "can create a 32-bit only registry key" do
@registry.architecture = :i386
- @registry.create_key("HKLM\\Software\\Root\\Trunk\\Red", true).should == true
- @registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Red").should == true
+ expect(@registry.create_key("HKLM\\Software\\Root\\Trunk\\Red", true)).to eq(true)
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Red")).to eq(true)
@registry.architecture = :x86_64
- @registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Red").should == false
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Red")).to eq(false)
end
it "can create a 64-bit only registry key" do
@registry.architecture = :x86_64
- @registry.create_key("HKLM\\Software\\Root\\Trunk\\Blue", true).should == true
- @registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Blue").should == true
+ expect(@registry.create_key("HKLM\\Software\\Root\\Trunk\\Blue", true)).to eq(true)
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Blue")).to eq(true)
@registry.architecture = :i386
- @registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Blue").should == false
+ expect(@registry.key_exists?("HKLM\\Software\\Root\\Trunk\\Blue")).to eq(false)
end
end
diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb
index 4ad9b07b74..a6b5d57748 100644
--- a/spec/functional/win32/security_spec.rb
+++ b/spec/functional/win32/security_spec.rb
@@ -23,7 +23,7 @@ end
describe 'Chef::Win32::Security', :windows_only do
it "has_admin_privileges? returns true when running as admin" do
- Chef::ReservedNames::Win32::Security.has_admin_privileges?.should == true
+ expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to eq(true)
end
# We've done some investigation adding a negative test and it turned
diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb
index b5b2e20825..fd21e7d82e 100644
--- a/spec/functional/win32/service_manager_spec.rb
+++ b/spec/functional/win32/service_manager_spec.rb
@@ -93,7 +93,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
context "with invalid service definition" do
it "throws an error when initialized with no service definition" do
- lambda { Chef::Application::WindowsServiceManager.new(nil) }.should raise_error(ArgumentError)
+ expect { Chef::Application::WindowsServiceManager.new(nil) }.to raise_error(ArgumentError)
end
it "throws an error with required missing options" do
@@ -101,7 +101,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
service_def = test_service.dup
service_def.delete(key)
- lambda { Chef::Application::WindowsServiceManager.new(service_def) }.should raise_error(ArgumentError)
+ expect { Chef::Application::WindowsServiceManager.new(service_def) }.to raise_error(ArgumentError)
end
end
end
@@ -111,7 +111,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
@service_manager_output = [ ]
# Uncomment below lines to debug this test
# original_puts = $stdout.method(:puts)
- $stdout.stub(:puts) do |message|
+ allow($stdout).to receive(:puts) do |message|
@service_manager_output << message
# original_puts.call(message)
end
@@ -125,19 +125,19 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
it "default => should say service don't exist" do
service_manager.run
- @service_manager_output.grep(/doesn't exist on the system/).length.should > 0
+ expect(@service_manager_output.grep(/doesn't exist on the system/).length).to be > 0
end
it "install => should install the service" do
service_manager.run(["-a", "install"])
- test_service_exists?.should be_true
+ expect(test_service_exists?).to be_truthy
end
it "other actions => should say service doesn't exist" do
["delete", "start", "stop", "pause", "resume", "uninstall"].each do |action|
service_manager.run(["-a", action])
- @service_manager_output.grep(/doesn't exist on the system/).length.should > 0
+ expect(@service_manager_output.grep(/doesn't exist on the system/).length).to be > 0
@service_manager_output = [ ]
end
end
@@ -150,47 +150,47 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
it "should have an own-process, non-interactive type" do
status = ::Win32::Service.status("spec-service")
- status[:service_type].should == "own process"
- status[:interactive].should be_false
+ expect(status[:service_type]).to eq("own process")
+ expect(status[:interactive]).to be_falsey
end
it "install => should say service already exists" do
service_manager.run(["-a", "install"])
- @service_manager_output.grep(/already exists/).length.should > 0
+ expect(@service_manager_output.grep(/already exists/).length).to be > 0
end
context "and service is stopped" do
["delete", "uninstall"].each do |action|
it "#{action} => should remove the service", :volatile do
service_manager.run(["-a", action])
- test_service_exists?.should be_false
+ expect(test_service_exists?).to be_falsey
end
end
it "default, status => should say service is stopped" do
service_manager.run([ ])
- @service_manager_output.grep(/stopped/).length.should > 0
+ expect(@service_manager_output.grep(/stopped/).length).to be > 0
@service_manager_output = [ ]
service_manager.run(["-a", "status"])
- @service_manager_output.grep(/stopped/).length.should > 0
+ expect(@service_manager_output.grep(/stopped/).length).to be > 0
end
it "start should start the service", :volatile do
service_manager.run(["-a", "start"])
- test_service_state.should == "running"
- File.exists?(test_service_file).should be_true
+ expect(test_service_state).to eq("running")
+ expect(File.exists?(test_service_file)).to be_truthy
end
it "stop should not affect the service" do
service_manager.run(["-a", "stop"])
- test_service_state.should == "stopped"
+ expect(test_service_state).to eq("stopped")
end
["pause", "resume"].each do |action|
it "#{action} => should raise error" do
- lambda {service_manager.run(["-a", action])}.should raise_error(::Win32::Service::Error)
+ expect {service_manager.run(["-a", action])}.to raise_error(::Win32::Service::Error)
end
end
@@ -202,32 +202,32 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
["delete", "uninstall"].each do |action|
it "#{action} => should remove the service", :volatile do
service_manager.run(["-a", action])
- test_service_exists?.should be_false
+ expect(test_service_exists?).to be_falsey
end
end
it "default, status => should say service is running" do
service_manager.run([ ])
- @service_manager_output.grep(/running/).length.should > 0
+ expect(@service_manager_output.grep(/running/).length).to be > 0
@service_manager_output = [ ]
service_manager.run(["-a", "status"])
- @service_manager_output.grep(/running/).length.should > 0
+ expect(@service_manager_output.grep(/running/).length).to be > 0
end
it "stop should stop the service" do
service_manager.run(["-a", "stop"])
- test_service_state.should == "stopped"
+ expect(test_service_state).to eq("stopped")
end
it "pause should pause the service" do
service_manager.run(["-a", "pause"])
- test_service_state.should == "paused"
+ expect(test_service_state).to eq("paused")
end
it "resume should have no affect" do
service_manager.run(["-a", "resume"])
- test_service_state.should == "running"
+ expect(test_service_state).to eq("running")
end
end
@@ -241,31 +241,31 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
actions.each do |action|
it "#{action} => should remove the service" do
service_manager.run(["-a", action])
- test_service_exists?.should be_false
+ expect(test_service_exists?).to be_falsey
end
end
it "default, status => should say service is paused" do
service_manager.run([ ])
- @service_manager_output.grep(/paused/).length.should > 0
+ expect(@service_manager_output.grep(/paused/).length).to be > 0
@service_manager_output = [ ]
service_manager.run(["-a", "status"])
- @service_manager_output.grep(/paused/).length.should > 0
+ expect(@service_manager_output.grep(/paused/).length).to be > 0
end
it "stop should stop the service" do
service_manager.run(["-a", "stop"])
- test_service_state.should == "stopped"
+ expect(test_service_state).to eq("stopped")
end
it "pause should not affect the service" do
service_manager.run(["-a", "pause"])
- test_service_state.should == "paused"
+ expect(test_service_state).to eq("paused")
end
it "start should raise an error" do
- lambda {service_manager.run(["-a", "start"])}.should raise_error(::Win32::Service::Error)
+ expect {service_manager.run(["-a", "start"])}.to raise_error(::Win32::Service::Error)
end
end
diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb
index 6c8f6b2aaa..38af47b0c9 100644
--- a/spec/functional/win32/versions_spec.rb
+++ b/spec/functional/win32/versions_spec.rb
@@ -62,8 +62,8 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
it "should have have one method for each marketing version" do
versions = 0
for_each_windows_version { versions += 1 }
- versions.should > 0
- versions.should == Chef::ReservedNames::Win32::Version::WIN_VERSIONS.length
+ expect(versions).to be > 0
+ expect(versions).to eq(Chef::ReservedNames::Win32::Version::WIN_VERSIONS.length)
end
it "should only contain version methods with legal method names" do
@@ -71,8 +71,8 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
for_each_windows_version do |method_name|
method_match = method_name_pattern.match(method_name.to_s)
- method_match.should_not be_nil
- method_name.to_s.should == method_match[0]
+ expect(method_match).not_to be_nil
+ expect(method_name.to_s).to eq(method_match[0])
end
end
@@ -81,7 +81,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
for_each_windows_version do |method_name|
true_versions += 1 if @version.send(method_name)
end
- true_versions.should == 1
+ expect(true_versions).to eq(1)
end
it "should successfully execute all version methods" do
@@ -91,7 +91,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
context "Windows Operating System version" do
it "should match the version from WMI" do
- @current_os_version.should include(@version.marketing_name)
+ expect(@current_os_version).to include(@version.marketing_name)
end
end