diff options
Diffstat (limited to 'spec/unit/cookbook/syntax_check_spec.rb')
-rw-r--r-- | spec/unit/cookbook/syntax_check_spec.rb | 36 |
1 files changed, 18 insertions, 18 deletions
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 |