From aebf7ba8d32a29fd4f5105a76aa4e1820f939bb8 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Wed, 9 Apr 2014 08:40:25 -0700 Subject: Wrap code in an instance_eval context for syntax check. This evaluates the code in a context similar to what Chef does when compiling recipes, so that idioms like using `return` to end evaluation of a recipe will work. --- spec/unit/cookbook/syntax_check_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'spec/unit/cookbook/syntax_check_spec.rb') diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb index a674f6ab40..7f7a914115 100644 --- a/spec/unit/cookbook/syntax_check_spec.rb +++ b/spec/unit/cookbook/syntax_check_spec.rb @@ -24,7 +24,7 @@ describe Chef::Cookbook::SyntaxCheck do let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap') } let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) } - let(:open_ldap_cookbook_files) { + let(:open_ldap_cookbook_files) do %w{ attributes/default.rb attributes/smokey.rb definitions/client.rb @@ -32,8 +32,9 @@ describe Chef::Cookbook::SyntaxCheck do metadata.rb recipes/default.rb recipes/gigantor.rb - recipes/one.rb }.map{ |f| File.join(cookbook_path, f) } -} + recipes/one.rb + recipes/return.rb }.map{ |f| File.join(cookbook_path, f) } + end before do Chef::Log.logger = Logger.new(StringIO.new) @@ -41,7 +42,7 @@ describe Chef::Cookbook::SyntaxCheck do @attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, 'attributes', f) } @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, 'definitions', f)} - @recipes = %w{default.rb gigantor.rb one.rb}.map { |f| File.join(cookbook_path, 'recipes', f) } + @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, 'recipes', f) } @ruby_files = @attr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")] basenames = %w{ helpers_via_partial_test.erb helper_test.erb -- cgit v1.2.1