summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/cookbook')
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb1
-rw-r--r--spec/unit/cookbook/file_vendor_spec.rb7
-rw-r--r--spec/unit/cookbook/metadata_spec.rb63
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb6
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb8
5 files changed, 40 insertions, 45 deletions
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 10495d180a..a32eb052af 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -184,4 +184,3 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
end
-
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb
index ea6f8d010d..139a5932f9 100644
--- a/spec/unit/cookbook/file_vendor_spec.rb
+++ b/spec/unit/cookbook/file_vendor_spec.rb
@@ -40,7 +40,7 @@ describe Chef::Cookbook::FileVendor do
context "with a manifest from a cookbook version" do
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:cookbook_name => "bob", :name => "bob-1.2.3"} }
+ let(:manifest) { { :cookbook_name => "bob", :name => "bob-1.2.3" } }
it "creates a RemoteFileVendor for a given manifest" do
file_vendor = file_vendor_class.create_from_manifest(manifest)
@@ -54,7 +54,7 @@ describe Chef::Cookbook::FileVendor do
context "with a manifest from a cookbook artifact" do
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:name => "bob"} }
+ let(:manifest) { { :name => "bob" } }
it "creates a RemoteFileVendor for a given manifest" do
file_vendor = file_vendor_class.create_from_manifest(manifest)
@@ -71,7 +71,7 @@ describe Chef::Cookbook::FileVendor do
let(:cookbook_path) { %w{/var/chef/cookbooks /var/chef/other_cookbooks} }
# A manifest is a Hash of the format defined by Chef::CookbookVersion#manifest
- let(:manifest) { {:cookbook_name => "bob"} }
+ let(:manifest) { { :cookbook_name => "bob" } }
before do
file_vendor_class.fetch_from_disk(cookbook_path)
@@ -95,4 +95,3 @@ describe Chef::Cookbook::FileVendor do
end
end
-
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 351792175f..ff18333e70 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -205,7 +205,7 @@ describe Chef::Cookbook::Metadata do
:issues_url => "http://example.com/issues",
:privacy => true,
}
- params.sort { |a,b| a.to_s <=> b.to_s }.each do |field, field_value|
+ params.sort { |a, b| a.to_s <=> b.to_s }.each do |field, field_value|
describe field do
it "should be set-able via #{field}" do
expect(metadata.send(field, field_value)).to eql(field_value)
@@ -239,7 +239,7 @@ describe Chef::Cookbook::Metadata do
:provides => [ :providing, "foo::bar", "<= 0.2" ],
:replaces => [ :replacing, "foo::bar", "= 0.2.1" ],
}
- dep_types.sort { |a,b| a.to_s <=> b.to_s }.each do |dep, dep_args|
+ dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
check_with = dep_args.shift
describe dep do
it "should be set-able via #{dep}" do
@@ -260,7 +260,7 @@ describe Chef::Cookbook::Metadata do
:provides => [ :providing, "foo::bar", "<=0.2", "<= 0.2" ],
:replaces => [ :replacing, "foo::bar", "=0.2.1", "= 0.2.1" ],
}
- dep_types.sort { |a,b| a.to_s <=> b.to_s }.each do |dep, dep_args|
+ dep_types.sort { |a, b| a.to_s <=> b.to_s }.each do |dep, dep_args|
check_with = dep_args.shift
normalized_version = dep_args.pop
describe dep do
@@ -274,7 +274,6 @@ describe Chef::Cookbook::Metadata do
end
end
-
describe "in the obsoleted format" do
dep_types = {
:depends => [ "foo::bar", "> 0.2", "< 1.0" ],
@@ -287,12 +286,11 @@ describe Chef::Cookbook::Metadata do
dep_types.each do |dep, dep_args|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
- expect {metadata.send(dep, *dep_args)}.to raise_error(Chef::Exceptions::ObsoleteDependencySyntax)
+ expect { metadata.send(dep, *dep_args) }.to raise_error(Chef::Exceptions::ObsoleteDependencySyntax)
end
end
end
-
describe "with obsolete operators" do
dep_types = {
:depends => [ "foo::bar", ">> 0.2"],
@@ -305,7 +303,7 @@ describe Chef::Cookbook::Metadata do
dep_types.each do |dep, dep_args|
it "for #{dep} raises an informative error instead of vomiting on your shoes" do
- expect {metadata.send(dep, *dep_args)}.to raise_error(Chef::Exceptions::InvalidVersionConstraint)
+ expect { metadata.send(dep, *dep_args) }.to raise_error(Chef::Exceptions::InvalidVersionConstraint)
end
end
end
@@ -345,11 +343,11 @@ describe Chef::Cookbook::Metadata do
end
it "should work with multiple simple constraints" do
- expect_chef_version_works(["~> 12.5.1"],["~> 11.18.10"])
+ expect_chef_version_works(["~> 12.5.1"], ["~> 11.18.10"])
end
it "should work with multiple complex constraints" do
- expect_chef_version_works([">= 11.14.2", "< 11.18.10"],[">= 12.2.1", "< 12.5.1"])
+ expect_chef_version_works([">= 11.14.2", "< 11.18.10"], [">= 12.2.1", "< 12.5.1"])
end
it "should fail validation on a simple pessimistic constraint" do
@@ -368,12 +366,12 @@ describe Chef::Cookbook::Metadata do
end
it "should fail validation when all ranges fail" do
- expect_chef_version_works([">= 999.0", "< 999.9"],[">= 0.0.1", "< 0.0.9"])
+ expect_chef_version_works([">= 999.0", "< 999.9"], [">= 0.0.1", "< 0.0.9"])
expect { metadata.validate_chef_version! }.to raise_error(Chef::Exceptions::CookbookChefVersionMismatch)
end
it "should pass validation when one constraint passes" do
- expect_chef_version_works([">= 999.0", "< 999.9"],["= #{Chef::VERSION}"])
+ expect_chef_version_works([">= 999.0", "< 999.9"], ["= #{Chef::VERSION}"])
expect { metadata.validate_chef_version! }.not_to raise_error
end
end
@@ -397,11 +395,11 @@ describe Chef::Cookbook::Metadata do
end
it "should work with multiple simple constraints" do
- expect_ohai_version_works(["~> 12.5.1"],["~> 11.18.10"])
+ expect_ohai_version_works(["~> 12.5.1"], ["~> 11.18.10"])
end
it "should work with multiple complex constraints" do
- expect_ohai_version_works([">= 11.14.2", "< 11.18.10"],[">= 12.2.1", "< 12.5.1"])
+ expect_ohai_version_works([">= 11.14.2", "< 11.18.10"], [">= 12.2.1", "< 12.5.1"])
end
it "should fail validation on a simple pessimistic constraint" do
@@ -420,12 +418,12 @@ describe Chef::Cookbook::Metadata do
end
it "should fail validation when all ranges fail" do
- expect_ohai_version_works([">= 999.0", "< 999.9"],[">= 0.0.1", "< 0.0.9"])
+ expect_ohai_version_works([">= 999.0", "< 999.9"], [">= 0.0.1", "< 0.0.9"])
expect { metadata.validate_ohai_version! }.to raise_error(Chef::Exceptions::CookbookOhaiVersionMismatch)
end
it "should pass validation when one constraint passes" do
- expect_ohai_version_works([">= 999.0", "< 999.9"],["= #{Ohai::VERSION}"])
+ expect_ohai_version_works([">= 999.0", "< 999.9"], ["= #{Ohai::VERSION}"])
expect { metadata.validate_ohai_version! }.not_to raise_error
end
end
@@ -540,22 +538,22 @@ describe Chef::Cookbook::Metadata do
expect(metadata.attributes["db/mysql/databases"][:choice]).to eq([])
end
- it "should let calculated be true or false" do
- expect {
- metadata.attribute("db/mysql/databases", :calculated => true)
- }.not_to raise_error
- expect {
- metadata.attribute("db/mysql/databases", :calculated => false)
- }.not_to raise_error
- expect {
- metadata.attribute("db/mysql/databases", :calculated => Hash.new)
- }.to raise_error(ArgumentError)
- end
+ it "should let calculated be true or false" do
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => true)
+ }.not_to raise_error
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => false)
+ }.not_to raise_error
+ expect {
+ metadata.attribute("db/mysql/databases", :calculated => Hash.new)
+ }.to raise_error(ArgumentError)
+ end
- it "should set calculated to false by default" do
- metadata.attribute("db/mysql/databases", {})
- expect(metadata.attributes["db/mysql/databases"][:calculated]).to eq(false)
- end
+ it "should set calculated to false by default" do
+ metadata.attribute("db/mysql/databases", {})
+ expect(metadata.attributes["db/mysql/databases"][:calculated]).to eq(false)
+ end
it "accepts String for the attribute type" do
expect {
@@ -578,11 +576,11 @@ describe Chef::Cookbook::Metadata do
}.not_to raise_error
end
- it "should let type be hash (backwards compatibility only)" do
+ it "should let type be hash (backwards compatibility only)" do
expect {
metadata.attribute("db/mysql/databases", :type => "hash")
}.not_to raise_error
- end
+ end
it "should let required be required, recommended or optional" do
expect {
@@ -847,7 +845,6 @@ describe Chef::Cookbook::Metadata do
let(:deserialized_metadata) { Chef::Cookbook::Metadata.from_json(Chef::JSONCompat.to_json(metadata)) }
-
it "should deserialize to a Chef::Cookbook::Metadata object" do
expect(deserialized_metadata).to be_a_kind_of(Chef::Cookbook::Metadata)
end
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index d8f7f7d293..c869ee8ff3 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -93,7 +93,7 @@ describe Chef::CookbookSynchronizer do
let(:cookbook_a_manifest) do
segments = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ]
- cookbook_a_manifest = segments.inject({}) {|h, segment| h[segment.to_s] = []; h}
+ cookbook_a_manifest = segments.inject({}) { |h, segment| h[segment.to_s] = []; h }
cookbook_a_manifest["recipes"] = [ cookbook_a_default_recipe ]
cookbook_a_manifest["attributes"] = [ cookbook_a_default_attrs ]
cookbook_a_manifest["templates"] = [ cookbook_a_template ]
@@ -157,7 +157,7 @@ describe Chef::CookbookSynchronizer do
let(:file_cache) { double("Chef::FileCache with files from unused cookbooks") }
let(:cookbook_manifest) do
- {"valid1"=> {}, "valid2" => {}}
+ { "valid1" => {}, "valid2" => {} }
end
it "removes unneeded cookbooks" do
@@ -175,7 +175,7 @@ describe Chef::CookbookSynchronizer do
let(:file_cache) { double("Chef::FileCache with files from unused cookbooks") }
let(:cookbook_manifest) do
- {"valid1"=> {}, "valid2" => {}}
+ { "valid1" => {}, "valid2" => {} }
end
it "removes only deleted files" do
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index 02762535ce..6d0ce96870 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -38,7 +38,7 @@ describe Chef::Cookbook::SyntaxCheck do
recipes/default.rb
recipes/gigantor.rb
recipes/one.rb
- recipes/return.rb }.map{ |f| File.join(cookbook_path, f) }
+ recipes/return.rb }.map { |f| File.join(cookbook_path, f) }
end
before do
@@ -48,7 +48,7 @@ describe Chef::Cookbook::SyntaxCheck do
@attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, "attributes", f) }
@libr_files = %w{openldap.rb openldap/version.rb}.map { |f| File.join(cookbook_path, "libraries", f) }
- @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, "definitions", f)}
+ @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, "definitions", f) }
@recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, "recipes", f) }
@ruby_files = @attr_files + @libr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")]
basenames = %w{ helpers_via_partial_test.erb
@@ -62,7 +62,7 @@ describe Chef::Cookbook::SyntaxCheck do
some_windows_line_endings.erb
all_windows_line_endings.erb
no_windows_line_endings.erb }
- @template_files = basenames.map { |f| File.join(cookbook_path, "templates", "default", f)}
+ @template_files = basenames.map { |f| File.join(cookbook_path, "templates", "default", f) }
end
after do
@@ -171,7 +171,7 @@ describe Chef::Cookbook::SyntaxCheck do
it "does not remove the invalid template from the list of untested templates" do
expect(syntax_check.untested_template_files).to include(File.join(cookbook_path, "templates", "default", "borken.erb"))
- expect {syntax_check.validate_templates}.not_to change(syntax_check, :untested_template_files)
+ expect { syntax_check.validate_templates }.not_to change(syntax_check, :untested_template_files)
end
end