summaryrefslogtreecommitdiff
path: root/spec/unit/dsl
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-10-29 15:14:22 -0700
committerClaire McQuin <claire@getchef.com>2014-10-29 15:59:04 -0700
commit5fed7a65a2f024d964ecf2de1bcf2911cf8a600c (patch)
tree14cc6968e4fe4fd2485c0211088b25c645a80a4b /spec/unit/dsl
parentb92c309b0f1aa0837f76ab89d6c81c36076ceca9 (diff)
downloadchef-5fed7a65a2f024d964ecf2de1bcf2911cf8a600c.tar.gz
Update to RSpec 3.
Diffstat (limited to 'spec/unit/dsl')
-rw-r--r--spec/unit/dsl/data_query_spec.rb2
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb28
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb36
-rw-r--r--spec/unit/dsl/regsitry_helper_spec.rb12
4 files changed, 39 insertions, 39 deletions
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 78cd5569e8..b93ae1f1d6 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -28,7 +28,7 @@ describe Chef::DSL::DataQuery do
let(:language) do
language = DataQueryDSLTester.new
- language.stub(:node).and_return(@node)
+ allow(language).to receive(:node).and_return(@node)
language
end
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index f00d5a2ab8..e41560c034 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -48,37 +48,37 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "returns the default value when the platform doesn't match" do
- @platform_specific_value.value_for_node(:platform => :dos).should == 'bork da bork'
+ expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq('bork da bork')
end
it "returns a value for a platform set as a group" do
- @platform_specific_value.value_for_node(:platform => :centos).should == '"stable"'
+ expect(@platform_specific_value.value_for_node(:platform => :centos)).to eq('"stable"')
end
it "returns a value for the platform when it was set as a symbol but fetched as a string" do
- @platform_specific_value.value_for_node(:platform => "centos").should == '"stable"'
+ expect(@platform_specific_value.value_for_node(:platform => "centos")).to eq('"stable"')
end
it "returns a value for a specific platform version" do
node = {:platform => 'ubuntu', :platform_version => '10.04'}
- @platform_specific_value.value_for_node(node).should == 'using upstart more'
+ expect(@platform_specific_value.value_for_node(node)).to eq('using upstart more')
end
it "returns a platform-default value if the platform version doesn't match an explicit one" do
node = {:platform => 'ubuntu', :platform_version => '9.10' }
- @platform_specific_value.value_for_node(node).should == 'using init more'
+ expect(@platform_specific_value.value_for_node(node)).to eq('using init more')
end
it "returns nil if there is no default and no platforms match" do
# this matches the behavior in the original implementation.
# whether or not it's correct is another matter.
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new({})
- platform_specific_value.value_for_node(:platform => 'foo').should be_nil
+ expect(platform_specific_value.value_for_node(:platform => 'foo')).to be_nil
end
it "raises an argument error if the platform hash is not correctly structured" do
bad_hash = {:ubuntu => :foo} # should be :ubuntu => {:default => 'foo'}
- lambda {Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash)}.should raise_error(ArgumentError)
+ expect {Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash)}.to raise_error(ArgumentError)
end
end
@@ -98,33 +98,33 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
end
it "returns the default value when the platform family doesn't match" do
- @platform_family_value.value_for_node(:platform_family => :os2).should == 'default value'
+ expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq('default value')
end
it "returns a value for the platform family when it was set as a string but fetched as a symbol" do
- @platform_family_value.value_for_node(:platform_family => :debian).should == "debian value"
+ expect(@platform_family_value.value_for_node(:platform_family => :debian)).to eq("debian value")
end
it "returns a value for the platform family when it was set as a symbol but fetched as a string" do
- @platform_family_value.value_for_node(:platform_family => "gentoo").should == "gentoo value"
+ expect(@platform_family_value.value_for_node(:platform_family => "gentoo")).to eq("gentoo value")
end
it "returns an array value stored for a platform family" do
- @platform_family_value.value_for_node(:platform_family => "suse").should == @array_values
+ expect(@platform_family_value.value_for_node(:platform_family => "suse")).to eq(@array_values)
end
it "returns a value for the platform family when it was set within an array hash key as a symbol" do
- @platform_family_value.value_for_node(:platform_family => :rhel).should == "redhatty value"
+ expect(@platform_family_value.value_for_node(:platform_family => :rhel)).to eq("redhatty value")
end
it "returns a value for the platform family when it was set within an array hash key as a string" do
- @platform_family_value.value_for_node(:platform_family => "fedora").should == "redhatty value"
+ expect(@platform_family_value.value_for_node(:platform_family => "fedora")).to eq("redhatty value")
end
it "returns nil if there is no default and no platforms match" do
platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue.new({})
- platform_specific_value.value_for_node(:platform_family => 'foo').should be_nil
+ expect(platform_specific_value.value_for_node(:platform_family => 'foo')).to be_nil
end
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 0d643514e0..0f2288740f 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -25,52 +25,52 @@ describe Chef::DSL::RebootPending do
let(:recipe) { Object.new.extend(Chef::DSL::RebootPending) }
before do
- recipe.stub(:platform?).and_return(false)
+ allow(recipe).to receive(:platform?).and_return(false)
end
context "platform is windows" do
before do
- recipe.stub(:platform?).with('windows').and_return(true)
- recipe.stub(:registry_key_exists?).and_return(false)
- recipe.stub(:registry_value_exists?).and_return(false)
+ allow(recipe).to receive(:platform?).with('windows').and_return(true)
+ allow(recipe).to receive(:registry_key_exists?).and_return(false)
+ allow(recipe).to receive(:registry_value_exists?).and_return(false)
end
it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do
- recipe.stub(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => 'PendingFileRenameOperations' }).and_return(true)
- expect(recipe.reboot_pending?).to be_true
+ allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => 'PendingFileRenameOperations' }).and_return(true)
+ expect(recipe.reboot_pending?).to be_truthy
end
it 'should return true if "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" exists' do
- recipe.stub(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired').and_return(true)
- expect(recipe.reboot_pending?).to be_true
+ allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired').and_return(true)
+ expect(recipe.reboot_pending?).to be_truthy
end
it 'should return true if key "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired" exists' do
- recipe.stub(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired').and_return(true)
- expect(recipe.reboot_pending?).to be_true
+ allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootRequired').and_return(true)
+ expect(recipe.reboot_pending?).to be_truthy
end
it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data' do
- recipe.stub(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
- recipe.stub(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
+ allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(true)
+ allow(recipe).to receive(:registry_get_values).with('HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile').and_return(
[{:name => "Flags", :type => :dword, :data => 3}])
- expect(recipe.reboot_pending?).to be_true
+ expect(recipe.reboot_pending?).to be_truthy
end
end
context "platform is ubuntu" do
before do
- recipe.stub(:platform?).with('ubuntu').and_return(true)
+ allow(recipe).to receive(:platform?).with('ubuntu').and_return(true)
end
it 'should return true if /var/run/reboot-required exists' do
- File.stub(:exists?).with('/var/run/reboot-required').and_return(true)
- expect(recipe.reboot_pending?).to be_true
+ allow(File).to receive(:exists?).with('/var/run/reboot-required').and_return(true)
+ expect(recipe.reboot_pending?).to be_truthy
end
it 'should return false if /var/run/reboot-required does not exist' do
- File.stub(:exists?).with('/var/run/reboot-required').and_return(false)
- expect(recipe.reboot_pending?).to be_false
+ allow(File).to receive(:exists?).with('/var/run/reboot-required').and_return(false)
+ expect(recipe.reboot_pending?).to be_falsey
end
end
diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb
index 7fe08e310f..6508a12b6f 100644
--- a/spec/unit/dsl/regsitry_helper_spec.rb
+++ b/spec/unit/dsl/regsitry_helper_spec.rb
@@ -33,22 +33,22 @@ describe Chef::Resource::RegistryKey do
context "tests registry dsl" do
it "resource can access registry_helper method registry_key_exists" do
- @resource.respond_to?('registry_key_exists?').should == true
+ expect(@resource.respond_to?('registry_key_exists?')).to eq(true)
end
it "resource can access registry_helper method registry_get_values" do
- @resource.respond_to?('registry_get_values').should == true
+ expect(@resource.respond_to?('registry_get_values')).to eq(true)
end
it "resource can access registry_helper method registry_has_subkey" do
- @resource.respond_to?('registry_has_subkeys?').should == true
+ expect(@resource.respond_to?('registry_has_subkeys?')).to eq(true)
end
it "resource can access registry_helper method registry_get_subkeys" do
- @resource.respond_to?('registry_get_subkeys').should == true
+ expect(@resource.respond_to?('registry_get_subkeys')).to eq(true)
end
it "resource can access registry_helper method registry_value_exists" do
- @resource.respond_to?('registry_value_exists?').should == true
+ expect(@resource.respond_to?('registry_value_exists?')).to eq(true)
end
it "resource can access registry_helper method data_value_exists" do
- @resource.respond_to?('registry_data_exists?').should == true
+ expect(@resource.respond_to?('registry_data_exists?')).to eq(true)
end
end
end