summaryrefslogtreecommitdiff
path: root/spec/unit/dsl
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/dsl')
-rw-r--r--spec/unit/dsl/audit_spec.rb6
-rw-r--r--spec/unit/dsl/data_query_spec.rb10
-rw-r--r--spec/unit/dsl/platform_introspection_spec.rb15
-rw-r--r--spec/unit/dsl/reboot_pending_spec.rb18
-rw-r--r--spec/unit/dsl/recipe_spec.rb2
-rw-r--r--spec/unit/dsl/regsitry_helper_spec.rb3
-rw-r--r--spec/unit/dsl/resources_spec.rb6
7 files changed, 28 insertions, 32 deletions
diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb
index df8dbc95c0..a8227f6c99 100644
--- a/spec/unit/dsl/audit_spec.rb
+++ b/spec/unit/dsl/audit_spec.rb
@@ -17,15 +17,15 @@ describe Chef::DSL::Audit do
let(:cookbook_collection) { {} }
it "raises an error when a block of audits is not provided" do
- expect{ auditor.control_group "name" }.to raise_error(Chef::Exceptions::NoAuditsProvided)
+ expect { auditor.control_group "name" }.to raise_error(Chef::Exceptions::NoAuditsProvided)
end
it "raises an error when no audit name is given" do
- expect{ auditor.control_group do end }.to raise_error(Chef::Exceptions::AuditNameMissing)
+ expect { auditor.control_group do end }.to raise_error(Chef::Exceptions::AuditNameMissing)
end
context "audits already populated" do
- let(:audits) { {"unique" => {} } }
+ let(:audits) { { "unique" => {} } }
it "raises an error if the audit name is a duplicate" do
expect { auditor.control_group "unique" do end }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate)
diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb
index 36f9aa13b1..55c6e5f578 100644
--- a/spec/unit/dsl/data_query_spec.rb
+++ b/spec/unit/dsl/data_query_spec.rb
@@ -35,23 +35,23 @@ describe Chef::DSL::DataQuery do
describe "::data_bag" do
it "lists the items in a data bag" do
allow(Chef::DataBag).to receive(:load)
- .with("bag_name")
- .and_return("item_1" => "http://url_for/item_1", "item_2" => "http://url_for/item_2")
+ .with("bag_name")
+ .and_return("item_1" => "http://url_for/item_1", "item_2" => "http://url_for/item_2")
expect( language.data_bag("bag_name").sort ).to eql %w{item_1 item_2}
end
end
shared_examples_for "a data bag item" do
it "validates the name of the data bag you're trying to load an item from" do
- expect{ language.send(method_name, " %%^& ", "item_name") }.to raise_error(Chef::Exceptions::InvalidDataBagName)
+ expect { language.send(method_name, " %%^& ", "item_name") }.to raise_error(Chef::Exceptions::InvalidDataBagName)
end
it "validates the id of the data bag item you're trying to load" do
- expect{ language.send(method_name, "bag_name", " 987 (*&()") }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
+ expect { language.send(method_name, "bag_name", " 987 (*&()") }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
end
it "validates that the id of the data bag item is not nil" do
- expect{ language.send(method_name, "bag_name", nil) }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
+ expect { language.send(method_name, "bag_name", nil) }.to raise_error(Chef::Exceptions::InvalidDataBagItemID)
end
end
diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb
index 24f63d126b..fd1f9b23b5 100644
--- a/spec/unit/dsl/platform_introspection_spec.rb
+++ b/spec/unit/dsl/platform_introspection_spec.rb
@@ -39,9 +39,9 @@ end
describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
before do
platform_hash = {
- :openbsd => {:default => "free, functional, secure"},
- [:redhat, :centos, :fedora, :scientific] => {:default => '"stable"'},
- :ubuntu => {"10.04" => "using upstart more", :default => "using init more"},
+ :openbsd => { :default => "free, functional, secure" },
+ [:redhat, :centos, :fedora, :scientific] => { :default => '"stable"' },
+ :ubuntu => { "10.04" => "using upstart more", :default => "using init more" },
:default => "bork da bork",
}
@platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(platform_hash)
@@ -60,12 +60,12 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "returns a value for a specific platform version" do
- node = {:platform => "ubuntu", :platform_version => "10.04"}
+ node = { :platform => "ubuntu", :platform_version => "10.04" }
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" }
+ node = { :platform => "ubuntu", :platform_version => "9.10" }
expect(@platform_specific_value.value_for_node(node)).to eq("using init more")
end
@@ -77,8 +77,8 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do
end
it "raises an argument error if the platform hash is not correctly structured" do
- bad_hash = {:ubuntu => :foo} # should be :ubuntu => {:default => 'foo'}
- expect {Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash)}.to raise_error(ArgumentError)
+ bad_hash = { :ubuntu => :foo } # should be :ubuntu => {:default => 'foo'}
+ expect { Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(bad_hash) }.to raise_error(ArgumentError)
end
end
@@ -101,7 +101,6 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do
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
expect(@platform_family_value.value_for_node(:platform_family => :debian)).to eq("debian value")
end
diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb
index 42891195bf..66f8b76d7f 100644
--- a/spec/unit/dsl/reboot_pending_spec.rb
+++ b/spec/unit/dsl/reboot_pending_spec.rb
@@ -34,22 +34,22 @@ describe Chef::DSL::RebootPending do
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
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
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
allow(recipe).to receive(:registry_key_exists?).with('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending').and_return(true)
expect(recipe.reboot_pending?).to be_truthy
end
-
+
context "version is server 2003" do
before do
allow(Chef::Platform).to receive(:windows_server_2003?).and_return(true)
@@ -58,22 +58,22 @@ describe Chef::DSL::RebootPending do
it 'should return true if value "HKLM\SOFTWARE\Microsoft\Updates\UpdateExeVolatile" contains specific data on 2k3' do
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}])
+ [{ :name => "Flags", :type => :dword, :data => 3 }])
expect(recipe.reboot_pending?).to be_truthy
end
end
end
-
+
context "platform is ubuntu" do
before do
allow(recipe).to receive(:platform?).with("ubuntu").and_return(true)
end
-
+
it "should return true if /var/run/reboot-required exists" do
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
allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false)
expect(recipe.reboot_pending?).to be_falsey
@@ -85,7 +85,7 @@ describe Chef::DSL::RebootPending do
describe "in a recipe" do
it "responds to reboot_pending?" do
# Chef::Recipe.new(cookbook_name, recipe_name, run_context(node, cookbook_collection, events))
- recipe = Chef::Recipe.new(nil,nil,Chef::RunContext.new(Chef::Node.new, {}, nil))
+ recipe = Chef::Recipe.new(nil, nil, Chef::RunContext.new(Chef::Node.new, {}, nil))
expect(recipe).to respond_to(:reboot_pending?)
end
end # describe in a recipe
diff --git a/spec/unit/dsl/recipe_spec.rb b/spec/unit/dsl/recipe_spec.rb
index 534e430817..cd01079c15 100644
--- a/spec/unit/dsl/recipe_spec.rb
+++ b/spec/unit/dsl/recipe_spec.rb
@@ -19,7 +19,6 @@
require "spec_helper"
require "chef/dsl/recipe"
-
RecipeDSLExampleClass = Struct.new(:cookbook_name, :recipe_name)
class RecipeDSLExampleClass
include Chef::DSL::Recipe
@@ -79,4 +78,3 @@ describe Chef::DSL::Recipe do
end
end
-
diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb
index 9b527ec36c..d6c2257003 100644
--- a/spec/unit/dsl/regsitry_helper_spec.rb
+++ b/spec/unit/dsl/regsitry_helper_spec.rb
@@ -24,7 +24,7 @@ describe Chef::Resource::RegistryKey do
before (:all) do
events = Chef::EventDispatch::Dispatcher.new
node = Chef::Node.new
- node.consume_external_attrs(OHAI_SYSTEM.data,{})
+ node.consume_external_attrs(OHAI_SYSTEM.data, {})
run_context = Chef::RunContext.new(node, {}, events)
@resource = Chef::Resource::new("foo", run_context)
end
@@ -50,4 +50,3 @@ describe Chef::Resource::RegistryKey do
end
end
end
-
diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb
index 3952483efc..53cd6fcdb1 100644
--- a/spec/unit/dsl/resources_spec.rb
+++ b/spec/unit/dsl/resources_spec.rb
@@ -44,7 +44,7 @@ describe Chef::DSL::Resources do
end
end
end
- it { is_expected.to eq [[:test_resource, "test_name"]]}
+ it { is_expected.to eq [[:test_resource, "test_name"]] }
end
context "with no resource added" do
@@ -77,9 +77,9 @@ describe Chef::DSL::Resources do
before do
Chef::DSL::Resources.add_resource_dsl(:test_resource)
test_class.new.instance_eval do
- test_resource { }
+ test_resource {}
end
end
- it { is_expected.to eq [[:test_resource, nil]]}
+ it { is_expected.to eq [[:test_resource, nil]] }
end
end