summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-04-09 08:40:25 -0700
committerdanielsdeleo <dan@getchef.com>2014-04-09 08:40:25 -0700
commitaebf7ba8d32a29fd4f5105a76aa4e1820f939bb8 (patch)
treed5159d08ecf47f62496b0b1306fe3513b0535c57 /spec/unit/cookbook
parent0d7f637b663f53a07ca375d0953658ad283fe6a5 (diff)
downloadchef-aebf7ba8d32a29fd4f5105a76aa4e1820f939bb8.tar.gz
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.
Diffstat (limited to 'spec/unit/cookbook')
-rw-r--r--spec/unit/cookbook/syntax_check_spec.rb9
1 files changed, 5 insertions, 4 deletions
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