summaryrefslogtreecommitdiff
path: root/spec/unit/resource
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-10-24 18:12:50 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-10-24 18:12:50 -0700
commitbd0b0a34e4dbb60fe61bbc8716df90e8f7c7d19a (patch)
treeacc7a2d09b2cec8eed863218c0400cd15cd27854 /spec/unit/resource
parentbdce1c5619fde7d277262df9336e06f73e4fc3f8 (diff)
downloadchef-bd0b0a34e4dbb60fe61bbc8716df90e8f7c7d19a.tar.gz
updating resources/providers unit tests to rpsec3
mechanically generated patch using transpec 2.3.7 gem
Diffstat (limited to 'spec/unit/resource')
-rw-r--r--spec/unit/resource/apt_package_spec.rb2
-rw-r--r--spec/unit/resource/bash_spec.rb8
-rw-r--r--spec/unit/resource/batch_spec.rb2
-rw-r--r--spec/unit/resource/breakpoint_spec.rb6
-rw-r--r--spec/unit/resource/chef_gem_spec.rb2
-rw-r--r--spec/unit/resource/conditional_action_not_nothing_spec.rb4
-rw-r--r--spec/unit/resource/conditional_spec.rb32
-rw-r--r--spec/unit/resource/cookbook_file_spec.rb26
-rw-r--r--spec/unit/resource/cron_spec.rb74
-rw-r--r--spec/unit/resource/csh_spec.rb8
-rw-r--r--spec/unit/resource/deploy_spec.rb102
-rw-r--r--spec/unit/resource/directory_spec.rb36
-rw-r--r--spec/unit/resource/easy_install_package_spec.rb2
-rw-r--r--spec/unit/resource/env_spec.rb24
-rw-r--r--spec/unit/resource/erl_call_spec.rb22
-rw-r--r--spec/unit/resource/execute_spec.rb2
-rw-r--r--spec/unit/resource/file_spec.rb58
-rw-r--r--spec/unit/resource/freebsd_package_spec.rb18
-rw-r--r--spec/unit/resource/gem_package_spec.rb2
-rw-r--r--spec/unit/resource/git_spec.rb8
-rw-r--r--spec/unit/resource/group_spec.rb54
-rw-r--r--spec/unit/resource/http_request_spec.rb12
-rw-r--r--spec/unit/resource/ifconfig_spec.rb16
-rw-r--r--spec/unit/resource/ips_package_spec.rb2
-rw-r--r--spec/unit/resource/link_spec.rb50
-rw-r--r--spec/unit/resource/log_spec.rb18
-rw-r--r--spec/unit/resource/mdadm_spec.rb36
-rw-r--r--spec/unit/resource/mount_spec.rb90
-rw-r--r--spec/unit/resource/ohai_spec.rb14
-rw-r--r--spec/unit/resource/package_spec.rb24
-rw-r--r--spec/unit/resource/perl_spec.rb8
-rw-r--r--spec/unit/resource/portage_package_spec.rb6
-rw-r--r--spec/unit/resource/powershell_spec.rb14
-rw-r--r--spec/unit/resource/python_spec.rb8
-rw-r--r--spec/unit/resource/registry_key_spec.rb64
-rw-r--r--spec/unit/resource/remote_directory_spec.rb34
-rw-r--r--spec/unit/resource/remote_file_spec.rb82
-rw-r--r--spec/unit/resource/route_spec.rb38
-rw-r--r--spec/unit/resource/ruby_block_spec.rb16
-rw-r--r--spec/unit/resource/ruby_spec.rb8
-rw-r--r--spec/unit/resource/scm_spec.rb80
-rw-r--r--spec/unit/resource/script_spec.rb4
-rw-r--r--spec/unit/resource/service_spec.rb72
-rw-r--r--spec/unit/resource/solaris_package_spec.rb2
-rw-r--r--spec/unit/resource/subversion_spec.rb16
-rw-r--r--spec/unit/resource/template_spec.rb70
-rw-r--r--spec/unit/resource/user_spec.rb46
-rw-r--r--spec/unit/resource/windows_package_spec.rb4
-rw-r--r--spec/unit/resource/windows_service_spec.rb2
-rw-r--r--spec/unit/resource/yum_package_spec.rb14
50 files changed, 671 insertions, 671 deletions
diff --git a/spec/unit/resource/apt_package_spec.rb b/spec/unit/resource/apt_package_spec.rb
index 9503e0cbe1..be8eb9c324 100644
--- a/spec/unit/resource/apt_package_spec.rb
+++ b/spec/unit/resource/apt_package_spec.rb
@@ -35,6 +35,6 @@ describe Chef::Resource::AptPackage, "initialize" do
it "should support default_release" do
@resource.default_release("lenny-backports")
- @resource.default_release.should eql("lenny-backports")
+ expect(@resource.default_release).to eql("lenny-backports")
end
end
diff --git a/spec/unit/resource/bash_spec.rb b/spec/unit/resource/bash_spec.rb
index d729db6977..f313900433 100644
--- a/spec/unit/resource/bash_spec.rb
+++ b/spec/unit/resource/bash_spec.rb
@@ -25,16 +25,16 @@ describe Chef::Resource::Bash do
end
it "should create a new Chef::Resource::Bash" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Bash)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Bash)
end
it "should have a resource name of :bash" do
- @resource.resource_name.should eql(:bash)
+ expect(@resource.resource_name).to eql(:bash)
end
it "should have an interpreter of bash" do
- @resource.interpreter.should eql("bash")
+ expect(@resource.interpreter).to eql("bash")
end
end
diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb
index b74c7d24a7..4a056b8735 100644
--- a/spec/unit/resource/batch_spec.rb
+++ b/spec/unit/resource/batch_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Resource::Batch do
end
it "should create a new Chef::Resource::Batch" do
- @resource.should be_a_kind_of(Chef::Resource::Batch)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Batch)
end
context "windows script" do
diff --git a/spec/unit/resource/breakpoint_spec.rb b/spec/unit/resource/breakpoint_spec.rb
index ed655b84a6..ed1f3ebcd5 100644
--- a/spec/unit/resource/breakpoint_spec.rb
+++ b/spec/unit/resource/breakpoint_spec.rb
@@ -33,15 +33,15 @@ describe Chef::Resource::Breakpoint do
end
it "allows the action :break" do
- @breakpoint.allowed_actions.should include(:break)
+ expect(@breakpoint.allowed_actions).to include(:break)
end
it "defaults to the break action" do
- @breakpoint.action.should == "break"
+ expect(@breakpoint.action).to eq("break")
end
it "names itself after the line number of the file where it's created" do
- @breakpoint.name.should match(/breakpoint_spec\.rb\:[\d]{2}\:in \`new\'$/)
+ expect(@breakpoint.name).to match(/breakpoint_spec\.rb\:[\d]{2}\:in \`new\'$/)
end
end
diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb
index 6a419b3f3b..480856d19f 100644
--- a/spec/unit/resource/chef_gem_spec.rb
+++ b/spec/unit/resource/chef_gem_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Resource::ChefGem, "gem_binary" do
end
it "should raise an exception when gem_binary is set" do
- lambda { @resource.gem_binary("/lol/cats/gem") }.should raise_error(ArgumentError)
+ expect { @resource.gem_binary("/lol/cats/gem") }.to raise_error(ArgumentError)
end
it "should set the gem_binary based on computing it from RbConfig" do
diff --git a/spec/unit/resource/conditional_action_not_nothing_spec.rb b/spec/unit/resource/conditional_action_not_nothing_spec.rb
index 49bc0ad57d..9f29de55f2 100644
--- a/spec/unit/resource/conditional_action_not_nothing_spec.rb
+++ b/spec/unit/resource/conditional_action_not_nothing_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Resource::ConditionalActionNotNothing do
end
it "indicates that resource convergence should not continue" do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
end
@@ -38,7 +38,7 @@ describe Chef::Resource::ConditionalActionNotNothing do
end
it "indicates that resource convergence should continue" do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
end
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index 1fc2518013..cacac925b7 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -21,9 +21,9 @@ require 'ostruct'
describe Chef::Resource::Conditional do
before do
- Mixlib::ShellOut.any_instance.stub(:run_command).and_return(nil)
+ allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command).and_return(nil)
@status = OpenStruct.new(:success? => true)
- Mixlib::ShellOut.any_instance.stub(:status).and_return(@status)
+ allow_any_instance_of(Mixlib::ShellOut).to receive(:status).and_return(@status)
@parent_resource = Chef::Resource.new(nil, Chef::Node.new)
end
@@ -53,7 +53,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should continue" do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
end
@@ -64,22 +64,22 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should not continue" do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
end
describe 'after running a command which timed out' do
before do
@conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false")
- Chef::GuardInterpreter::DefaultGuardInterpreter.any_instance.stub(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
+ allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
end
it 'indicates that resource convergence should not continue' do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
it 'should log a warning' do
- Chef::Log.should_receive(:warn).with("Command 'false' timed out")
+ expect(Chef::Log).to receive(:warn).with("Command 'false' timed out")
@conditional.continue?
end
end
@@ -90,7 +90,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should continue" do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
end
@@ -100,7 +100,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should not continue" do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
end
end
@@ -112,7 +112,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should not continue" do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
end
@@ -123,22 +123,22 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should continue" do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
end
describe 'after running a command which timed out' do
before do
@conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false")
- Chef::GuardInterpreter::DefaultGuardInterpreter.any_instance.stub(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
+ allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout)
end
it 'indicates that resource convergence should continue' do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
it 'should log a warning' do
- Chef::Log.should_receive(:warn).with("Command 'false' timed out")
+ expect(Chef::Log).to receive(:warn).with("Command 'false' timed out")
@conditional.continue?
end
end
@@ -149,7 +149,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should not continue" do
- @conditional.continue?.should be_false
+ expect(@conditional.continue?).to be_false
end
end
@@ -159,7 +159,7 @@ describe Chef::Resource::Conditional do
end
it "indicates that resource convergence should continue" do
- @conditional.continue?.should be_true
+ expect(@conditional.continue?).to be_true
end
end
end
diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb
index 6c55c8035a..834e08bba4 100644
--- a/spec/unit/resource/cookbook_file_spec.rb
+++ b/spec/unit/resource/cookbook_file_spec.rb
@@ -25,25 +25,25 @@ describe Chef::Resource::CookbookFile do
end
it "uses the name parameter for the source parameter" do
- @cookbook_file.name.should == 'sourcecode_tarball.tgz'
+ expect(@cookbook_file.name).to eq('sourcecode_tarball.tgz')
end
it "has a source parameter" do
@cookbook_file.name('config_file.conf')
- @cookbook_file.name.should == 'config_file.conf'
+ expect(@cookbook_file.name).to eq('config_file.conf')
end
it "defaults to a nil cookbook parameter (current cookbook will be used)" do
- @cookbook_file.cookbook.should be_nil
+ expect(@cookbook_file.cookbook).to be_nil
end
it "has a cookbook parameter" do
@cookbook_file.cookbook("munin")
- @cookbook_file.cookbook.should == 'munin'
+ expect(@cookbook_file.cookbook).to eq('munin')
end
it "sets the provider to Chef::Provider::CookbookFile" do
- @cookbook_file.provider.should == Chef::Provider::CookbookFile
+ expect(@cookbook_file.provider).to eq(Chef::Provider::CookbookFile)
end
describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do
@@ -68,21 +68,21 @@ describe Chef::Resource::CookbookFile do
state = @cookbook_file.state
if Chef::Platform.windows?
puts state
- state[:rights].should == [{:permissions => :read, :principals => "Everyone"}]
- state[:deny_rights].should == [{:permissions => :full_control, :principals => "Clumsy_Sam"}]
+ expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}])
+ expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}])
else
- state[:group].should == "wheel"
- state[:mode].should == "0664"
- state[:owner].should == "root"
+ expect(state[:group]).to eq("wheel")
+ expect(state[:mode]).to eq("0664")
+ expect(state[:owner]).to eq("root")
end
- state[:checksum].should == "1" * 64
+ expect(state[:checksum]).to eq("1" * 64)
end
it "returns the path as its identity" do
if Chef::Platform.windows?
- @cookbook_file.identity.should == "C:/temp/origin/file.txt"
+ expect(@cookbook_file.identity).to eq("C:/temp/origin/file.txt")
else
- @cookbook_file.identity.should == "/tmp/origin/file.txt"
+ expect(@cookbook_file.identity).to eq("/tmp/origin/file.txt")
end
end
end
diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb
index cf821e3d32..743552c1de 100644
--- a/spec/unit/resource/cron_spec.rb
+++ b/spec/unit/resource/cron_spec.rb
@@ -26,135 +26,135 @@ describe Chef::Resource::Cron do
end
it "should create a new Chef::Resource::Cron" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Cron)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Cron)
end
it "should have a name" do
- @resource.name.should eql("cronify")
+ expect(@resource.name).to eql("cronify")
end
it "should have a default action of 'create'" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
it "should accept create or delete for action" do
- lambda { @resource.action :create }.should_not raise_error
- lambda { @resource.action :delete }.should_not raise_error
- lambda { @resource.action :lolcat }.should raise_error(ArgumentError)
+ expect { @resource.action :create }.not_to raise_error
+ expect { @resource.action :delete }.not_to raise_error
+ expect { @resource.action :lolcat }.to raise_error(ArgumentError)
end
it "should allow you to set a command" do
@resource.command "/bin/true"
- @resource.command.should eql("/bin/true")
+ expect(@resource.command).to eql("/bin/true")
end
it "should allow you to set a user" do
@resource.user "daemon"
- @resource.user.should eql("daemon")
+ expect(@resource.user).to eql("daemon")
end
it "should allow you to specify the minute" do
@resource.minute "30"
- @resource.minute.should eql("30")
+ expect(@resource.minute).to eql("30")
end
it "should allow you to specify the hour" do
@resource.hour "6"
- @resource.hour.should eql("6")
+ expect(@resource.hour).to eql("6")
end
it "should allow you to specify the day" do
@resource.day "10"
- @resource.day.should eql("10")
+ expect(@resource.day).to eql("10")
end
it "should allow you to specify the month" do
@resource.month "10"
- @resource.month.should eql("10")
+ expect(@resource.month).to eql("10")
end
it "should allow you to specify the weekday" do
@resource.weekday "2"
- @resource.weekday.should eql("2")
+ expect(@resource.weekday).to eql("2")
end
it "should allow you to specify the mailto variable" do
@resource.mailto "test@example.com"
- @resource.mailto.should eql("test@example.com")
+ expect(@resource.mailto).to eql("test@example.com")
end
it "should allow you to specify the path" do
@resource.path "/usr/bin:/usr/sbin"
- @resource.path.should eql("/usr/bin:/usr/sbin")
+ expect(@resource.path).to eql("/usr/bin:/usr/sbin")
end
it "should allow you to specify the home directory" do
@resource.home "/root"
- @resource.home.should eql("/root")
+ expect(@resource.home).to eql("/root")
end
it "should allow you to specify the shell to run the command with" do
@resource.shell "/bin/zsh"
- @resource.shell.should eql("/bin/zsh")
+ expect(@resource.shell).to eql("/bin/zsh")
end
it "should allow you to specify environment variables hash" do
env = {"TEST" => "LOL"}
@resource.environment env
- @resource.environment.should eql(env)
+ expect(@resource.environment).to eql(env)
end
it "should allow * for all time and date values" do
[ "minute", "hour", "day", "month", "weekday" ].each do |x|
- @resource.send(x, "*").should eql("*")
+ expect(@resource.send(x, "*")).to eql("*")
end
end
it "should allow ranges for all time and date values" do
[ "minute", "hour", "day", "month", "weekday" ].each do |x|
- @resource.send(x, "1-2,5").should eql("1-2,5")
+ expect(@resource.send(x, "1-2,5")).to eql("1-2,5")
end
end
it "should have a default value of * for all time and date values" do
[ "minute", "hour", "day", "month", "weekday" ].each do |x|
- @resource.send(x).should eql("*")
+ expect(@resource.send(x)).to eql("*")
end
end
it "should have a default value of root for the user" do
- @resource.user.should eql("root")
+ expect(@resource.user).to eql("root")
end
it "should reject any minute over 59" do
- lambda { @resource.minute "60" }.should raise_error(RangeError)
+ expect { @resource.minute "60" }.to raise_error(RangeError)
end
it "should reject any hour over 23" do
- lambda { @resource.hour "24" }.should raise_error(RangeError)
+ expect { @resource.hour "24" }.to raise_error(RangeError)
end
it "should reject any day over 31" do
- lambda { @resource.day "32" }.should raise_error(RangeError)
+ expect { @resource.day "32" }.to raise_error(RangeError)
end
it "should reject any month over 12" do
- lambda { @resource.month "13" }.should raise_error(RangeError)
+ expect { @resource.month "13" }.to raise_error(RangeError)
end
describe "weekday" do
it "should reject any weekday over 7" do
- lambda { @resource.weekday "8" }.should raise_error(RangeError)
+ expect { @resource.weekday "8" }.to raise_error(RangeError)
end
it "should reject any symbols which don't represent day of week" do
- lambda { @resource.weekday :foo }.should raise_error(RangeError)
+ expect { @resource.weekday :foo }.to raise_error(RangeError)
end
end
it "should convert integer schedule values to a string" do
[ "minute", "hour", "day", "month", "weekday" ].each do |x|
- @resource.send(x, 5).should eql("5")
+ expect(@resource.send(x, 5)).to eql("5")
end
end
@@ -171,16 +171,16 @@ describe Chef::Resource::Cron do
it "describes the state" do
state = @resource.state
- state[:minute].should == "1"
- state[:hour].should == "2"
- state[:day].should == "3"
- state[:month].should == "4"
- state[:weekday].should == "5"
- state[:user].should == "root"
+ expect(state[:minute]).to eq("1")
+ expect(state[:hour]).to eq("2")
+ expect(state[:day]).to eq("3")
+ expect(state[:month]).to eq("4")
+ expect(state[:weekday]).to eq("5")
+ expect(state[:user]).to eq("root")
end
it "returns the command as its identity" do
- @resource.identity.should == "tackle"
+ expect(@resource.identity).to eq("tackle")
end
end
end
diff --git a/spec/unit/resource/csh_spec.rb b/spec/unit/resource/csh_spec.rb
index e1534a8f5f..5fb3b00507 100644
--- a/spec/unit/resource/csh_spec.rb
+++ b/spec/unit/resource/csh_spec.rb
@@ -25,16 +25,16 @@ describe Chef::Resource::Csh do
end
it "should create a new Chef::Resource::Csh" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Csh)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Csh)
end
it "should have a resource name of :csh" do
- @resource.resource_name.should eql(:csh)
+ expect(@resource.resource_name).to eql(:csh)
end
it "should have an interpreter of csh" do
- @resource.interpreter.should eql("csh")
+ expect(@resource.interpreter).to eql("csh")
end
end
diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb
index 914ea19030..6592fae26c 100644
--- a/spec/unit/resource/deploy_spec.rb
+++ b/spec/unit/resource/deploy_spec.rb
@@ -33,28 +33,28 @@ describe Chef::Resource::Deploy do
def resource_has_a_string_attribute(attr_name)
it "has a String attribute for #{attr_name.to_s}" do
@resource.send(attr_name, "this is a string")
- @resource.send(attr_name).should eql("this is a string")
- lambda {@resource.send(attr_name, 8675309)}.should raise_error(ArgumentError)
+ expect(@resource.send(attr_name)).to eql("this is a string")
+ expect {@resource.send(attr_name, 8675309)}.to raise_error(ArgumentError)
end
end
def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false})
it "has a Boolean attribute for #{attr_name.to_s}" do
- @resource.send(attr_name).should eql(opts[:defaults_to])
+ expect(@resource.send(attr_name)).to eql(opts[:defaults_to])
@resource.send(attr_name, !opts[:defaults_to])
- @resource.send(attr_name).should eql( !opts[:defaults_to] )
+ expect(@resource.send(attr_name)).to eql( !opts[:defaults_to] )
end
end
def resource_has_a_callback_attribute(attr_name)
it "has a Callback attribute #{attr_name}" do
callback_block = lambda { :noop }
- lambda {@resource.send(attr_name, &callback_block)}.should_not raise_error
- @resource.send(attr_name).should == callback_block
+ expect {@resource.send(attr_name, &callback_block)}.not_to raise_error
+ expect(@resource.send(attr_name)).to eq(callback_block)
callback_file = "path/to/callback.rb"
- lambda {@resource.send(attr_name, callback_file)}.should_not raise_error
- @resource.send(attr_name).should == callback_file
- lambda {@resource.send(attr_name, :this_is_fail)}.should raise_error(ArgumentError)
+ expect {@resource.send(attr_name, callback_file)}.not_to raise_error
+ expect(@resource.send(attr_name)).to eq(callback_file)
+ expect {@resource.send(attr_name, :this_is_fail)}.to raise_error(ArgumentError)
end
end
end
@@ -85,7 +85,7 @@ describe Chef::Resource::Deploy do
resource_has_a_boolean_attribute(:shallow_clone, :defaults_to=>false)
it "uses the first argument as the deploy directory" do
- @resource.deploy_to.should eql("/my/deploy/dir")
+ expect(@resource.deploy_to).to eql("/my/deploy/dir")
end
# For git, any revision, branch, tag, whatever is resolved to a SHA1 ref.
@@ -93,100 +93,100 @@ describe Chef::Resource::Deploy do
# Therefore, revision and branch ARE NOT SEPARATE THINGS
it "aliases #revision as #branch" do
@resource.branch "stable"
- @resource.revision.should eql("stable")
+ expect(@resource.revision).to eql("stable")
end
it "takes the SCM resource to use as a constant, and defaults to git" do
- @resource.scm_provider.should eql(Chef::Provider::Git)
+ expect(@resource.scm_provider).to eql(Chef::Provider::Git)
@resource.scm_provider Chef::Provider::Subversion
- @resource.scm_provider.should eql(Chef::Provider::Subversion)
+ expect(@resource.scm_provider).to eql(Chef::Provider::Subversion)
end
it "allows scm providers to be set via symbol" do
- @resource.scm_provider.should == Chef::Provider::Git
+ expect(@resource.scm_provider).to eq(Chef::Provider::Git)
@resource.scm_provider :subversion
- @resource.scm_provider.should == Chef::Provider::Subversion
+ expect(@resource.scm_provider).to eq(Chef::Provider::Subversion)
end
it "allows scm providers to be set via string" do
- @resource.scm_provider.should == Chef::Provider::Git
+ expect(@resource.scm_provider).to eq(Chef::Provider::Git)
@resource.scm_provider "subversion"
- @resource.scm_provider.should == Chef::Provider::Subversion
+ expect(@resource.scm_provider).to eq(Chef::Provider::Subversion)
end
it "has a boolean attribute for svn_force_export defaulting to false" do
- @resource.svn_force_export.should be_false
+ expect(@resource.svn_force_export).to be_false
@resource.svn_force_export true
- @resource.svn_force_export.should be_true
- lambda {@resource.svn_force_export(10053)}.should raise_error(ArgumentError)
+ expect(@resource.svn_force_export).to be_true
+ expect {@resource.svn_force_export(10053)}.to raise_error(ArgumentError)
end
it "takes arbitrary environment variables in a hash" do
@resource.environment "RAILS_ENV" => "production"
- @resource.environment.should == {"RAILS_ENV" => "production"}
+ expect(@resource.environment).to eq({"RAILS_ENV" => "production"})
end
it "takes string arguments to environment for backwards compat, setting RAILS_ENV, RACK_ENV, and MERB_ENV" do
@resource.environment "production"
- @resource.environment.should == {"RAILS_ENV"=>"production", "RACK_ENV"=>"production","MERB_ENV"=>"production"}
+ expect(@resource.environment).to eq({"RAILS_ENV"=>"production", "RACK_ENV"=>"production","MERB_ENV"=>"production"})
end
it "sets destination to $deploy_to/shared/$repository_cache" do
- @resource.destination.should eql("/my/deploy/dir/shared/cached-copy")
+ expect(@resource.destination).to eql("/my/deploy/dir/shared/cached-copy")
end
it "sets shared_path to $deploy_to/shared" do
- @resource.shared_path.should eql("/my/deploy/dir/shared")
+ expect(@resource.shared_path).to eql("/my/deploy/dir/shared")
end
it "sets current_path to $deploy_to/current" do
- @resource.current_path.should eql("/my/deploy/dir/current")
+ expect(@resource.current_path).to eql("/my/deploy/dir/current")
end
it "gets the current_path correct even if the shared_path is set (regression test)" do
@resource.shared_path
- @resource.current_path.should eql("/my/deploy/dir/current")
+ expect(@resource.current_path).to eql("/my/deploy/dir/current")
end
it "gives #depth as 5 if shallow clone is true, nil otherwise" do
- @resource.depth.should be_nil
+ expect(@resource.depth).to be_nil
@resource.shallow_clone true
- @resource.depth.should eql("5")
+ expect(@resource.depth).to eql("5")
end
it "aliases repo as repository" do
@resource.repository "git@github.com/opcode/cookbooks.git"
- @resource.repo.should eql("git@github.com/opcode/cookbooks.git")
+ expect(@resource.repo).to eql("git@github.com/opcode/cookbooks.git")
end
it "aliases git_ssh_wrapper as ssh_wrapper" do
@resource.ssh_wrapper "git_my_repo.sh"
- @resource.git_ssh_wrapper.should eql("git_my_repo.sh")
+ expect(@resource.git_ssh_wrapper).to eql("git_my_repo.sh")
end
it "has an Array attribute purge_before_symlink, default: log, tmp/pids, public/system" do
- @resource.purge_before_symlink.should == %w{ log tmp/pids public/system }
+ expect(@resource.purge_before_symlink).to eq(%w{ log tmp/pids public/system })
@resource.purge_before_symlink %w{foo bar baz}
- @resource.purge_before_symlink.should == %w{foo bar baz}
+ expect(@resource.purge_before_symlink).to eq(%w{foo bar baz})
end
it "has an Array attribute create_dirs_before_symlink, default: tmp, public, config" do
- @resource.create_dirs_before_symlink.should == %w{tmp public config}
+ expect(@resource.create_dirs_before_symlink).to eq(%w{tmp public config})
@resource.create_dirs_before_symlink %w{foo bar baz}
- @resource.create_dirs_before_symlink.should == %w{foo bar baz}
+ expect(@resource.create_dirs_before_symlink).to eq(%w{foo bar baz})
end
it 'has a Hash attribute symlinks, default: {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}' do
default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
- @resource.symlinks.should == default
+ expect(@resource.symlinks).to eq(default)
@resource.symlinks "foo" => "bar/baz"
- @resource.symlinks.should == {"foo" => "bar/baz"}
+ expect(@resource.symlinks).to eq({"foo" => "bar/baz"})
end
it 'has a Hash attribute symlink_before_migrate, default "config/database.yml" => "config/database.yml"' do
- @resource.symlink_before_migrate.should == {"config/database.yml" => "config/database.yml"}
+ expect(@resource.symlink_before_migrate).to eq({"config/database.yml" => "config/database.yml"})
@resource.symlink_before_migrate "wtf?" => "wtf is going on"
- @resource.symlink_before_migrate.should == {"wtf?" => "wtf is going on"}
+ expect(@resource.symlink_before_migrate).to eq({"wtf?" => "wtf is going on"})
end
resource_has_a_callback_attribute :before_migrate
@@ -196,55 +196,55 @@ describe Chef::Resource::Deploy do
it "aliases restart_command as restart" do
@resource.restart "foobaz"
- @resource.restart_command.should == "foobaz"
+ expect(@resource.restart_command).to eq("foobaz")
end
it "takes a block for the restart parameter" do
restart_like_this = lambda {p :noop}
@resource.restart(&restart_like_this)
- @resource.restart.should == restart_like_this
+ expect(@resource.restart).to eq(restart_like_this)
end
it "allows providers to be set with a full class name" do
@resource.provider Chef::Provider::Deploy::Timestamped
- @resource.provider.should == Chef::Provider::Deploy::Timestamped
+ expect(@resource.provider).to eq(Chef::Provider::Deploy::Timestamped)
end
it "allows deploy providers to be set via symbol" do
@resource.provider :revision
- @resource.provider.should == Chef::Provider::Deploy::Revision
+ expect(@resource.provider).to eq(Chef::Provider::Deploy::Revision)
end
it "allows deploy providers to be set via string" do
@resource.provider "revision"
- @resource.provider.should == Chef::Provider::Deploy::Revision
+ expect(@resource.provider).to eq(Chef::Provider::Deploy::Revision)
end
it "defaults keep_releases to 5" do
- @resource.keep_releases.should == 5
+ expect(@resource.keep_releases).to eq(5)
end
it "allows keep_releases to be set via integer" do
@resource.keep_releases 10
- @resource.keep_releases.should == 10
+ expect(@resource.keep_releases).to eq(10)
end
it "enforces a minimum keep_releases of 1" do
@resource.keep_releases 0
- @resource.keep_releases.should == 1
+ expect(@resource.keep_releases).to eq(1)
end
describe "when it has a timeout attribute" do
let(:ten_seconds) { 10 }
before { @resource.timeout(ten_seconds) }
it "stores this timeout" do
- @resource.timeout.should == ten_seconds
+ expect(@resource.timeout).to eq(ten_seconds)
end
end
describe "when it has no timeout attribute" do
it "should have no default timeout" do
- @resource.timeout.should be_nil
+ expect(@resource.timeout).to be_nil
end
end
@@ -266,12 +266,12 @@ describe Chef::Resource::Deploy do
it "describes its state" do
state = @resource.state
- state[:deploy_to].should == "/"
- state[:revision].should == "1.2.3"
+ expect(state[:deploy_to]).to eq("/")
+ expect(state[:revision]).to eq("1.2.3")
end
it "returns the repository URI as its identity" do
- @resource.identity.should == "http://uri.org"
+ expect(@resource.identity).to eq("http://uri.org")
end
end
diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb
index a42383c49e..c452b2a914 100644
--- a/spec/unit/resource/directory_spec.rb
+++ b/spec/unit/resource/directory_spec.rb
@@ -26,38 +26,38 @@ describe Chef::Resource::Directory do
end
it "should create a new Chef::Resource::Directory" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Directory)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Directory)
end
it "should have a name" do
- @resource.name.should eql("fakey_fakerton")
+ expect(@resource.name).to eql("fakey_fakerton")
end
it "should have a default action of 'create'" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
it "should accept create or delete for action" do
- lambda { @resource.action :create }.should_not raise_error
- lambda { @resource.action :delete }.should_not raise_error
- lambda { @resource.action :blues }.should raise_error(ArgumentError)
+ expect { @resource.action :create }.not_to raise_error
+ expect { @resource.action :delete }.not_to raise_error
+ expect { @resource.action :blues }.to raise_error(ArgumentError)
end
it "should use the object name as the path by default" do
- @resource.path.should eql("fakey_fakerton")
+ expect(@resource.path).to eql("fakey_fakerton")
end
it "should accept a string as the path" do
- lambda { @resource.path "/tmp" }.should_not raise_error
- @resource.path.should eql("/tmp")
- lambda { @resource.path Hash.new }.should raise_error(ArgumentError)
+ expect { @resource.path "/tmp" }.not_to raise_error
+ expect(@resource.path).to eql("/tmp")
+ expect { @resource.path Hash.new }.to raise_error(ArgumentError)
end
it "should allow you to have specify whether the action is recursive with true/false" do
- lambda { @resource.recursive true }.should_not raise_error
- lambda { @resource.recursive false }.should_not raise_error
- lambda { @resource.recursive "monkey" }.should raise_error(ArgumentError)
+ expect { @resource.recursive true }.not_to raise_error
+ expect { @resource.recursive false }.not_to raise_error
+ expect { @resource.recursive "monkey" }.to raise_error(ArgumentError)
end
describe "when it has group, mode, and owner" do
@@ -70,13 +70,13 @@ describe Chef::Resource::Directory do
it "describes its state" do
state = @resource.state
- state[:group].should == "wheel"
- state[:mode].should == "0664"
- state[:owner].should == "root"
+ expect(state[:group]).to eq("wheel")
+ expect(state[:mode]).to eq("0664")
+ expect(state[:owner]).to eq("root")
end
it "returns the directory path as its identity" do
- @resource.identity.should == "/tmp/foo/bar/"
+ expect(@resource.identity).to eq("/tmp/foo/bar/")
end
end
end
diff --git a/spec/unit/resource/easy_install_package_spec.rb b/spec/unit/resource/easy_install_package_spec.rb
index d3a5f4a0fe..c68b026b39 100644
--- a/spec/unit/resource/easy_install_package_spec.rb
+++ b/spec/unit/resource/easy_install_package_spec.rb
@@ -34,6 +34,6 @@ describe Chef::Resource::EasyInstallPackage, "initialize" do
it "should allow you to set the easy_install_binary attribute" do
@resource.easy_install_binary "/opt/local/bin/easy_install"
- @resource.easy_install_binary.should eql("/opt/local/bin/easy_install")
+ expect(@resource.easy_install_binary).to eql("/opt/local/bin/easy_install")
end
end
diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb
index a1f599400b..566827a27e 100644
--- a/spec/unit/resource/env_spec.rb
+++ b/spec/unit/resource/env_spec.rb
@@ -26,43 +26,43 @@ describe Chef::Resource::Env do
end
it "should create a new Chef::Resource::Env" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Env)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Env)
end
it "should have a name" do
- @resource.name.should eql("FOO")
+ expect(@resource.name).to eql("FOO")
end
it "should have a default action of 'create'" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
{ :create => false, :delete => false, :modify => false, :flibber => true }.each do |action,bad_value|
it "should #{bad_value ? 'not' : ''} accept #{action.to_s}" do
if bad_value
- lambda { @resource.action action }.should raise_error(ArgumentError)
+ expect { @resource.action action }.to raise_error(ArgumentError)
else
- lambda { @resource.action action }.should_not raise_error
+ expect { @resource.action action }.not_to raise_error
end
end
end
it "should use the object name as the key_name by default" do
- @resource.key_name.should eql("FOO")
+ expect(@resource.key_name).to eql("FOO")
end
it "should accept a string as the env value via 'value'" do
- lambda { @resource.value "bar" }.should_not raise_error
+ expect { @resource.value "bar" }.not_to raise_error
end
it "should not accept a Hash for the env value via 'to'" do
- lambda { @resource.value Hash.new }.should raise_error(ArgumentError)
+ expect { @resource.value Hash.new }.to raise_error(ArgumentError)
end
it "should allow you to set an env value via 'to'" do
@resource.value "bar"
- @resource.value.should eql("bar")
+ expect(@resource.value).to eql("bar")
end
describe "when it has key name and value" do
@@ -74,11 +74,11 @@ describe Chef::Resource::Env do
it "describes its state" do
state = @resource.state
- state[:value].should == "level7"
+ expect(state[:value]).to eq("level7")
end
it "returns the key name as its identity" do
- @resource.identity.should == "charmander"
+ expect(@resource.identity).to eq("charmander")
end
end
diff --git a/spec/unit/resource/erl_call_spec.rb b/spec/unit/resource/erl_call_spec.rb
index 3efbdca9a0..8ec182665f 100644
--- a/spec/unit/resource/erl_call_spec.rb
+++ b/spec/unit/resource/erl_call_spec.rb
@@ -26,45 +26,45 @@ describe Chef::Resource::ErlCall do
end
it "should create a new Chef::Resource::ErlCall" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::ErlCall)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::ErlCall)
end
it "should have a resource name of :erl_call" do
- @resource.resource_name.should eql(:erl_call)
+ expect(@resource.resource_name).to eql(:erl_call)
end
it "should have a default action of run" do
- @resource.action.should eql("run")
+ expect(@resource.action).to eql("run")
end
it "should accept run as an action" do
- lambda { @resource.action :run }.should_not raise_error
+ expect { @resource.action :run }.not_to raise_error
end
it "should allow you to set the code attribute" do
@resource.code "q()."
- @resource.code.should eql("q().")
+ expect(@resource.code).to eql("q().")
end
it "should allow you to set the cookie attribute" do
@resource.cookie "nomnomnom"
- @resource.cookie.should eql("nomnomnom")
+ expect(@resource.cookie).to eql("nomnomnom")
end
it "should allow you to set the distributed attribute" do
@resource.distributed true
- @resource.distributed.should eql(true)
+ expect(@resource.distributed).to eql(true)
end
it "should allow you to set the name_type attribute" do
@resource.name_type "sname"
- @resource.name_type.should eql("sname")
+ expect(@resource.name_type).to eql("sname")
end
it "should allow you to set the node_name attribute" do
@resource.node_name "chef@erlang"
- @resource.node_name.should eql("chef@erlang")
+ expect(@resource.node_name).to eql("chef@erlang")
end
describe "when it has cookie and node_name" do
@@ -75,7 +75,7 @@ describe Chef::Resource::ErlCall do
end
it "returns the code as its identity" do
- @resource.identity.should == "erl-call:function()"
+ expect(@resource.identity).to eq("erl-call:function()")
end
end
end
diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb
index e1728b7892..70b9d87d4c 100644
--- a/spec/unit/resource/execute_spec.rb
+++ b/spec/unit/resource/execute_spec.rb
@@ -25,7 +25,7 @@ describe Chef::Resource::Execute do
it_behaves_like "an execute resource"
it "default guard interpreter should be :execute interpreter" do
- execute_resource.guard_interpreter.should be(:execute)
+ expect(execute_resource.guard_interpreter).to be(:execute)
end
end
diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb
index 9c6365f6d3..cfa7511673 100644
--- a/spec/unit/resource/file_spec.rb
+++ b/spec/unit/resource/file_spec.rb
@@ -25,55 +25,55 @@ describe Chef::Resource::File do
end
it "should have a name" do
- @resource.name.should eql("fakey_fakerton")
+ expect(@resource.name).to eql("fakey_fakerton")
end
it "should have a default action of 'create'" do
- @resource.action.should eql("create")
+ expect(@resource.action).to eql("create")
end
it "should have a default content of nil" do
- @resource.content.should be_nil
+ expect(@resource.content).to be_nil
end
it "should be set to back up 5 files by default" do
- @resource.backup.should eql(5)
+ expect(@resource.backup).to eql(5)
end
it "should only accept strings for content" do
- lambda { @resource.content 5 }.should raise_error(ArgumentError)
- lambda { @resource.content :foo }.should raise_error(ArgumentError)
- lambda { @resource.content "hello" => "there" }.should raise_error(ArgumentError)
- lambda { @resource.content "hi" }.should_not raise_error
+ expect { @resource.content 5 }.to raise_error(ArgumentError)
+ expect { @resource.content :foo }.to raise_error(ArgumentError)
+ expect { @resource.content "hello" => "there" }.to raise_error(ArgumentError)
+ expect { @resource.content "hi" }.not_to raise_error
end
it "should only accept false or a number for backup" do
- lambda { @resource.backup true }.should raise_error(ArgumentError)
- lambda { @resource.backup false }.should_not raise_error
- lambda { @resource.backup 10 }.should_not raise_error
- lambda { @resource.backup "blues" }.should raise_error(ArgumentError)
+ expect { @resource.backup true }.to raise_error(ArgumentError)
+ expect { @resource.backup false }.not_to raise_error
+ expect { @resource.backup 10 }.not_to raise_error
+ expect { @resource.backup "blues" }.to raise_error(ArgumentError)
end
it "should accept a sha256 for checksum" do
- lambda { @resource.checksum "0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa" }.should_not raise_error
- lambda { @resource.checksum "monkey!" }.should raise_error(ArgumentError)
+ expect { @resource.checksum "0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa" }.not_to raise_error
+ expect { @resource.checksum "monkey!" }.to raise_error(ArgumentError)
end
it "should accept create, delete or touch for action" do
- lambda { @resource.action :create }.should_not raise_error
- lambda { @resource.action :delete }.should_not raise_error
- lambda { @resource.action :touch }.should_not raise_error
- lambda { @resource.action :blues }.should raise_error(ArgumentError)
+ expect { @resource.action :create }.not_to raise_error
+ expect { @resource.action :delete }.not_to raise_error
+ expect { @resource.action :touch }.not_to raise_error
+ expect { @resource.action :blues }.to raise_error(ArgumentError)
end
it "should use the object name as the path by default" do
- @resource.path.should eql("fakey_fakerton")
+ expect(@resource.path).to eql("fakey_fakerton")
end
it "should accept a string as the path" do
- lambda { @resource.path "/tmp" }.should_not raise_error
- @resource.path.should eql("/tmp")
- lambda { @resource.path Hash.new }.should raise_error(ArgumentError)
+ expect { @resource.path "/tmp" }.not_to raise_error
+ expect(@resource.path).to eql("/tmp")
+ expect { @resource.path Hash.new }.to raise_error(ArgumentError)
end
describe "when it has a path, owner, group, mode, and checksum" do
@@ -88,15 +88,15 @@ describe Chef::Resource::File do
context "on unix", :unix_only do
it "describes its state" do
state = @resource.state
- state[:owner].should == "root"
- state[:group].should == "wheel"
- state[:mode].should == "0644"
- state[:checksum].should == "1" * 64
+ expect(state[:owner]).to eq("root")
+ expect(state[:group]).to eq("wheel")
+ expect(state[:mode]).to eq("0644")
+ expect(state[:checksum]).to eq("1" * 64)
end
end
it "returns the file path as its identity" do
- @resource.identity.should == "/tmp/foo.txt"
+ expect(@resource.identity).to eq("/tmp/foo.txt")
end
end
@@ -108,8 +108,8 @@ describe Chef::Resource::File do
end
it "describes its state including windows ACL attributes" do
state = @resource.state
- state[:rights].should == [ {:permissions => :read, :principals => "Everyone"},
- {:permissions => :full_control, :principals => "DOMAIN\User"} ]
+ expect(state[:rights]).to eq([ {:permissions => :read, :principals => "Everyone"},
+ {:permissions => :full_control, :principals => "DOMAIN\User"} ])
end
end
diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb
index 04a6962270..7263d3a7ba 100644
--- a/spec/unit/resource/freebsd_package_spec.rb
+++ b/spec/unit/resource/freebsd_package_spec.rb
@@ -32,15 +32,15 @@ describe Chef::Resource::FreebsdPackage do
describe "Initialization" do
it "should return a Chef::Resource::FreebsdPackage" do
- @resource.should be_a_kind_of(Chef::Resource::FreebsdPackage)
+ expect(@resource).to be_a_kind_of(Chef::Resource::FreebsdPackage)
end
it "should set the resource_name to :freebsd_package" do
- @resource.resource_name.should eql(:freebsd_package)
+ expect(@resource.resource_name).to eql(:freebsd_package)
end
it "should not set the provider" do
- @resource.provider.should be_nil
+ expect(@resource.provider).to be_nil
end
end
@@ -50,7 +50,7 @@ describe Chef::Resource::FreebsdPackage do
it "should be Freebsd::Port" do
@resource.source('ports')
@resource.after_created
- @resource.provider.should == Chef::Provider::Package::Freebsd::Port
+ expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Port)
end
end
@@ -59,7 +59,7 @@ describe Chef::Resource::FreebsdPackage do
[1000017, 1000018, 1000500, 1001001, 1100000].each do |__freebsd_version|
@node.automatic_attrs[:os_version] = __freebsd_version
@resource.after_created
- @resource.provider.should == Chef::Provider::Package::Freebsd::Pkgng
+ expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng)
end
end
end
@@ -67,21 +67,21 @@ describe Chef::Resource::FreebsdPackage do
describe "if pkgng enabled" do
it "should be Freebsd::Pkgng" do
pkg_enabled = OpenStruct.new(:stdout => "yes\n")
- @resource.stub(:shell_out!).with("make -V WITH_PKGNG", :env => nil).and_return(pkg_enabled)
+ allow(@resource).to receive(:shell_out!).with("make -V WITH_PKGNG", :env => nil).and_return(pkg_enabled)
@resource.after_created
- @resource.provider.should == Chef::Provider::Package::Freebsd::Pkgng
+ expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkgng)
end
end
describe "if __Freebsd_version is less than 1000017 and pkgng not enabled" do
it "should be Freebsd::Pkg" do
pkg_enabled = OpenStruct.new(:stdout => "\n")
- @resource.stub(:shell_out!).with("make -V WITH_PKGNG", :env => nil).and_return(pkg_enabled)
+ allow(@resource).to receive(:shell_out!).with("make -V WITH_PKGNG", :env => nil).and_return(pkg_enabled)
[1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version|
@node.automatic_attrs[:os_version] = __freebsd_version
@resource.after_created
- @resource.provider.should == Chef::Provider::Package::Freebsd::Pkg
+ expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Pkg)
end
end
end
diff --git a/spec/unit/resource/gem_package_spec.rb b/spec/unit/resource/gem_package_spec.rb
index 01c4fb6106..0f3eae70bb 100644
--- a/spec/unit/resource/gem_package_spec.rb
+++ b/spec/unit/resource/gem_package_spec.rb
@@ -37,6 +37,6 @@ describe Chef::Resource::GemPackage, "gem_binary" do
it "should set the gem_binary variable to whatever is passed in" do
@resource.gem_binary("/opt/local/bin/gem")
- @resource.gem_binary.should eql("/opt/local/bin/gem")
+ expect(@resource.gem_binary).to eql("/opt/local/bin/gem")
end
end
diff --git a/spec/unit/resource/git_spec.rb b/spec/unit/resource/git_spec.rb
index da7aee1014..6a39b3d172 100644
--- a/spec/unit/resource/git_spec.rb
+++ b/spec/unit/resource/git_spec.rb
@@ -33,18 +33,18 @@ describe Chef::Resource::Git do
end
it "is a kind of Scm Resource" do
- @git.should be_a_kind_of(Chef::Resource::Scm)
- @git.should be_an_instance_of(Chef::Resource::Git)
+ expect(@git).to be_a_kind_of(Chef::Resource::Scm)
+ expect(@git).to be_an_instance_of(Chef::Resource::Git)
end
it "uses aliases revision as branch" do
@git.branch "HEAD"
- @git.revision.should eql("HEAD")
+ expect(@git.revision).to eql("HEAD")
end
it "aliases revision as reference" do
@git.reference "v1.0 tag"
- @git.revision.should eql("v1.0 tag")
+ expect(@git.revision).to eql("v1.0 tag")
end
end
diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb
index 0c3cf4f67f..bcf9205f7e 100644
--- a/spec/unit/resource/group_spec.rb
+++ b/spec/unit/resource/group_spec.rb
@@ -25,47 +25,47 @@ describe Chef::Resource::Group, "initialize" do
end
it "should create a new Chef::Resource::Group" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Group)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Group)
end
it "should set the resource_name to :group" do
- @resource.resource_name.should eql(:group)
+ expect(@resource.resource_name).to eql(:group)
end
it "should set the group_name equal to the argument to initialize" do
- @resource.group_name.should eql("admin")
+ expect(@resource.group_name).to eql("admin")
end
it "should default gid to nil" do
- @resource.gid.should eql(nil)
+ expect(@resource.gid).to eql(nil)
end
it "should default members to an empty array" do
- @resource.members.should eql([])
+ expect(@resource.members).to eql([])
end
it "should alias users to members, also an empty array" do
- @resource.users.should eql([])
+ expect(@resource.users).to eql([])
end
it "should set action to :create" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
%w{create remove modify manage}.each do |action|
it "should allow action #{action}" do
- @resource.allowed_actions.detect { |a| a == action.to_sym }.should eql(action.to_sym)
+ expect(@resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym)
end
end
it "should accept domain groups (@ or \ separator) on non-windows" do
- lambda { @resource.group_name "domain\@group" }.should_not raise_error
- @resource.group_name.should == "domain\@group"
- lambda { @resource.group_name "domain\\group" }.should_not raise_error
- @resource.group_name.should == "domain\\group"
- lambda { @resource.group_name "domain\\group^name" }.should_not raise_error
- @resource.group_name.should == "domain\\group^name"
+ expect { @resource.group_name "domain\@group" }.not_to raise_error
+ expect(@resource.group_name).to eq("domain\@group")
+ expect { @resource.group_name "domain\\group" }.not_to raise_error
+ expect(@resource.group_name).to eq("domain\\group")
+ expect { @resource.group_name "domain\\group^name" }.not_to raise_error
+ expect(@resource.group_name).to eq("domain\\group^name")
end
end
@@ -76,11 +76,11 @@ describe Chef::Resource::Group, "group_name" do
it "should allow a string" do
@resource.group_name "pirates"
- @resource.group_name.should eql("pirates")
+ expect(@resource.group_name).to eql("pirates")
end
it "should not allow a hash" do
- lambda { @resource.send(:group_name, { :aj => "is freakin awesome" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(:group_name, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
@@ -91,11 +91,11 @@ describe Chef::Resource::Group, "gid" do
it "should allow an integer" do
@resource.gid 100
- @resource.gid.should eql(100)
+ expect(@resource.gid).to eql(100)
end
it "should not allow a hash" do
- lambda { @resource.send(:gid, { :aj => "is freakin awesome" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
@@ -107,16 +107,16 @@ describe Chef::Resource::Group, "members" do
[ :users, :members].each do |method|
it "(#{method}) should allow and convert a string" do
@resource.send(method, "aj")
- @resource.send(method).should eql(["aj"])
+ expect(@resource.send(method)).to eql(["aj"])
end
it "(#{method}) should allow an array" do
@resource.send(method, [ "aj", "adam" ])
- @resource.send(method).should eql( ["aj", "adam"] )
+ expect(@resource.send(method)).to eql( ["aj", "adam"] )
end
it "(#{method}) should not allow a hash" do
- lambda { @resource.send(method, { :aj => "is freakin awesome" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(method, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
end
end
end
@@ -127,16 +127,16 @@ describe Chef::Resource::Group, "append" do
end
it "should default to false" do
- @resource.append.should eql(false)
+ expect(@resource.append).to eql(false)
end
it "should allow a boolean" do
@resource.append true
- @resource.append.should eql(true)
+ expect(@resource.append).to eql(true)
end
it "should not allow a hash" do
- lambda { @resource.send(:gid, { :aj => "is freakin awesome" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(:gid, { :aj => "is freakin awesome" }) }.to raise_error(ArgumentError)
end
describe "when it has members" do
@@ -147,11 +147,11 @@ describe Chef::Resource::Group, "append" do
it "describes its state" do
state = @resource.state
- state[:members].should eql(["blastoise", "pikachu"])
+ expect(state[:members]).to eql(["blastoise", "pikachu"])
end
it "returns the group name as its identity" do
- @resource.identity.should == "pokemon"
+ expect(@resource.identity).to eq("pokemon")
end
end
end
diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb
index b636ca9994..aa4ce4dfbc 100644
--- a/spec/unit/resource/http_request_spec.rb
+++ b/spec/unit/resource/http_request_spec.rb
@@ -26,22 +26,22 @@ describe Chef::Resource::HttpRequest do
end
it "should create a new Chef::Resource::HttpRequest" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::HttpRequest)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::HttpRequest)
end
it "should set url to a string" do
@resource.url "http://slashdot.org"
- @resource.url.should eql("http://slashdot.org")
+ expect(@resource.url).to eql("http://slashdot.org")
end
it "should set the message to the name by default" do
- @resource.message.should eql("fakey_fakerton")
+ expect(@resource.message).to eql("fakey_fakerton")
end
it "should set message to a string" do
@resource.message "monkeybars"
- @resource.message.should eql("monkeybars")
+ expect(@resource.message).to eql("monkeybars")
end
describe "when it has a message and headers" do
@@ -52,7 +52,7 @@ describe Chef::Resource::HttpRequest do
end
it "returns the url as its identity" do
- @resource.identity.should == "http://www.trololol.net"
+ expect(@resource.identity).to eq("http://www.trololol.net")
end
end
diff --git a/spec/unit/resource/ifconfig_spec.rb b/spec/unit/resource/ifconfig_spec.rb
index 10a4d09982..ea5282acd5 100644
--- a/spec/unit/resource/ifconfig_spec.rb
+++ b/spec/unit/resource/ifconfig_spec.rb
@@ -38,12 +38,12 @@ describe Chef::Resource::Ifconfig do
it "describes its state" do
state = @resource.state
- state[:inet_addr].should == "434.2343.23"
- state[:mask].should == "255.255.545"
+ expect(state[:inet_addr]).to eq("434.2343.23")
+ expect(state[:mask]).to eq("255.255.545")
end
it "returns the device as its identity" do
- @resource.identity.should == "charmander"
+ expect(@resource.identity).to eq("charmander")
end
end
@@ -54,9 +54,9 @@ describe Chef::Resource::Ifconfig do
end
it "should use an ordinary Provider::Ifconfig as a provider for #{platform} #{version}" do
- @resource.provider_for_action(:add).should be_a_kind_of(Chef::Provider::Ifconfig)
- @resource.provider_for_action(:add).should_not be_a_kind_of(Chef::Provider::Ifconfig::Debian)
- @resource.provider_for_action(:add).should_not be_a_kind_of(Chef::Provider::Ifconfig::Redhat)
+ expect(@resource.provider_for_action(:add)).to be_a_kind_of(Chef::Provider::Ifconfig)
+ expect(@resource.provider_for_action(:add)).not_to be_a_kind_of(Chef::Provider::Ifconfig::Debian)
+ expect(@resource.provider_for_action(:add)).not_to be_a_kind_of(Chef::Provider::Ifconfig::Redhat)
end
end
@@ -67,7 +67,7 @@ describe Chef::Resource::Ifconfig do
end
it "should use an Provider::Ifconfig::Redhat as a provider for #{platform} #{version}" do
- @resource.provider_for_action(:add).should be_a_kind_of(Chef::Provider::Ifconfig::Redhat)
+ expect(@resource.provider_for_action(:add)).to be_a_kind_of(Chef::Provider::Ifconfig::Redhat)
end
end
@@ -78,7 +78,7 @@ describe Chef::Resource::Ifconfig do
end
it "should use an Ifconfig::Debian as a provider for #{platform} #{version}" do
- @resource.provider_for_action(:add).should be_a_kind_of(Chef::Provider::Ifconfig::Debian)
+ expect(@resource.provider_for_action(:add)).to be_a_kind_of(Chef::Provider::Ifconfig::Debian)
end
end
diff --git a/spec/unit/resource/ips_package_spec.rb b/spec/unit/resource/ips_package_spec.rb
index 8718c5c093..126ae00224 100644
--- a/spec/unit/resource/ips_package_spec.rb
+++ b/spec/unit/resource/ips_package_spec.rb
@@ -35,6 +35,6 @@ describe Chef::Resource::IpsPackage, "initialize" do
it "should support accept_license" do
@resource.accept_license(true)
- @resource.accept_license.should eql(true)
+ expect(@resource.accept_license).to eql(true)
end
end
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index 221617f9b3..3573a15f31 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -22,78 +22,78 @@ require 'spec_helper'
describe Chef::Resource::Link do
before(:each) do
- Chef::Resource::Link.any_instance.should_receive(:verify_links_supported!).and_return(true)
+ expect_any_instance_of(Chef::Resource::Link).to receive(:verify_links_supported!).and_return(true)
@resource = Chef::Resource::Link.new("fakey_fakerton")
end
it "should create a new Chef::Resource::Link" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Link)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Link)
end
it "should have a name" do
- @resource.name.should eql("fakey_fakerton")
+ expect(@resource.name).to eql("fakey_fakerton")
end
it "should have a default action of 'create'" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
{ :create => false, :delete => false, :blues => true }.each do |action,bad_value|
it "should #{bad_value ? 'not' : ''} accept #{action.to_s}" do
if bad_value
- lambda { @resource.action action }.should raise_error(ArgumentError)
+ expect { @resource.action action }.to raise_error(ArgumentError)
else
- lambda { @resource.action action }.should_not raise_error
+ expect { @resource.action action }.not_to raise_error
end
end
end
it "should use the object name as the target_file by default" do
- @resource.target_file.should eql("fakey_fakerton")
+ expect(@resource.target_file).to eql("fakey_fakerton")
end
it "should accept a string as the link source via 'to'" do
- lambda { @resource.to "/tmp" }.should_not raise_error
+ expect { @resource.to "/tmp" }.not_to raise_error
end
it "should not accept a Hash for the link source via 'to'" do
- lambda { @resource.to Hash.new }.should raise_error(ArgumentError)
+ expect { @resource.to Hash.new }.to raise_error(ArgumentError)
end
it "should allow you to set a link source via 'to'" do
@resource.to "/tmp/foo"
- @resource.to.should eql("/tmp/foo")
+ expect(@resource.to).to eql("/tmp/foo")
end
it "should allow you to specify the link type" do
@resource.link_type "symbolic"
- @resource.link_type.should eql(:symbolic)
+ expect(@resource.link_type).to eql(:symbolic)
end
it "should default to a symbolic link" do
- @resource.link_type.should eql(:symbolic)
+ expect(@resource.link_type).to eql(:symbolic)
end
it "should accept a hard link_type" do
@resource.link_type :hard
- @resource.link_type.should eql(:hard)
+ expect(@resource.link_type).to eql(:hard)
end
it "should reject any other link_type but :hard and :symbolic" do
- lambda { @resource.link_type "x-men" }.should raise_error(ArgumentError)
+ expect { @resource.link_type "x-men" }.to raise_error(ArgumentError)
end
it "should accept a group name or id for group" do
- lambda { @resource.group "root" }.should_not raise_error
- lambda { @resource.group 123 }.should_not raise_error
- lambda { @resource.group "root:goo" }.should raise_error(ArgumentError)
+ expect { @resource.group "root" }.not_to raise_error
+ expect { @resource.group 123 }.not_to raise_error
+ expect { @resource.group "root:goo" }.to raise_error(ArgumentError)
end
it "should accept a user name or id for owner" do
- lambda { @resource.owner "root" }.should_not raise_error
- lambda { @resource.owner 123 }.should_not raise_error
- lambda { @resource.owner "root:goo" }.should raise_error(ArgumentError)
+ expect { @resource.owner "root" }.not_to raise_error
+ expect { @resource.owner 123 }.not_to raise_error
+ expect { @resource.owner "root:goo" }.to raise_error(ArgumentError)
end
describe "when it has to, link_type, owner, and group" do
@@ -107,13 +107,13 @@ describe Chef::Resource::Link do
it "describes its state" do
state = @resource.state
- state[:to].should == "/to/dir/file.tar"
- state[:owner].should == "root"
- state[:group].should == "0664"
+ expect(state[:to]).to eq("/to/dir/file.tar")
+ expect(state[:owner]).to eq("root")
+ expect(state[:group]).to eq("0664")
end
it "returns the target file as its identity" do
- @resource.identity.should == "/var/target.tar"
+ expect(@resource.identity).to eq("/var/target.tar")
end
end
end
diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb
index c0201e57f3..b2af194238 100644
--- a/spec/unit/resource/log_spec.rb
+++ b/spec/unit/resource/log_spec.rb
@@ -27,29 +27,29 @@ describe Chef::Resource::Log do
end
it "should create a new Chef::Resource::Log" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Log)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Log)
end
it "supports the :write actions" do
- @resource.allowed_actions.should include(:write)
+ expect(@resource.allowed_actions).to include(:write)
end
it "should have a name of log" do
- @resource.resource_name.should == :log
+ expect(@resource.resource_name).to eq(:log)
end
it "should allow you to set a log string" do
- @resource.name.should == @log_str
+ expect(@resource.name).to eq(@log_str)
end
it "should set the message to the first argument to new" do
- @resource.message.should == @log_str
+ expect(@resource.message).to eq(@log_str)
end
it "should accept a string for the log message" do
@resource.message "this is different"
- @resource.message.should == "this is different"
+ expect(@resource.message).to eq("this is different")
end
it "should accept a vaild level option" do
@@ -58,7 +58,7 @@ describe Chef::Resource::Log do
@resource.level :warn
@resource.level :error
@resource.level :fatal
- lambda { @resource.level :unsupported }.should raise_error(ArgumentError)
+ expect { @resource.level :unsupported }.to raise_error(ArgumentError)
end
describe "when the identity is defined" do
@@ -67,7 +67,7 @@ describe Chef::Resource::Log do
end
it "returns the log string as its identity" do
- @resource.identity.should == "ery day I'm loggin-in"
+ expect(@resource.identity).to eq("ery day I'm loggin-in")
end
end
end
diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb
index daf10bcfea..866309ec5b 100644
--- a/spec/unit/resource/mdadm_spec.rb
+++ b/spec/unit/resource/mdadm_spec.rb
@@ -26,57 +26,57 @@ describe Chef::Resource::Mdadm do
end
it "should create a new Chef::Resource::Mdadm" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Mdadm)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Mdadm)
end
it "should have a resource name of :mdadm" do
- @resource.resource_name.should eql(:mdadm)
+ expect(@resource.resource_name).to eql(:mdadm)
end
it "should have a default action of create" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
it "should accept create, assemble, stop as actions" do
- lambda { @resource.action :create }.should_not raise_error
- lambda { @resource.action :assemble }.should_not raise_error
- lambda { @resource.action :stop }.should_not raise_error
+ expect { @resource.action :create }.not_to raise_error
+ expect { @resource.action :assemble }.not_to raise_error
+ expect { @resource.action :stop }.not_to raise_error
end
it "should allow you to set the raid_device attribute" do
@resource.raid_device "/dev/md3"
- @resource.raid_device.should eql("/dev/md3")
+ expect(@resource.raid_device).to eql("/dev/md3")
end
it "should allow you to set the chunk attribute" do
@resource.chunk 256
- @resource.chunk.should eql(256)
+ expect(@resource.chunk).to eql(256)
end
it "should allow you to set the level attribute" do
@resource.level 1
- @resource.level.should eql(1)
+ expect(@resource.level).to eql(1)
end
it "should allow you to set the metadata attribute" do
@resource.metadata "1.2"
- @resource.metadata.should eql("1.2")
+ expect(@resource.metadata).to eql("1.2")
end
it "should allow you to set the bitmap attribute" do
@resource.metadata "internal"
- @resource.metadata.should eql("internal")
+ expect(@resource.metadata).to eql("internal")
end
it "should allow you to set the devices attribute" do
@resource.devices ["/dev/sda", "/dev/sdb"]
- @resource.devices.should eql(["/dev/sda", "/dev/sdb"])
+ expect(@resource.devices).to eql(["/dev/sda", "/dev/sdb"])
end
it "should allow you to set the exists attribute" do
@resource.exists true
- @resource.exists.should eql(true)
+ expect(@resource.exists).to eql(true)
end
describe "when it has devices, level, and chunk" do
@@ -89,13 +89,13 @@ describe Chef::Resource::Mdadm do
it "describes its state" do
state = @resource.state
- state[:devices].should eql(["device1", "device2"])
- state[:level].should == 1
- state[:chunk].should == 42
+ expect(state[:devices]).to eql(["device1", "device2"])
+ expect(state[:level]).to eq(1)
+ expect(state[:chunk]).to eq(42)
end
it "returns the raid device as its identity" do
- @resource.identity.should == "raider"
+ expect(@resource.identity).to eq("raider")
end
end
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index 0a154342c7..ad95c06e04 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -25,150 +25,150 @@ describe Chef::Resource::Mount do
end
it "should create a new Chef::Resource::Mount" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Mount)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Mount)
end
it "should have a name" do
- @resource.name.should eql("filesystem")
+ expect(@resource.name).to eql("filesystem")
end
it "should set mount_point to the name" do
- @resource.mount_point.should eql("filesystem")
+ expect(@resource.mount_point).to eql("filesystem")
end
it "should have a default action of mount" do
- @resource.action.should eql(:mount)
+ expect(@resource.action).to eql(:mount)
end
it "should accept mount, umount and remount as actions" do
- lambda { @resource.action :mount }.should_not raise_error
- lambda { @resource.action :umount }.should_not raise_error
- lambda { @resource.action :remount }.should_not raise_error
- lambda { @resource.action :brooklyn }.should raise_error(ArgumentError)
+ expect { @resource.action :mount }.not_to raise_error
+ expect { @resource.action :umount }.not_to raise_error
+ expect { @resource.action :remount }.not_to raise_error
+ expect { @resource.action :brooklyn }.to raise_error(ArgumentError)
end
it "should allow you to set the device attribute" do
@resource.device "/dev/sdb3"
- @resource.device.should eql("/dev/sdb3")
+ expect(@resource.device).to eql("/dev/sdb3")
end
it "should set fsck_device to '-' by default" do
- @resource.fsck_device.should eql('-')
+ expect(@resource.fsck_device).to eql('-')
end
it "should allow you to set the fsck_device attribute" do
@resource.fsck_device "/dev/rdsk/sdb3"
- @resource.fsck_device.should eql("/dev/rdsk/sdb3")
+ expect(@resource.fsck_device).to eql("/dev/rdsk/sdb3")
end
it "should allow you to set the fstype attribute" do
@resource.fstype "nfs"
- @resource.fstype.should eql("nfs")
+ expect(@resource.fstype).to eql("nfs")
end
it "should allow you to set the dump attribute" do
@resource.dump 1
- @resource.dump.should eql(1)
+ expect(@resource.dump).to eql(1)
end
it "should allow you to set the pass attribute" do
@resource.pass 1
- @resource.pass.should eql(1)
+ expect(@resource.pass).to eql(1)
end
it "should set the options attribute to defaults" do
- @resource.options.should eql(["defaults"])
+ expect(@resource.options).to eql(["defaults"])
end
it "should allow options to be sent as a string, and convert to array" do
@resource.options "rw,noexec"
- @resource.options.should be_a_kind_of(Array)
+ expect(@resource.options).to be_a_kind_of(Array)
end
it "should allow options attribute as an array" do
@resource.options ["ro", "nosuid"]
- @resource.options.should be_a_kind_of(Array)
+ expect(@resource.options).to be_a_kind_of(Array)
end
it "should allow options to be sent as a delayed evaluator" do
@resource.options Chef::DelayedEvaluator.new {["rw", "noexec"]}
- @resource.options.should eql(["rw", "noexec"])
+ expect(@resource.options).to eql(["rw", "noexec"])
end
it "should allow options to be sent as a delayed evaluator, and convert to array" do
@resource.options Chef::DelayedEvaluator.new {"rw,noexec"}
- @resource.options.should be_a_kind_of(Array)
- @resource.options.should eql(["rw", "noexec"])
+ expect(@resource.options).to be_a_kind_of(Array)
+ expect(@resource.options).to eql(["rw", "noexec"])
end
it "should accept true for mounted" do
@resource.mounted(true)
- @resource.mounted.should eql(true)
+ expect(@resource.mounted).to eql(true)
end
it "should accept false for mounted" do
@resource.mounted(false)
- @resource.mounted.should eql(false)
+ expect(@resource.mounted).to eql(false)
end
it "should set mounted to false by default" do
- @resource.mounted.should eql(false)
+ expect(@resource.mounted).to eql(false)
end
it "should not accept a string for mounted" do
- lambda { @resource.mounted("poop") }.should raise_error(ArgumentError)
+ expect { @resource.mounted("poop") }.to raise_error(ArgumentError)
end
it "should accept true for enabled" do
@resource.enabled(true)
- @resource.enabled.should eql(true)
+ expect(@resource.enabled).to eql(true)
end
it "should accept false for enabled" do
@resource.enabled(false)
- @resource.enabled.should eql(false)
+ expect(@resource.enabled).to eql(false)
end
it "should set enabled to false by default" do
- @resource.enabled.should eql(false)
+ expect(@resource.enabled).to eql(false)
end
it "should not accept a string for enabled" do
- lambda { @resource.enabled("poop") }.should raise_error(ArgumentError)
+ expect { @resource.enabled("poop") }.to raise_error(ArgumentError)
end
it "should default all feature support to false" do
support_hash = { :remount => false }
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
it "should allow you to set feature support as an array" do
support_array = [ :remount ]
support_hash = { :remount => true }
@resource.supports(support_array)
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
it "should allow you to set feature support as a hash" do
support_hash = { :remount => true }
@resource.supports(support_hash)
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
it "should allow you to set username" do
@resource.username("Administrator")
- @resource.username.should == "Administrator"
+ expect(@resource.username).to eq("Administrator")
end
it "should allow you to set password" do
@resource.password("Jetstream123!")
- @resource.password.should == "Jetstream123!"
+ expect(@resource.password).to eq("Jetstream123!")
end
it "should allow you to set domain" do
@resource.domain("TEST_DOMAIN")
- @resource.domain.should == "TEST_DOMAIN"
+ expect(@resource.domain).to eq("TEST_DOMAIN")
end
describe "when it has mount point, device type, and fstype" do
@@ -181,13 +181,13 @@ describe Chef::Resource::Mount do
it "describes its state" do
state = @resource.state
- state[:mount_point].should == "123.456"
- state[:device_type].should eql(:device)
- state[:fstype].should == "ranked"
+ expect(state[:mount_point]).to eq("123.456")
+ expect(state[:device_type]).to eql(:device)
+ expect(state[:fstype]).to eq("ranked")
end
it "returns the device as its identity" do
- @resource.identity.should == "charmander"
+ expect(@resource.identity).to eq("charmander")
end
end
@@ -202,12 +202,12 @@ describe Chef::Resource::Mount do
it "describes its state" do
state = @resource.state
- state[:mount_point].should == "T:"
- state[:username].should == "Administrator"
- state[:password].should == "Jetstream123!"
- state[:domain].should == "TEST_DOMAIN"
- state[:device_type].should eql(:device)
- state[:fstype].should == "auto"
+ expect(state[:mount_point]).to eq("T:")
+ expect(state[:username]).to eq("Administrator")
+ expect(state[:password]).to eq("Jetstream123!")
+ expect(state[:domain]).to eq("TEST_DOMAIN")
+ expect(state[:device_type]).to eql(:device)
+ expect(state[:fstype]).to eq("auto")
end
end
diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb
index b8d062b4c9..fe29755abf 100644
--- a/spec/unit/resource/ohai_spec.rb
+++ b/spec/unit/resource/ohai_spec.rb
@@ -25,21 +25,21 @@ describe Chef::Resource::Ohai do
end
it "should create a new Chef::Resource::Ohai" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Ohai)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Ohai)
end
it "should have a resource name of :ohai" do
- @resource.resource_name.should eql(:ohai)
+ expect(@resource.resource_name).to eql(:ohai)
end
it "should have a default action of create" do
- @resource.action.should eql(:reload)
+ expect(@resource.action).to eql(:reload)
end
it "should allow you to set the plugin attribute" do
@resource.plugin "passwd"
- @resource.plugin.should eql("passwd")
+ expect(@resource.plugin).to eql("passwd")
end
describe "when it has a plugin value" do
@@ -50,11 +50,11 @@ describe Chef::Resource::Ohai do
it "describes its state" do
state = @resource.state
- state[:plugin].should == "passwd"
+ expect(state[:plugin]).to eq("passwd")
end
it "returns the name as its identity" do
- @resource.identity.should == "test"
+ expect(@resource.identity).to eq("test")
end
end
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index 8a1a13394e..449732a3c4 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_spec.rb
@@ -26,42 +26,42 @@ describe Chef::Resource::Package do
end
it "should create a new Chef::Resource::Package" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Package)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Package)
end
it "should set the package_name to the first argument to new" do
- @resource.package_name.should eql("emacs")
+ expect(@resource.package_name).to eql("emacs")
end
it "should accept a string for the package name" do
@resource.package_name "something"
- @resource.package_name.should eql("something")
+ expect(@resource.package_name).to eql("something")
end
it "should accept a string for the version" do
@resource.version "something"
- @resource.version.should eql("something")
+ expect(@resource.version).to eql("something")
end
it "should accept a string for the response file" do
@resource.response_file "something"
- @resource.response_file.should eql("something")
+ expect(@resource.response_file).to eql("something")
end
it "should accept a hash for response file template variables" do
@resource.response_file_variables({:variables => true})
- @resource.response_file_variables.should eql({:variables => true})
+ expect(@resource.response_file_variables).to eql({:variables => true})
end
it "should accept a string for the source" do
@resource.source "something"
- @resource.source.should eql("something")
+ expect(@resource.source).to eql("something")
end
it "should accept a string for the options" do
@resource.options "something"
- @resource.options.should eql("something")
+ expect(@resource.options).to eql("something")
end
describe "when it has a package_name and version" do
@@ -73,12 +73,12 @@ describe Chef::Resource::Package do
it "describes its state" do
state = @resource.state
- state[:version].should == "10.9.8"
- state[:options].should == "-al"
+ expect(state[:version]).to eq("10.9.8")
+ expect(state[:options]).to eq("-al")
end
it "returns the file path as its identity" do
- @resource.identity.should == "tomcat"
+ expect(@resource.identity).to eq("tomcat")
end
end
diff --git a/spec/unit/resource/perl_spec.rb b/spec/unit/resource/perl_spec.rb
index d25dc98563..7247cce6e3 100644
--- a/spec/unit/resource/perl_spec.rb
+++ b/spec/unit/resource/perl_spec.rb
@@ -25,16 +25,16 @@ describe Chef::Resource::Perl do
end
it "should create a new Chef::Resource::Perl" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Perl)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Perl)
end
it "should have a resource name of :perl" do
- @resource.resource_name.should eql(:perl)
+ expect(@resource.resource_name).to eql(:perl)
end
it "should have an interpreter of perl" do
- @resource.interpreter.should eql("perl")
+ expect(@resource.interpreter).to eql("perl")
end
end
diff --git a/spec/unit/resource/portage_package_spec.rb b/spec/unit/resource/portage_package_spec.rb
index 510f3b5864..d2ac7ac4be 100644
--- a/spec/unit/resource/portage_package_spec.rb
+++ b/spec/unit/resource/portage_package_spec.rb
@@ -25,14 +25,14 @@ describe Chef::Resource::PortagePackage, "initialize" do
end
it "should return a Chef::Resource::PortagePackage" do
- @resource.should be_a_kind_of(Chef::Resource::PortagePackage)
+ expect(@resource).to be_a_kind_of(Chef::Resource::PortagePackage)
end
it "should set the resource_name to :portage_package" do
- @resource.resource_name.should eql(:portage_package)
+ expect(@resource.resource_name).to eql(:portage_package)
end
it "should set the provider to Chef::Provider::Package::Portage" do
- @resource.provider.should eql(Chef::Provider::Package::Portage)
+ expect(@resource.provider).to eql(Chef::Provider::Package::Portage)
end
end
diff --git a/spec/unit/resource/powershell_spec.rb b/spec/unit/resource/powershell_spec.rb
index da20c4f0bf..c263172ae6 100644
--- a/spec/unit/resource/powershell_spec.rb
+++ b/spec/unit/resource/powershell_spec.rb
@@ -33,32 +33,32 @@ describe Chef::Resource::PowershellScript do
end
it "should create a new Chef::Resource::PowershellScript" do
- @resource.should be_a_kind_of(Chef::Resource::PowershellScript)
+ expect(@resource).to be_a_kind_of(Chef::Resource::PowershellScript)
end
it "should set convert_boolean_return to false by default" do
- @resource.convert_boolean_return.should == false
+ expect(@resource.convert_boolean_return).to eq(false)
end
it "should return the value for convert_boolean_return that was set" do
@resource.convert_boolean_return true
- @resource.convert_boolean_return.should == true
+ expect(@resource.convert_boolean_return).to eq(true)
@resource.convert_boolean_return false
- @resource.convert_boolean_return.should == false
+ expect(@resource.convert_boolean_return).to eq(false)
end
context "when using guards" do
let(:resource) { @resource }
before(:each) do
- resource.stub(:run_action)
- resource.stub(:updated).and_return(true)
+ allow(resource).to receive(:run_action)
+ allow(resource).to receive(:updated).and_return(true)
end
it "inherits exactly the :cwd, :environment, :group, :path, :user, :umask, and :architecture attributes from a parent resource class" do
inherited_difference = Chef::Resource::PowershellScript.guard_inherited_attributes -
[:cwd, :environment, :group, :path, :user, :umask, :architecture ]
- inherited_difference.should == []
+ expect(inherited_difference).to eq([])
end
it "should allow guard interpreter to be set to Chef::Resource::Script" do
diff --git a/spec/unit/resource/python_spec.rb b/spec/unit/resource/python_spec.rb
index 3362b68c62..8a3f7e48ca 100644
--- a/spec/unit/resource/python_spec.rb
+++ b/spec/unit/resource/python_spec.rb
@@ -25,16 +25,16 @@ describe Chef::Resource::Python do
end
it "should create a new Chef::Resource::Python" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Python)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Python)
end
it "should have a resource name of :python" do
- @resource.resource_name.should eql(:python)
+ expect(@resource.resource_name).to eql(:python)
end
it "should have an interpreter of python" do
- @resource.interpreter.should eql("python")
+ expect(@resource.interpreter).to eql("python")
end
end
diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb
index 00c301d61d..e2a864d73a 100644
--- a/spec/unit/resource/registry_key_spec.rb
+++ b/spec/unit/resource/registry_key_spec.rb
@@ -24,33 +24,33 @@ describe Chef::Resource::RegistryKey, "initialize" do
end
it "should create a new Chef::Resource::RegistryKey" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::RegistryKey)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::RegistryKey)
end
it "should set the resource_name to :registry_key" do
- @resource.resource_name.should eql(:registry_key)
+ expect(@resource.resource_name).to eql(:registry_key)
end
it "should set the key equal to the argument to initialize" do
- @resource.key.should eql('HKCU\Software\Raxicoricofallapatorius')
+ expect(@resource.key).to eql('HKCU\Software\Raxicoricofallapatorius')
end
it "should default recursive to false" do
- @resource.recursive.should eql(false)
+ expect(@resource.recursive).to eql(false)
end
it "should default architecture to :machine" do
- @resource.architecture.should eql(:machine)
+ expect(@resource.architecture).to eql(:machine)
end
it "should set action to :create" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
%w{create create_if_missing delete delete_key}.each do |action|
it "should allow action #{action}" do
- @resource.allowed_actions.detect { |a| a == action.to_sym }.should eql(action.to_sym)
+ expect(@resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym)
end
end
end
@@ -62,15 +62,15 @@ describe Chef::Resource::RegistryKey, "key" do
it "should allow a string" do
@resource.key 'HKCU\Software\Poosh'
- @resource.key.should eql('HKCU\Software\Poosh')
+ expect(@resource.key).to eql('HKCU\Software\Poosh')
end
it "should not allow an integer" do
- lambda { @resource.send(:key, 100) }.should raise_error(ArgumentError)
+ expect { @resource.send(:key, 100) }.to raise_error(ArgumentError)
end
it "should not allow a hash" do
- lambda { @resource.send(:key, { :sonic => "screwdriver" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(:key, { :sonic => "screwdriver" }) }.to raise_error(ArgumentError)
end
end
@@ -81,41 +81,41 @@ describe Chef::Resource::RegistryKey, "values" do
it "should allow a single proper hash of registry values" do
@resource.values( { :name => 'poosh', :type => :string, :data => 'carmen' } )
- @resource.values.should eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
+ expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
end
it "should allow an array of proper hashes of registry values" do
@resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen' } ]
- @resource.values.should eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
+ expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
end
it "should return checksummed data if the type is unsafe" do
@resource.values( { :name => 'poosh', :type => :binary, :data => 255.chr * 1 })
- @resource.values.should eql([ { :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" } ])
+ expect(@resource.values).to eql([ { :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" } ])
end
it "should throw an exception if the name field is missing" do
- lambda { @resource.values [ { :type => :string, :data => 'carmen' } ] }.should raise_error(ArgumentError)
+ expect { @resource.values [ { :type => :string, :data => 'carmen' } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if the type field is missing" do
- lambda { @resource.values [ { :name => 'poosh', :data => 'carmen' } ] }.should raise_error(ArgumentError)
+ expect { @resource.values [ { :name => 'poosh', :data => 'carmen' } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if the data field is missing" do
- lambda { @resource.values [ { :name => 'poosh', :type => :string } ] }.should raise_error(ArgumentError)
+ expect { @resource.values [ { :name => 'poosh', :type => :string } ] }.to raise_error(ArgumentError)
end
it "should throw an exception if extra fields are present" do
- lambda { @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen', :screwdriver => 'sonic' } ] }.should raise_error(ArgumentError)
+ expect { @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen', :screwdriver => 'sonic' } ] }.to raise_error(ArgumentError)
end
it "should not allow a string" do
- lambda { @resource.send(:values, 'souffle') }.should raise_error(ArgumentError)
+ expect { @resource.send(:values, 'souffle') }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
- lambda { @resource.send(:values, 100) }.should raise_error(ArgumentError)
+ expect { @resource.send(:values, 100) }.to raise_error(ArgumentError)
end
end
@@ -126,23 +126,23 @@ describe Chef::Resource::RegistryKey, "recursive" do
it "should allow a boolean" do
@resource.recursive(true)
- @resource.recursive.should eql(true)
+ expect(@resource.recursive).to eql(true)
end
it "should not allow a hash" do
- lambda { @resource.recursive({:sonic => :screwdriver}) }.should raise_error(ArgumentError)
+ expect { @resource.recursive({:sonic => :screwdriver}) }.to raise_error(ArgumentError)
end
it "should not allow an array" do
- lambda { @resource.recursive([:nose, :chin]) }.should raise_error(ArgumentError)
+ expect { @resource.recursive([:nose, :chin]) }.to raise_error(ArgumentError)
end
it "should not allow a string" do
- lambda { @resource.recursive('souffle') }.should raise_error(ArgumentError)
+ expect { @resource.recursive('souffle') }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
- lambda { @resource.recursive(100) }.should raise_error(ArgumentError)
+ expect { @resource.recursive(100) }.to raise_error(ArgumentError)
end
end
@@ -154,24 +154,24 @@ describe Chef::Resource::RegistryKey, "architecture" do
[ :i386, :x86_64, :machine ].each do |arch|
it "should allow #{arch} as a symbol" do
@resource.architecture(arch)
- @resource.architecture.should eql(arch)
+ expect(@resource.architecture).to eql(arch)
end
end
it "should not allow a hash" do
- lambda { @resource.architecture({:sonic => :screwdriver}) }.should raise_error(ArgumentError)
+ expect { @resource.architecture({:sonic => :screwdriver}) }.to raise_error(ArgumentError)
end
it "should not allow an array" do
- lambda { @resource.architecture([:nose, :chin]) }.should raise_error(ArgumentError)
+ expect { @resource.architecture([:nose, :chin]) }.to raise_error(ArgumentError)
end
it "should not allow a string" do
- lambda { @resource.architecture('souffle') }.should raise_error(ArgumentError)
+ expect { @resource.architecture('souffle') }.to raise_error(ArgumentError)
end
it "should not allow an integer" do
- lambda { @resource.architecture(100) }.should raise_error(ArgumentError)
+ expect { @resource.architecture(100) }.to raise_error(ArgumentError)
end
end
@@ -183,7 +183,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
it "should return unsafe data as-is" do
key_values = [ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ]
@resource.values(key_values)
- @resource.unscrubbed_values.should eql(key_values)
+ expect(@resource.unscrubbed_values).to eql(key_values)
end
end
@@ -194,6 +194,6 @@ describe Chef::Resource::RegistryKey, "state" do
it "should return scrubbed values" do
@resource.values([ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ])
- @resource.state.should eql( { :values => [{ :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" }] } )
+ expect(@resource.state).to eql( { :values => [{ :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" }] } )
end
end
diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb
index d3800062ae..1ab75586b6 100644
--- a/spec/unit/resource/remote_directory_spec.rb
+++ b/spec/unit/resource/remote_directory_spec.rb
@@ -25,52 +25,52 @@ describe Chef::Resource::RemoteDirectory do
end
it "should create a new Chef::Resource::RemoteDirectory" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::RemoteDirectory)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::RemoteDirectory)
end
it "should set the path to the first argument to new" do
- @resource.path.should eql("/etc/dunk")
+ expect(@resource.path).to eql("/etc/dunk")
end
it "should accept a string for the remote directory source" do
@resource.source "foo"
- @resource.source.should eql("foo")
+ expect(@resource.source).to eql("foo")
end
it "should have the basename of the remote directory resource as the default source" do
- @resource.source.should eql("dunk")
+ expect(@resource.source).to eql("dunk")
end
it "should accept a number for the remote files backup" do
@resource.files_backup 1
- @resource.files_backup.should eql(1)
+ expect(@resource.files_backup).to eql(1)
end
it "should accept false for the remote files backup" do
@resource.files_backup false
- @resource.files_backup.should eql(false)
+ expect(@resource.files_backup).to eql(false)
end
it "should accept 3 or 4 digets for the files_mode" do
@resource.files_mode 100
- @resource.files_mode.should eql(100)
+ expect(@resource.files_mode).to eql(100)
@resource.files_mode 1000
- @resource.files_mode.should eql(1000)
+ expect(@resource.files_mode).to eql(1000)
end
it "should accept a string or number for the files group" do
@resource.files_group "heart"
- @resource.files_group.should eql("heart")
+ expect(@resource.files_group).to eql("heart")
@resource.files_group 1000
- @resource.files_group.should eql(1000)
+ expect(@resource.files_group).to eql(1000)
end
it "should accept a string or number for the files owner" do
@resource.files_owner "heart"
- @resource.files_owner.should eql("heart")
+ expect(@resource.files_owner).to eql("heart")
@resource.files_owner 1000
- @resource.files_owner.should eql(1000)
+ expect(@resource.files_owner).to eql(1000)
end
describe "when it has cookbook, files owner, files mode, and source" do
@@ -85,13 +85,13 @@ describe Chef::Resource::RemoteDirectory do
it "describes its state" do
state = @resource.state
- state[:files_owner].should == "root"
- state[:files_group].should == "supergroup"
- state[:files_mode].should == "0664"
+ expect(state[:files_owner]).to eq("root")
+ expect(state[:files_group]).to eq("supergroup")
+ expect(state[:files_mode]).to eq("0664")
end
it "returns the path as its identity" do
- @resource.identity.should == "/var/path/"
+ expect(@resource.identity).to eq("/var/path/")
end
end
end
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
index 8f1633119d..14d2fb97bc 100644
--- a/spec/unit/resource/remote_file_spec.rb
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -27,74 +27,74 @@ describe Chef::Resource::RemoteFile do
describe "initialize" do
it "should create a new Chef::Resource::RemoteFile" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::File)
- @resource.should be_a_kind_of(Chef::Resource::RemoteFile)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::File)
+ expect(@resource).to be_a_kind_of(Chef::Resource::RemoteFile)
end
end
it "says its provider is RemoteFile when the source is an absolute URI" do
@resource.source("http://www.google.com/robots.txt")
- @resource.provider.should == Chef::Provider::RemoteFile
- Chef::Platform.find_provider(:noplatform, 'noversion', @resource).should == Chef::Provider::RemoteFile
+ expect(@resource.provider).to eq(Chef::Provider::RemoteFile)
+ expect(Chef::Platform.find_provider(:noplatform, 'noversion', @resource)).to eq(Chef::Provider::RemoteFile)
end
describe "source" do
it "does not have a default value for 'source'" do
- @resource.source.should eql([])
+ expect(@resource.source).to eql([])
end
it "should accept a URI for the remote file source" do
@resource.source "http://opscode.com/"
- @resource.source.should eql([ "http://opscode.com/" ])
+ expect(@resource.source).to eql([ "http://opscode.com/" ])
end
it "should accept a delayed evalutator (string) for the remote file source" do
@resource.source Chef::DelayedEvaluator.new {"http://opscode.com/"}
- @resource.source.should eql([ "http://opscode.com/" ])
+ expect(@resource.source).to eql([ "http://opscode.com/" ])
end
it "should accept an array of URIs for the remote file source" do
@resource.source([ "http://opscode.com/", "http://puppetlabs.com/" ])
- @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
+ expect(@resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
end
it "should accept a delated evaluator (array) for the remote file source" do
@resource.source Chef::DelayedEvaluator.new { [ "http://opscode.com/", "http://puppetlabs.com/" ] }
- @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
+ expect(@resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
end
it "should accept an multiple URIs as arguments for the remote file source" do
@resource.source("http://opscode.com/", "http://puppetlabs.com/")
- @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
+ expect(@resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
end
it "should only accept a single argument if a delayed evalutor is used" do
- lambda {
+ expect {
@resource.source("http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"})
- }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "should only accept a single array item if a delayed evalutor is used" do
- lambda {
+ expect {
@resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}])
- }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "does not accept a non-URI as the source" do
- lambda { @resource.source("not-a-uri") }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ expect { @resource.source("not-a-uri") }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "does not accept a non-URI as the source when read from a delayed evaluator" do
- lambda {
+ expect {
@resource.source(Chef::DelayedEvaluator.new {"not-a-uri"})
@resource.source
- }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
+ }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
end
it "should raise an exception when source is an empty array" do
- lambda { @resource.source([]) }.should raise_error(ArgumentError)
+ expect { @resource.source([]) }.to raise_error(ArgumentError)
end
end
@@ -102,51 +102,51 @@ describe Chef::Resource::RemoteFile do
describe "checksum" do
it "should accept a string for the checksum object" do
@resource.checksum "asdf"
- @resource.checksum.should eql("asdf")
+ expect(@resource.checksum).to eql("asdf")
end
it "should default to nil" do
- @resource.checksum.should == nil
+ expect(@resource.checksum).to eq(nil)
end
end
describe "ftp_active_mode" do
it "should accept a boolean for the ftp_active_mode object" do
@resource.ftp_active_mode true
- @resource.ftp_active_mode.should be_true
+ expect(@resource.ftp_active_mode).to be_true
end
it "should default to false" do
- @resource.ftp_active_mode.should be_false
+ expect(@resource.ftp_active_mode).to be_false
end
end
describe "conditional get options" do
it "defaults to using etags and last modified" do
- @resource.use_etags.should be_true
- @resource.use_last_modified.should be_true
+ expect(@resource.use_etags).to be_true
+ expect(@resource.use_last_modified).to be_true
end
it "enable or disables etag and last modified options as a group" do
@resource.use_conditional_get(false)
- @resource.use_etags.should be_false
- @resource.use_last_modified.should be_false
+ expect(@resource.use_etags).to be_false
+ expect(@resource.use_last_modified).to be_false
@resource.use_conditional_get(true)
- @resource.use_etags.should be_true
- @resource.use_last_modified.should be_true
+ expect(@resource.use_etags).to be_true
+ expect(@resource.use_last_modified).to be_true
end
it "disables etags indivdually" do
@resource.use_etags(false)
- @resource.use_etags.should be_false
- @resource.use_last_modified.should be_true
+ expect(@resource.use_etags).to be_false
+ expect(@resource.use_last_modified).to be_true
end
it "disables last modified individually" do
@resource.use_last_modified(false)
- @resource.use_last_modified.should be_false
- @resource.use_etags.should be_true
+ expect(@resource.use_last_modified).to be_false
+ expect(@resource.use_etags).to be_true
end
end
@@ -171,21 +171,21 @@ describe Chef::Resource::RemoteFile do
state = @resource.state
if Chef::Platform.windows?
puts state
- state[:rights].should == [{:permissions => :read, :principals => "Everyone"}]
- state[:deny_rights].should == [{:permissions => :full_control, :principals => "Clumsy_Sam"}]
+ expect(state[:rights]).to eq([{:permissions => :read, :principals => "Everyone"}])
+ expect(state[:deny_rights]).to eq([{:permissions => :full_control, :principals => "Clumsy_Sam"}])
else
- state[:group].should == "pokemon"
- state[:mode].should == "0664"
- state[:owner].should == "root"
- state[:checksum].should == "1"*26
+ expect(state[:group]).to eq("pokemon")
+ expect(state[:mode]).to eq("0664")
+ expect(state[:owner]).to eq("root")
+ expect(state[:checksum]).to eq("1"*26)
end
end
it "returns the path as its identity" do
if Chef::Platform.windows?
- @resource.identity.should == "C:/temp/origin/file.txt"
+ expect(@resource.identity).to eq("C:/temp/origin/file.txt")
else
- @resource.identity.should == "/this/path/"
+ expect(@resource.identity).to eq("/this/path/")
end
end
end
diff --git a/spec/unit/resource/route_spec.rb b/spec/unit/resource/route_spec.rb
index 4522438402..ec1d369932 100644
--- a/spec/unit/resource/route_spec.rb
+++ b/spec/unit/resource/route_spec.rb
@@ -26,64 +26,64 @@ describe Chef::Resource::Route do
end
it "should create a new Chef::Resource::Route" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Route)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Route)
end
it "should have a name" do
- @resource.name.should eql("10.0.0.10")
+ expect(@resource.name).to eql("10.0.0.10")
end
it "should have a default action of 'add'" do
- @resource.action.should eql([:add])
+ expect(@resource.action).to eql([:add])
end
it "should accept add or delete for action" do
- lambda { @resource.action :add }.should_not raise_error
- lambda { @resource.action :delete }.should_not raise_error
- lambda { @resource.action :lolcat }.should raise_error(ArgumentError)
+ expect { @resource.action :add }.not_to raise_error
+ expect { @resource.action :delete }.not_to raise_error
+ expect { @resource.action :lolcat }.to raise_error(ArgumentError)
end
it "should use the object name as the target by default" do
- @resource.target.should eql("10.0.0.10")
+ expect(@resource.target).to eql("10.0.0.10")
end
it "should allow you to specify the netmask" do
@resource.netmask "255.255.255.0"
- @resource.netmask.should eql("255.255.255.0")
+ expect(@resource.netmask).to eql("255.255.255.0")
end
it "should allow you to specify the gateway" do
@resource.gateway "10.0.0.1"
- @resource.gateway.should eql("10.0.0.1")
+ expect(@resource.gateway).to eql("10.0.0.1")
end
it "should allow you to specify the metric" do
@resource.metric 10
- @resource.metric.should eql(10)
+ expect(@resource.metric).to eql(10)
end
it "should allow you to specify the device" do
@resource.device "eth0"
- @resource.device.should eql("eth0")
+ expect(@resource.device).to eql("eth0")
end
it "should allow you to specify the route type" do
@resource.route_type "host"
- @resource.route_type.should eql(:host)
+ expect(@resource.route_type).to eql(:host)
end
it "should default to a host route type" do
- @resource.route_type.should eql(:host)
+ expect(@resource.route_type).to eql(:host)
end
it "should accept a net route type" do
@resource.route_type :net
- @resource.route_type.should eql(:net)
+ expect(@resource.route_type).to eql(:net)
end
it "should reject any other route_type but :host and :net" do
- lambda { @resource.route_type "lolcat" }.should raise_error(ArgumentError)
+ expect { @resource.route_type "lolcat" }.to raise_error(ArgumentError)
end
describe "when it has netmask, gateway, and device" do
@@ -96,12 +96,12 @@ describe Chef::Resource::Route do
it "describes its state" do
state = @resource.state
- state[:netmask].should == "lemask"
- state[:gateway].should == "111.111.111"
+ expect(state[:netmask]).to eq("lemask")
+ expect(state[:gateway]).to eq("111.111.111")
end
it "returns the target as its identity" do
- @resource.identity.should == "charmander"
+ expect(@resource.identity).to eq("charmander")
end
end
end
diff --git a/spec/unit/resource/ruby_block_spec.rb b/spec/unit/resource/ruby_block_spec.rb
index 82bbd1ffc7..9f19fecd4f 100644
--- a/spec/unit/resource/ruby_block_spec.rb
+++ b/spec/unit/resource/ruby_block_spec.rb
@@ -26,27 +26,27 @@ describe Chef::Resource::RubyBlock do
end
it "should create a new Chef::Resource::RubyBlock" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::RubyBlock)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::RubyBlock)
end
it "should have a default action of 'create'" do
- @resource.action.should eql("run")
+ expect(@resource.action).to eql("run")
end
it "should have a resource name of :ruby_block" do
- @resource.resource_name.should eql(:ruby_block)
+ expect(@resource.resource_name).to eql(:ruby_block)
end
it "should accept a ruby block/proc/.. for the 'block' parameter" do
- @resource.block do
+ expect(@resource.block do
"foo"
- end.call.should eql("foo")
+ end.call).to eql("foo")
end
it "allows the action to be 'create'" do
@resource.action :create
- @resource.action.should == [:create]
+ expect(@resource.action).to eq([:create])
end
describe "when it has been initialized with block code" do
@@ -55,7 +55,7 @@ describe Chef::Resource::RubyBlock do
end
it "returns the block as its identity" do
- @resource.identity.should == "puts 'harrrr'"
+ expect(@resource.identity).to eq("puts 'harrrr'")
end
end
end
diff --git a/spec/unit/resource/ruby_spec.rb b/spec/unit/resource/ruby_spec.rb
index 9bf7316e6d..e899810ab9 100644
--- a/spec/unit/resource/ruby_spec.rb
+++ b/spec/unit/resource/ruby_spec.rb
@@ -25,16 +25,16 @@ describe Chef::Resource::Ruby do
end
it "should create a new Chef::Resource::Ruby" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Ruby)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Ruby)
end
it "should have a resource name of :ruby" do
- @resource.resource_name.should eql(:ruby)
+ expect(@resource.resource_name).to eql(:ruby)
end
it "should have an interpreter of ruby" do
- @resource.interpreter.should eql("ruby")
+ expect(@resource.interpreter).to eql("ruby")
end
end
diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb
index eeb2fb1c3c..daabdd03ba 100644
--- a/spec/unit/resource/scm_spec.rb
+++ b/spec/unit/resource/scm_spec.rb
@@ -26,141 +26,141 @@ describe Chef::Resource::Scm do
end
it "should be a SCM resource" do
- @resource.should be_a_kind_of(Chef::Resource::Scm)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Scm)
end
it "supports :checkout, :export, :sync, :diff, and :log actions" do
- @resource.allowed_actions.should include(:checkout)
- @resource.allowed_actions.should include(:export)
- @resource.allowed_actions.should include(:sync)
- @resource.allowed_actions.should include(:diff)
- @resource.allowed_actions.should include(:log)
+ expect(@resource.allowed_actions).to include(:checkout)
+ expect(@resource.allowed_actions).to include(:export)
+ expect(@resource.allowed_actions).to include(:sync)
+ expect(@resource.allowed_actions).to include(:diff)
+ expect(@resource.allowed_actions).to include(:log)
end
it "takes the destination path as a string" do
@resource.destination "/path/to/deploy/dir"
- @resource.destination.should eql("/path/to/deploy/dir")
+ expect(@resource.destination).to eql("/path/to/deploy/dir")
end
it "takes a string for the repository URL" do
@resource.repository "git://github.com/opscode/chef.git"
- @resource.repository.should eql("git://github.com/opscode/chef.git")
+ expect(@resource.repository).to eql("git://github.com/opscode/chef.git")
end
it "takes a string for the revision" do
@resource.revision "abcdef"
- @resource.revision.should eql("abcdef")
+ expect(@resource.revision).to eql("abcdef")
end
it "defaults to the ``HEAD'' revision" do
- @resource.revision.should eql("HEAD")
+ expect(@resource.revision).to eql("HEAD")
end
it "takes a string for the user to run as" do
@resource.user "dr_deploy"
- @resource.user.should eql("dr_deploy")
+ expect(@resource.user).to eql("dr_deploy")
end
it "also takes an integer for the user to run as" do
@resource.user 0
- @resource.user.should eql(0)
+ expect(@resource.user).to eql(0)
end
it "takes a string for the group to run as, defaulting to nil" do
- @resource.group.should be_nil
+ expect(@resource.group).to be_nil
@resource.group "opsdevs"
- @resource.group.should == "opsdevs"
+ expect(@resource.group).to eq("opsdevs")
end
it "also takes an integer for the group to run as" do
@resource.group 23
- @resource.group.should == 23
+ expect(@resource.group).to eq(23)
end
it "has a svn_username String attribute" do
@resource.svn_username "moartestsplz"
- @resource.svn_username.should eql("moartestsplz")
+ expect(@resource.svn_username).to eql("moartestsplz")
end
it "has a svn_password String attribute" do
@resource.svn_password "taftplz"
- @resource.svn_password.should eql("taftplz")
+ expect(@resource.svn_password).to eql("taftplz")
end
it "has a svn_arguments String attribute" do
@resource.svn_arguments "--more-taft plz"
- @resource.svn_arguments.should eql("--more-taft plz")
+ expect(@resource.svn_arguments).to eql("--more-taft plz")
end
it "has a svn_info_args String attribute" do
- @resource.svn_info_args.should be_nil
+ expect(@resource.svn_info_args).to be_nil
@resource.svn_info_args("--no-moar-plaintext-creds yep")
- @resource.svn_info_args.should == "--no-moar-plaintext-creds yep"
+ expect(@resource.svn_info_args).to eq("--no-moar-plaintext-creds yep")
end
it "takes the depth as an integer for shallow clones" do
@resource.depth 5
- @resource.depth.should == 5
- lambda {@resource.depth "five"}.should raise_error(ArgumentError)
+ expect(@resource.depth).to eq(5)
+ expect {@resource.depth "five"}.to raise_error(ArgumentError)
end
it "defaults to nil depth for a full clone" do
- @resource.depth.should be_nil
+ expect(@resource.depth).to be_nil
end
it "takes a boolean for #enable_submodules" do
@resource.enable_submodules true
- @resource.enable_submodules.should be_true
- lambda {@resource.enable_submodules "lolz"}.should raise_error(ArgumentError)
+ expect(@resource.enable_submodules).to be_true
+ expect {@resource.enable_submodules "lolz"}.to raise_error(ArgumentError)
end
it "defaults to not enabling submodules" do
- @resource.enable_submodules.should be_false
+ expect(@resource.enable_submodules).to be_false
end
it "takes a boolean for #enable_checkout" do
@resource.enable_checkout true
- @resource.enable_checkout.should be_true
- lambda {@resource.enable_checkout "lolz"}.should raise_error(ArgumentError)
+ expect(@resource.enable_checkout).to be_true
+ expect {@resource.enable_checkout "lolz"}.to raise_error(ArgumentError)
end
it "defaults to enabling checkout" do
- @resource.enable_checkout.should be_true
+ expect(@resource.enable_checkout).to be_true
end
it "takes a string for the remote" do
@resource.remote "opscode"
- @resource.remote.should eql("opscode")
- lambda {@resource.remote 1337}.should raise_error(ArgumentError)
+ expect(@resource.remote).to eql("opscode")
+ expect {@resource.remote 1337}.to raise_error(ArgumentError)
end
it "defaults to ``origin'' for the remote" do
- @resource.remote.should == "origin"
+ expect(@resource.remote).to eq("origin")
end
it "takes a string for the ssh wrapper" do
@resource.ssh_wrapper "with_ssh_fu"
- @resource.ssh_wrapper.should eql("with_ssh_fu")
+ expect(@resource.ssh_wrapper).to eql("with_ssh_fu")
end
it "defaults to nil for the ssh wrapper" do
- @resource.ssh_wrapper.should be_nil
+ expect(@resource.ssh_wrapper).to be_nil
end
it "defaults to nil for the environment" do
- @resource.environment.should be_nil
+ expect(@resource.environment).to be_nil
end
describe "when it has a timeout attribute" do
let(:ten_seconds) { 10 }
before { @resource.timeout(ten_seconds) }
it "stores this timeout" do
- @resource.timeout.should == ten_seconds
+ expect(@resource.timeout).to eq(ten_seconds)
end
end
describe "when it has no timeout attribute" do
it "should have no default timeout" do
- @resource.timeout.should be_nil
+ expect(@resource.timeout).to be_nil
end
end
@@ -175,11 +175,11 @@ describe Chef::Resource::Scm do
it "describes its state" do
state = @resource.state
- state[:revision].should == "1.2.3"
+ expect(state[:revision]).to eq("1.2.3")
end
it "returns the destination as its identity" do
- @resource.identity.should == "hell"
+ expect(@resource.identity).to eq("hell")
end
end
@@ -187,7 +187,7 @@ describe Chef::Resource::Scm do
let(:test_environment) { {'CHEF_ENV' => '/tmp' } }
before { @resource.environment(test_environment) }
it "stores this environment" do
- @resource.environment.should == test_environment
+ expect(@resource.environment).to eq(test_environment)
end
end
end
diff --git a/spec/unit/resource/script_spec.rb b/spec/unit/resource/script_spec.rb
index f100b0dc85..9d744baaa5 100644
--- a/spec/unit/resource/script_spec.rb
+++ b/spec/unit/resource/script_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Resource::Script do
it "should accept a string for the interpreter" do
script_resource.interpreter "naaaaNaNaNaaNaaNaaNaa"
- script_resource.interpreter.should eql("naaaaNaNaNaaNaaNaaNaa")
+ expect(script_resource.interpreter).to eql("naaaaNaNaNaaNaaNaaNaa")
end
describe "when it has interpreter and flags" do
@@ -37,7 +37,7 @@ describe Chef::Resource::Script do
end
it "returns the command as its identity" do
- script_resource.identity.should == "grep"
+ expect(script_resource.identity).to eq("grep")
end
end
diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb
index 9b779e5830..eb6f444e93 100644
--- a/spec/unit/resource/service_spec.rb
+++ b/spec/unit/resource/service_spec.rb
@@ -26,135 +26,135 @@ describe Chef::Resource::Service do
end
it "should create a new Chef::Resource::Service" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::Service)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Service)
end
it "should not set a provider unless node[:init_package] is defined as systemd" do
- @resource.provider.should == nil
+ expect(@resource.provider).to eq(nil)
end
it "should set the service_name to the first argument to new" do
- @resource.service_name.should eql("chef")
+ expect(@resource.service_name).to eql("chef")
end
it "should set the pattern to be the service name by default" do
- @resource.pattern.should eql("chef")
+ expect(@resource.pattern).to eql("chef")
end
it "should accept a string for the service name" do
@resource.service_name "something"
- @resource.service_name.should eql("something")
+ expect(@resource.service_name).to eql("something")
end
it "should accept a string for the service pattern" do
@resource.pattern ".*"
- @resource.pattern.should eql(".*")
+ expect(@resource.pattern).to eql(".*")
end
it "should not accept a regexp for the service pattern" do
- lambda {
+ expect {
@resource.pattern /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service start command" do
@resource.start_command "/etc/init.d/chef start"
- @resource.start_command.should eql("/etc/init.d/chef start")
+ expect(@resource.start_command).to eql("/etc/init.d/chef start")
end
it "should not accept a regexp for the service start command" do
- lambda {
+ expect {
@resource.start_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service stop command" do
@resource.stop_command "/etc/init.d/chef stop"
- @resource.stop_command.should eql("/etc/init.d/chef stop")
+ expect(@resource.stop_command).to eql("/etc/init.d/chef stop")
end
it "should not accept a regexp for the service stop command" do
- lambda {
+ expect {
@resource.stop_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service status command" do
@resource.status_command "/etc/init.d/chef status"
- @resource.status_command.should eql("/etc/init.d/chef status")
+ expect(@resource.status_command).to eql("/etc/init.d/chef status")
end
it "should not accept a regexp for the service status command" do
- lambda {
+ expect {
@resource.status_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service restart command" do
@resource.restart_command "/etc/init.d/chef restart"
- @resource.restart_command.should eql("/etc/init.d/chef restart")
+ expect(@resource.restart_command).to eql("/etc/init.d/chef restart")
end
it "should not accept a regexp for the service restart command" do
- lambda {
+ expect {
@resource.restart_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service reload command" do
@resource.reload_command "/etc/init.d/chef reload"
- @resource.reload_command.should eql("/etc/init.d/chef reload")
+ expect(@resource.reload_command).to eql("/etc/init.d/chef reload")
end
it "should not accept a regexp for the service reload command" do
- lambda {
+ expect {
@resource.reload_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
it "should accept a string for the service init command" do
@resource.init_command "/etc/init.d/chef"
- @resource.init_command.should eql("/etc/init.d/chef")
+ expect(@resource.init_command).to eql("/etc/init.d/chef")
end
it "should not accept a regexp for the service init command" do
- lambda {
+ expect {
@resource.init_command /.*/
- }.should raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
%w{enabled running}.each do |attrib|
it "should accept true for #{attrib}" do
@resource.send(attrib, true)
- @resource.send(attrib).should eql(true)
+ expect(@resource.send(attrib)).to eql(true)
end
it "should accept false for #{attrib}" do
@resource.send(attrib, false)
- @resource.send(attrib).should eql(false)
+ expect(@resource.send(attrib)).to eql(false)
end
it "should not accept a string for #{attrib}" do
- lambda { @resource.send(attrib, "poop") }.should raise_error(ArgumentError)
+ expect { @resource.send(attrib, "poop") }.to raise_error(ArgumentError)
end
it "should default all the feature support to false" do
support_hash = { :status => false, :restart => false, :reload=> false }
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
it "should allow you to set what features this resource supports as a array" do
support_array = [ :status, :restart ]
support_hash = { :status => true, :restart => true, :reload => false }
@resource.supports(support_array)
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
it "should allow you to set what features this resource supports as a hash" do
support_hash = { :status => true, :restart => true, :reload => false }
@resource.supports(support_hash)
- @resource.supports.should == support_hash
+ expect(@resource.supports).to eq(support_hash)
end
end
@@ -167,12 +167,12 @@ describe Chef::Resource::Service do
it "describes its state" do
state = @resource.state
- state[:enabled].should eql(true)
- state[:running].should eql(false)
+ expect(state[:enabled]).to eql(true)
+ expect(state[:running]).to eql(false)
end
it "returns the service name as its identity" do
- @resource.identity.should == "superfriend"
+ expect(@resource.identity).to eq("superfriend")
end
end
diff --git a/spec/unit/resource/solaris_package_spec.rb b/spec/unit/resource/solaris_package_spec.rb
index ab4e03807d..f5d3e669a1 100644
--- a/spec/unit/resource/solaris_package_spec.rb
+++ b/spec/unit/resource/solaris_package_spec.rb
@@ -37,6 +37,6 @@ describe Chef::Resource::SolarisPackage, "initialize" do
end
it "should set the package_name to the name provided" do
- @resource.package_name.should eql("foo")
+ expect(@resource.package_name).to eql("foo")
end
end
diff --git a/spec/unit/resource/subversion_spec.rb b/spec/unit/resource/subversion_spec.rb
index a52d8421c6..4cbca9be11 100644
--- a/spec/unit/resource/subversion_spec.rb
+++ b/spec/unit/resource/subversion_spec.rb
@@ -33,35 +33,35 @@ describe Chef::Resource::Subversion do
end
it "is a subclass of Resource::Scm" do
- @svn.should be_an_instance_of(Chef::Resource::Subversion)
- @svn.should be_a_kind_of(Chef::Resource::Scm)
+ expect(@svn).to be_an_instance_of(Chef::Resource::Subversion)
+ expect(@svn).to be_a_kind_of(Chef::Resource::Scm)
end
it "allows the force_export action" do
- @svn.allowed_actions.should include(:force_export)
+ expect(@svn.allowed_actions).to include(:force_export)
end
it "sets svn info arguments to --no-auth-cache by default" do
- @svn.svn_info_args.should == '--no-auth-cache'
+ expect(@svn.svn_info_args).to eq('--no-auth-cache')
end
it "resets svn info arguments to nil when given false in the setter" do
@svn.svn_info_args(false)
- @svn.svn_info_args.should be_nil
+ expect(@svn.svn_info_args).to be_nil
end
it "sets svn arguments to --no-auth-cache by default" do
- @svn.svn_arguments.should == '--no-auth-cache'
+ expect(@svn.svn_arguments).to eq('--no-auth-cache')
end
it "resets svn arguments to nil when given false in the setter" do
@svn.svn_arguments(false)
- @svn.svn_arguments.should be_nil
+ expect(@svn.svn_arguments).to be_nil
end
it "hides password from custom exception message" do
@svn.svn_password "l33th4x0rpa$$w0rd"
e = @svn.customize_exception(Chef::Exceptions::Exec.new "Exception with password #{@svn.svn_password}")
- e.message.include?(@svn.svn_password).should be_false
+ expect(e.message.include?(@svn.svn_password)).to be_false
end
end
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index c9dfdc7014..df5ca94b8a 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -26,54 +26,54 @@ describe Chef::Resource::Template do
describe "initialize" do
it "should create a new Chef::Resource::Template" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::File)
- @resource.should be_a_kind_of(Chef::Resource::Template)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::File)
+ expect(@resource).to be_a_kind_of(Chef::Resource::Template)
end
end
describe "source" do
it "should accept a string for the template source" do
@resource.source "something"
- @resource.source.should eql("something")
+ expect(@resource.source).to eql("something")
end
it "should have a default based on the param name with .erb appended" do
- @resource.source.should eql("fakey_fakerton.erb")
+ expect(@resource.source).to eql("fakey_fakerton.erb")
end
it "should use only the basename of the file as the default" do
r = Chef::Resource::Template.new("/tmp/obit/fakey_fakerton")
- r.source.should eql("fakey_fakerton.erb")
+ expect(r.source).to eql("fakey_fakerton.erb")
end
end
describe "variables" do
it "should accept a hash for the variable list" do
@resource.variables({ :reluctance => :awkward })
- @resource.variables.should == { :reluctance => :awkward }
+ expect(@resource.variables).to eq({ :reluctance => :awkward })
end
end
describe "cookbook" do
it "should accept a string for the cookbook name" do
@resource.cookbook("foo")
- @resource.cookbook.should == "foo"
+ expect(@resource.cookbook).to eq("foo")
end
it "should default to nil" do
- @resource.cookbook.should == nil
+ expect(@resource.cookbook).to eq(nil)
end
end
describe "local" do
it "should accept a boolean for whether a template is local or remote" do
@resource.local(true)
- @resource.local.should == true
+ expect(@resource.local).to eq(true)
end
it "should default to false" do
- @resource.local.should == false
+ expect(@resource.local).to eq(false)
end
end
@@ -89,10 +89,10 @@ describe Chef::Resource::Template do
context "on unix", :unix_only do
it "describes its state" do
state = @resource.state
- state[:owner].should == "root"
- state[:group].should == "wheel"
- state[:mode].should == "0644"
- state[:checksum].should == "1" * 64
+ expect(state[:owner]).to eq("root")
+ expect(state[:group]).to eq("wheel")
+ expect(state[:mode]).to eq("0644")
+ expect(state[:checksum]).to eq("1" * 64)
end
end
@@ -102,7 +102,7 @@ describe Chef::Resource::Template do
end
it "returns the file path as its identity" do
- @resource.identity.should == "/tmp/foo.txt"
+ expect(@resource.identity).to eq("/tmp/foo.txt")
end
end
@@ -117,19 +117,19 @@ describe Chef::Resource::Template do
it "collects helper method bodies as blocks" do
@resource.helper(:example_1) { "example_1" }
@resource.helper(:example_2) { "example_2" }
- @resource.inline_helper_blocks[:example_1].call.should == "example_1"
- @resource.inline_helper_blocks[:example_2].call.should == "example_2"
+ expect(@resource.inline_helper_blocks[:example_1].call).to eq("example_1")
+ expect(@resource.inline_helper_blocks[:example_2].call).to eq("example_2")
end
it "compiles helper methods into a module" do
@resource.helper(:example_1) { "example_1" }
@resource.helper(:example_2) { "example_2" }
modules = @resource.helper_modules
- modules.should have(1).module
+ expect(modules.size).to eq(1)
o = Object.new
modules.each {|m| o.extend(m)}
- o.example_1.should == "example_1"
- o.example_2.should == "example_2"
+ expect(o.example_1).to eq("example_1")
+ expect(o.example_2).to eq("example_2")
end
it "compiles helper methods with arguments into a module" do
@@ -137,15 +137,15 @@ describe Chef::Resource::Template do
modules = @resource.helper_modules
o = Object.new
modules.each {|m| o.extend(m)}
- o.shout("shout").should == "SHOUT"
+ expect(o.shout("shout")).to eq("SHOUT")
end
it "raises an error when attempting to define a helper method without a method body" do
- lambda { @resource.helper(:example) }.should raise_error(Chef::Exceptions::ValidationFailed)
+ expect { @resource.helper(:example) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "raises an error when attempting to define a helper method with a non-Symbod method name" do
- lambda { @resource.helper("example") { "fail" } }.should raise_error(Chef::Exceptions::ValidationFailed)
+ expect { @resource.helper("example") { "fail" } }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "collects helper module bodies as blocks" do
@@ -155,7 +155,7 @@ describe Chef::Resource::Template do
end
end
module_body = @resource.inline_helper_modules.first
- module_body.should be_a(Proc)
+ expect(module_body).to be_a(Proc)
end
it "compiles helper module bodies into modules" do
@@ -165,27 +165,27 @@ describe Chef::Resource::Template do
end
end
modules = @resource.helper_modules
- modules.should have(1).module
+ expect(modules.size).to eq(1)
o = Object.new
modules.each {|m| o.extend(m)}
- o.example_1.should == "example_1"
+ expect(o.example_1).to eq("example_1")
end
it "raises an error when no block or module name is given for helpers definition" do
- lambda { @resource.helpers() }.should raise_error(Chef::Exceptions::ValidationFailed)
+ expect { @resource.helpers() }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "raises an error when a non-module is given for helpers definition" do
- lambda { @resource.helpers("NotAModule") }.should raise_error(Chef::Exceptions::ValidationFailed)
+ expect { @resource.helpers("NotAModule") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "raises an error when a module name and block are both given for helpers definition" do
- lambda { @resource.helpers(ExampleHelpers) { module_code } }.should raise_error(Chef::Exceptions::ValidationFailed)
+ expect { @resource.helpers(ExampleHelpers) { module_code } }.to raise_error(Chef::Exceptions::ValidationFailed)
end
it "collects helper modules" do
@resource.helpers(ExampleHelpers)
- @resource.helper_modules.should include(ExampleHelpers)
+ expect(@resource.helper_modules).to include(ExampleHelpers)
end
it "combines all helpers into a set of compiled modules" do
@@ -196,13 +196,13 @@ describe Chef::Resource::Template do
end
end
@resource.helper(:inline_method) { "inline_method" }
- @resource.should have(3).helper_modules
+ expect(@resource.helper_modules.size).to eq(3)
o = Object.new
@resource.helper_modules.each {|m| o.extend(m)}
- o.static_example.should == "static_example"
- o.inline_module.should == "inline_module"
- o.inline_method.should == "inline_method"
+ expect(o.static_example).to eq("static_example")
+ expect(o.inline_module).to eq("inline_module")
+ expect(o.inline_method).to eq("inline_method")
end
diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb
index 70b866202b..f05de94fe0 100644
--- a/spec/unit/resource/user_spec.rb
+++ b/spec/unit/resource/user_spec.rb
@@ -24,51 +24,51 @@ describe Chef::Resource::User, "initialize" do
end
it "should create a new Chef::Resource::User" do
- @resource.should be_a_kind_of(Chef::Resource)
- @resource.should be_a_kind_of(Chef::Resource::User)
+ expect(@resource).to be_a_kind_of(Chef::Resource)
+ expect(@resource).to be_a_kind_of(Chef::Resource::User)
end
it "should set the resource_name to :user" do
- @resource.resource_name.should eql(:user)
+ expect(@resource.resource_name).to eql(:user)
end
it "should set the username equal to the argument to initialize" do
- @resource.username.should eql("adam")
+ expect(@resource.username).to eql("adam")
end
%w{comment uid gid home shell password}.each do |attrib|
it "should set #{attrib} to nil" do
- @resource.send(attrib).should eql(nil)
+ expect(@resource.send(attrib)).to eql(nil)
end
end
it "should set action to :create" do
- @resource.action.should eql(:create)
+ expect(@resource.action).to eql(:create)
end
it "should set supports[:manage_home] to false" do
- @resource.supports[:manage_home].should eql(false)
+ expect(@resource.supports[:manage_home]).to eql(false)
end
it "should set supports[:non_unique] to false" do
- @resource.supports[:non_unique].should eql(false)
+ expect(@resource.supports[:non_unique]).to eql(false)
end
it "should set force to false" do
- @resource.force.should eql(false)
+ expect(@resource.force).to eql(false)
end
%w{create remove modify manage lock unlock}.each do |action|
it "should allow action #{action}" do
- @resource.allowed_actions.detect { |a| a == action.to_sym }.should eql(action.to_sym)
+ expect(@resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym)
end
end
it "should accept domain users (@ or \ separator) on non-windows" do
- lambda { @resource.username "domain\@user" }.should_not raise_error
- @resource.username.should == "domain\@user"
- lambda { @resource.username "domain\\user" }.should_not raise_error
- @resource.username.should == "domain\\user"
+ expect { @resource.username "domain\@user" }.not_to raise_error
+ expect(@resource.username).to eq("domain\@user")
+ expect { @resource.username "domain\\user" }.not_to raise_error
+ expect(@resource.username).to eq("domain\\user")
end
end
@@ -80,11 +80,11 @@ end
it "should allow a string" do
@resource.send(attrib, "adam")
- @resource.send(attrib).should eql("adam")
+ expect(@resource.send(attrib)).to eql("adam")
end
it "should not allow a hash" do
- lambda { @resource.send(attrib, { :woot => "i found it" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
end
end
end
@@ -97,16 +97,16 @@ end
it "should allow a string" do
@resource.send(attrib, "100")
- @resource.send(attrib).should eql("100")
+ expect(@resource.send(attrib)).to eql("100")
end
it "should allow an integer" do
@resource.send(attrib, 100)
- @resource.send(attrib).should eql(100)
+ expect(@resource.send(attrib)).to eql(100)
end
it "should not allow a hash" do
- lambda { @resource.send(attrib, { :woot => "i found it" }) }.should raise_error(ArgumentError)
+ expect { @resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
end
end
@@ -120,13 +120,13 @@ end
it "describes its state" do
state = @resource.state
- state[:uid].should == 123
- state[:gid].should == 456
- state[:home].should == "/usr/local/root/"
+ expect(state[:uid]).to eq(123)
+ expect(state[:gid]).to eq(456)
+ expect(state[:home]).to eq("/usr/local/root/")
end
it "returns the username as its identity" do
- @resource.identity.should == "root"
+ expect(@resource.identity).to eq("root")
end
end
diff --git a/spec/unit/resource/windows_package_spec.rb b/spec/unit/resource/windows_package_spec.rb
index c9ef8d910c..3c45548ece 100644
--- a/spec/unit/resource/windows_package_spec.rb
+++ b/spec/unit/resource/windows_package_spec.rb
@@ -56,13 +56,13 @@ describe Chef::Resource::WindowsPackage, "initialize", :windows_only do
end
it "coverts a source to an absolute path" do
- ::File.stub(:absolute_path).and_return("c:\\Files\\frost.msi")
+ allow(::File).to receive(:absolute_path).and_return("c:\\Files\\frost.msi")
resource.source("frost.msi")
expect(resource.source).to eql "c:\\Files\\frost.msi"
end
it "converts slashes to backslashes in the source path" do
- ::File.stub(:absolute_path).and_return("c:\\frost.msi")
+ allow(::File).to receive(:absolute_path).and_return("c:\\frost.msi")
resource.source("c:/frost.msi")
expect(resource.source).to eql "c:\\frost.msi"
end
diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb
index c92c3be1b0..fd7bedec9f 100644
--- a/spec/unit/resource/windows_service_spec.rb
+++ b/spec/unit/resource/windows_service_spec.rb
@@ -41,6 +41,6 @@ describe Chef::Resource::WindowsService, "initialize", :windows_only do
it "allows the action to be 'configure_startup'" do
resource.action :configure_startup
- resource.action.should == [:configure_startup]
+ expect(resource.action).to eq([:configure_startup])
end
end
diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb
index 7e1979fdfd..e01b87c580 100644
--- a/spec/unit/resource/yum_package_spec.rb
+++ b/spec/unit/resource/yum_package_spec.rb
@@ -39,7 +39,7 @@ describe Chef::Resource::YumPackage, "arch" do
it "should set the arch variable to whatever is passed in" do
@resource.arch("i386")
- @resource.arch.should eql("i386")
+ expect(@resource.arch).to eql("i386")
end
end
@@ -50,20 +50,20 @@ describe Chef::Resource::YumPackage, "flush_cache" do
it "should default the flush timing to false" do
flush_hash = { :before => false, :after => false }
- @resource.flush_cache.should == flush_hash
+ expect(@resource.flush_cache).to eq(flush_hash)
end
it "should allow you to set the flush timing with an array" do
flush_array = [ :before, :after ]
flush_hash = { :before => true, :after => true }
@resource.flush_cache(flush_array)
- @resource.flush_cache.should == flush_hash
+ expect(@resource.flush_cache).to eq(flush_hash)
end
it "should allow you to set the flush timing with a hash" do
flush_hash = { :before => true, :after => true }
@resource.flush_cache(flush_hash)
- @resource.flush_cache.should == flush_hash
+ expect(@resource.flush_cache).to eq(flush_hash)
end
end
@@ -73,8 +73,8 @@ describe Chef::Resource::YumPackage, "allow_downgrade" do
end
it "should allow you to specify whether allow_downgrade is true or false" do
- lambda { @resource.allow_downgrade true }.should_not raise_error
- lambda { @resource.allow_downgrade false }.should_not raise_error
- lambda { @resource.allow_downgrade "monkey" }.should raise_error(ArgumentError)
+ expect { @resource.allow_downgrade true }.not_to raise_error
+ expect { @resource.allow_downgrade false }.not_to raise_error
+ expect { @resource.allow_downgrade "monkey" }.to raise_error(ArgumentError)
end
end