summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2016-01-14 14:08:03 +0000
committerThom May <thom@chef.io>2016-01-14 14:08:03 +0000
commit51cfbdc4d16739caac4d946fadbe678444aafe34 (patch)
tree56dfd8f1cd9fd933de27268b32402e955a43ac2b /spec/unit/cookbook
parent05064423057d4cf46f4713b81b08829cf6d20af6 (diff)
downloadchef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go along with chef/chefstyle#5 . We should pick something and use it consistently, and my opinion is that double quotes are the appropriate thing.
Diffstat (limited to 'spec/unit/cookbook')
-rw-r--r--spec/unit/cookbook/chefignore_spec.rb12
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb6
-rw-r--r--spec/unit/cookbook/file_vendor_spec.rb2
-rw-r--r--spec/unit/cookbook/metadata_spec.rb44
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb30
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb36
6 files changed, 65 insertions, 65 deletions
diff --git a/spec/unit/cookbook/chefignore_spec.rb b/spec/unit/cookbook/chefignore_spec.rb
index 9f5546de28..9d81981dcf 100644
--- a/spec/unit/cookbook/chefignore_spec.rb
+++ b/spec/unit/cookbook/chefignore_spec.rb
@@ -15,11 +15,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::Chefignore do
before do
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'cookbooks'))
+ @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "cookbooks"))
end
it "loads the globs in the chefignore file" do
@@ -32,14 +32,14 @@ describe Chef::Cookbook::Chefignore do
end
it "determines if a file is ignored" do
- expect(@chefignore.ignored?('ignored')).to be_truthy
- expect(@chefignore.ignored?('recipes/ignoreme.rb')).to be_truthy
- expect(@chefignore.ignored?('recipes/dontignoreme.rb')).to be_falsey
+ expect(@chefignore.ignored?("ignored")).to be_truthy
+ expect(@chefignore.ignored?("recipes/ignoreme.rb")).to be_truthy
+ expect(@chefignore.ignored?("recipes/dontignoreme.rb")).to be_falsey
end
context "when using the single cookbook pattern" do
before do
- @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'standalone_cookbook'))
+ @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "standalone_cookbook"))
end
it "loads the globs in the chefignore file" do
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index 23ffc21f7f..1a0c1ddf94 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::CookbookVersionLoader do
before do
@@ -58,8 +58,8 @@ describe Chef::Cookbook::CookbookVersionLoader do
end
it "loads libraries" do
- expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap.rb'))
- expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap/version.rb'))
+ expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap.rb"))
+ expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap/version.rb"))
end
it "loads static files in the files/ dir" do
diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb
index 8bf2d3c2a3..2420718dea 100644
--- a/spec/unit/cookbook/file_vendor_spec.rb
+++ b/spec/unit/cookbook/file_vendor_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Cookbook::FileVendor do
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 48b0b2a059..ad4863ad3d 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/cookbook/metadata'
+require "spec_helper"
+require "chef/cookbook/metadata"
describe Chef::Cookbook::Metadata do
@@ -142,11 +142,11 @@ describe Chef::Cookbook::Metadata do
end
it "has an empty source_url string" do
- expect(metadata.source_url).to eq('')
+ expect(metadata.source_url).to eq("")
end
it "has an empty issues_url string" do
- expect(metadata.issues_url).to eq('')
+ expect(metadata.issues_url).to eq("")
end
it "is not private" do
@@ -189,7 +189,7 @@ describe Chef::Cookbook::Metadata do
describe "adding a supported platform" do
it "should support adding a supported platform with a single expression" do
metadata.supports("ubuntu", ">= 8.04")
- expect(metadata.platforms["ubuntu"]).to eq('>= 8.04')
+ expect(metadata.platforms["ubuntu"]).to eq(">= 8.04")
end
end
@@ -311,17 +311,17 @@ describe Chef::Cookbook::Metadata do
end
it "strips out self-dependencies", :chef_lt_13_only do
- metadata.name('foo')
+ metadata.name("foo")
expect(Chef::Log).to receive(:warn).with(
"Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)."
)
- metadata.depends('foo')
+ metadata.depends("foo")
expect(metadata.dependencies).to eql({})
end
it "errors on self-dependencies", :chef_gte_13_only do
- metadata.name('foo')
- expect { metadata.depends('foo') }.to raise_error
+ metadata.name("foo")
+ expect { metadata.depends("foo") }.to raise_error
# FIXME: add the error type
end
end
@@ -462,10 +462,10 @@ describe Chef::Cookbook::Metadata do
attrs = {
"display_name" => "MySQL Databases",
"description" => "Description of MySQL",
- "choice" => ['dedicated', 'shared'],
+ "choice" => ["dedicated", "shared"],
"calculated" => false,
- "type" => 'string',
- "required" => 'recommended',
+ "type" => "string",
+ "required" => "recommended",
"recipes" => [ "mysql::server", "mysql::master" ],
"default" => [ ],
"source_url" => "http://example.com",
@@ -519,16 +519,16 @@ describe Chef::Cookbook::Metadata do
metadata.attribute("db/mysql/databases", :privacy => false)
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :privacy => 'true')
+ metadata.attribute("db/mysql/databases", :privacy => "true")
}.to raise_error(ArgumentError)
end
it "should not accept anything but an array of strings for choice" do
expect {
- metadata.attribute("db/mysql/databases", :choice => ['dedicated', 'shared'])
+ metadata.attribute("db/mysql/databases", :choice => ["dedicated", "shared"])
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :choice => [10, 'shared'])
+ metadata.attribute("db/mysql/databases", :choice => [10, "shared"])
}.to raise_error(ArgumentError)
expect {
metadata.attribute("db/mysql/databases", :choice => Hash.new)
@@ -586,13 +586,13 @@ describe Chef::Cookbook::Metadata do
it "should let required be required, recommended or optional" do
expect {
- metadata.attribute("db/mysql/databases", :required => 'required')
+ metadata.attribute("db/mysql/databases", :required => "required")
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :required => 'recommended')
+ metadata.attribute("db/mysql/databases", :required => "recommended")
}.not_to raise_error
expect {
- metadata.attribute("db/mysql/databases", :required => 'optional')
+ metadata.attribute("db/mysql/databases", :required => "optional")
}.not_to raise_error
end
@@ -612,7 +612,7 @@ describe Chef::Cookbook::Metadata do
it "should set required to 'optional' by default" do
metadata.attribute("db/mysql/databases", {})
- expect(metadata.attributes["db/mysql/databases"][:required]).to eq('optional')
+ expect(metadata.attributes["db/mysql/databases"][:required]).to eq("optional")
end
it "should make sure recipes is an array" do
@@ -742,7 +742,7 @@ describe Chef::Cookbook::Metadata do
describe "recipes" do
let(:cookbook) do
- c = Chef::CookbookVersion.new('test_cookbook')
+ c = Chef::CookbookVersion.new("test_cookbook")
c.recipe_files = [ "default.rb", "enlighten.rb" ]
c
end
@@ -894,13 +894,13 @@ describe Chef::Cookbook::Metadata do
it "should transform deprecated greater than syntax for :#{to_check}" do
@hash[to_check.to_s]["foo::bar"] = ">> 0.2"
deserial = Chef::Cookbook::Metadata.from_hash(@hash)
- expect(deserial.send(to_check)["foo::bar"]).to eq('> 0.2')
+ expect(deserial.send(to_check)["foo::bar"]).to eq("> 0.2")
end
it "should transform deprecated less than syntax for :#{to_check}" do
@hash[to_check.to_s]["foo::bar"] = "<< 0.2"
deserial = Chef::Cookbook::Metadata.from_hash(@hash)
- expect(deserial.send(to_check)["foo::bar"]).to eq('< 0.2')
+ expect(deserial.send(to_check)["foo::bar"]).to eq("< 0.2")
end
it "should ignore multiple dependency constraints for :#{to_check}" do
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 30ddaad1d7..17803a8392 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require 'chef/cookbook/synchronizer'
-require 'chef/cookbook_version'
+require "spec_helper"
+require "chef/cookbook/synchronizer"
+require "chef/cookbook_version"
describe Chef::CookbookCacheCleaner do
describe "when cleaning up unused cookbook components" do
@@ -164,8 +164,8 @@ describe Chef::CookbookSynchronizer do
valid_cached_cb_files = %w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb}
obsolete_cb_files = %w{cookbooks/old1/recipes/default.rb cookbooks/old2/recipes/default.rb}
expect(file_cache).to receive(:find).with(File.join(%w{cookbooks ** {*,.*}})).and_return(valid_cached_cb_files + obsolete_cb_files)
- expect(file_cache).to receive(:delete).with('cookbooks/old1/recipes/default.rb')
- expect(file_cache).to receive(:delete).with('cookbooks/old2/recipes/default.rb')
+ expect(file_cache).to receive(:delete).with("cookbooks/old1/recipes/default.rb")
+ expect(file_cache).to receive(:delete).with("cookbooks/old2/recipes/default.rb")
allow(synchronizer).to receive(:cache).and_return(file_cache)
synchronizer.remove_old_cookbooks
end
@@ -186,7 +186,7 @@ describe Chef::CookbookSynchronizer do
expect(synchronizer).to receive(:have_cookbook?).with("valid1").at_least(:once).and_return(true)
# valid2 is a cookbook not in our run_list (we're simulating an override run_list where valid2 needs to be preserved)
expect(synchronizer).to receive(:have_cookbook?).with("valid2").at_least(:once).and_return(false)
- expect(file_cache).to receive(:delete).with('cookbooks/valid1/recipes/deleted.rb')
+ expect(file_cache).to receive(:delete).with("cookbooks/valid1/recipes/deleted.rb")
expect(synchronizer).to receive(:cookbook_segment).with("valid1", "recipes").at_least(:once).and_return([ { "path" => "recipes/default.rb" }])
allow(synchronizer).to receive(:cache).and_return(file_cache)
synchronizer.remove_deleted_files
@@ -224,7 +224,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb recipe
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc123').
+ with("http://chef.example.com/abc123").
and_return(cookbook_a_default_recipe_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
@@ -234,7 +234,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc456').
+ with("http://chef.example.com/abc456").
and_return(cookbook_a_default_attribute_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
@@ -252,7 +252,7 @@ describe Chef::CookbookSynchronizer do
and_return(false)
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/megaman.conf').
+ with("http://chef.example.com/megaman.conf").
and_return(cookbook_a_file_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
@@ -261,7 +261,7 @@ describe Chef::CookbookSynchronizer do
and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/ffffff').
+ with("http://chef.example.com/ffffff").
and_return(cookbook_a_template_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
@@ -281,7 +281,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb recipe
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc123').
+ with("http://chef.example.com/abc123").
and_return(cookbook_a_default_recipe_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb")
@@ -297,7 +297,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy default.rb attribute file
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/abc456').
+ with("http://chef.example.com/abc456").
and_return(cookbook_a_default_attribute_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb")
@@ -323,7 +323,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy megaman.conf
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/megaman.conf').
+ with("http://chef.example.com/megaman.conf").
and_return(cookbook_a_file_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
@@ -334,7 +334,7 @@ describe Chef::CookbookSynchronizer do
# Fetch and copy apache2.conf template
expect(server_api).to receive(:streaming_request).
- with('http://chef.example.com/ffffff').
+ with("http://chef.example.com/ffffff").
and_return(cookbook_a_template_default_tempfile)
expect(file_cache).to receive(:move_to).
with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
@@ -442,7 +442,7 @@ describe Chef::CookbookSynchronizer do
it "does not fetch templates or cookbook files" do
# Implicitly tested in previous test; this test is just for behavior specification.
expect(server_api).not_to receive(:streaming_request).
- with('http://chef.example.com/ffffff')
+ with("http://chef.example.com/ffffff")
synchronizer.sync_cookbooks
end
diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb
index efdb5b7926..ad270ae712 100644
--- a/spec/unit/cookbook/syntax_check_spec.rb
+++ b/spec/unit/cookbook/syntax_check_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
require "chef/cookbook/syntax_check"
describe Chef::Cookbook::SyntaxCheck do
@@ -24,7 +24,7 @@ describe Chef::Cookbook::SyntaxCheck do
allow(ChefConfig).to receive(:windows?) { false }
end
- let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap') }
+ let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks", "openldap") }
let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) }
let(:open_ldap_cookbook_files) do
@@ -46,10 +46,10 @@ describe Chef::Cookbook::SyntaxCheck do
@original_log_level = Chef::Log.level
Chef::Log.level = :warn # suppress "Syntax OK" messages
- @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)}
- @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, 'recipes', f) }
+ @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)}
+ @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
helper_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
@@ -77,18 +77,18 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "creates a syntax checker given the cookbook name and cookbook_path" do
- syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, 'cookbooks'))
+ syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, "cookbooks"))
expect(syntax_check.cookbook_path).to eq(cookbook_path)
expect(syntax_check.ruby_files.sort).to eq(open_ldap_cookbook_files.sort)
end
context "when using a standalone cookbook" do
- let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'standalone_cookbook') }
+ let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "standalone_cookbook") }
it "creates a syntax checker given the cookbook name and cookbook_path for a standalone cookbook" do
syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:standalone_cookbook, CHEF_SPEC_DATA)
expect(syntax_check.cookbook_path).to eq(cookbook_path)
- expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, 'recipes/default.rb')])
+ expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, "recipes/default.rb")])
end
end
@@ -128,13 +128,13 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "removes a ruby file from the list of untested files after it is marked as validated" do
- recipe = File.join(cookbook_path, 'recipes', 'default.rb')
+ recipe = File.join(cookbook_path, "recipes", "default.rb")
syntax_check.validated(recipe)
expect(syntax_check.untested_ruby_files).not_to include(recipe)
end
it "removes a template file from the list of untested files after it is marked as validated" do
- template = File.join(cookbook_path, 'templates', 'default', 'test.erb')
+ template = File.join(cookbook_path, "templates", "default", "test.erb")
syntax_check.validated(template)
expect(syntax_check.untested_template_files).not_to include(template)
end
@@ -151,7 +151,7 @@ describe Chef::Cookbook::SyntaxCheck do
describe "and a file has a syntax error" do
before do
- cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'borken')
+ cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "borken")
syntax_check.cookbook_path.replace(cookbook_path)
end
@@ -160,9 +160,9 @@ describe Chef::Cookbook::SyntaxCheck do
end
it "does not remove the invalid file from the list of untested files" do
- expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb'))
+ expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb"))
syntax_check.validate_ruby_files
- expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb'))
+ expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb"))
end
it "indicates that a template file has a syntax error" do
@@ -170,7 +170,7 @@ describe Chef::Cookbook::SyntaxCheck do
end
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.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)
end
@@ -178,10 +178,10 @@ describe Chef::Cookbook::SyntaxCheck do
describe "and an ignored file has a syntax error" do
before do
- cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'ignorken')
+ cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "ignorken")
Chef::Config[:cookbook_path] = File.dirname(cookbook_path)
syntax_check.cookbook_path.replace(cookbook_path)
- @ruby_files = [File.join(cookbook_path, 'metadata.rb'), File.join(cookbook_path, 'recipes/default.rb')]
+ @ruby_files = [File.join(cookbook_path, "metadata.rb"), File.join(cookbook_path, "recipes/default.rb")]
end
it "shows that ignored ruby files do not require a syntax check" do