Permalink
Browse files

Fix for 1.9.2 compatibility.

  • Loading branch information...
1 parent 1e5939a commit 376774b0994215470ac49ff67ad475b75da43288 @acrmp acrmp committed Jul 22, 2012
Showing with 6 additions and 13 deletions.
  1. +6 −13 lib/chefspec/minitest.rb
View
@@ -51,7 +51,6 @@ def self.override_minitest_assertions(chef_run)
remove_file_id_conversion
::MiniTest::Chef::Assertions.class_eval do
- @@chef_run = chef_run
def assert_includes_content(file, content)
assert file_includes_content?(file, content),
@@ -83,14 +82,6 @@ def refute_path_exists(file_or_dir)
private
- def resources
- @@chef_run.resources
- end
-
- def run_context
- @@chef_run.run_context
- end
-
def same_resource_type?(expected_resource, actual_resource)
case actual_resource.resource_name.to_s
when /file$/
@@ -171,9 +162,9 @@ def file_includes_content?(file, content)
end
end
- def self.share_node_object(node, spec_mod)
- spec_mod.send(:define_method, :node) do
- node
+ def self.share_object(spec_mod, name, obj)
+ spec_mod.send(:define_method, name) do
+ obj
end
end
@@ -186,7 +177,9 @@ def self.support_fake_converge(spec_mod)
:cookbook_path => default_cookbook_path).converge recipe_for_module(spec_mod)
override_minitest_resources(chef_run.run_context, spec_mod)
override_minitest_assertions(chef_run)
- share_node_object(chef_run.node, spec_mod)
+ share_object(spec_mod, :node, chef_run.node)
+ share_object(spec_mod, :resources, chef_run.resources)
+ share_object(spec_mod, :run_context, chef_run.run_context)
end
def self.recipe_for_module(mod)

0 comments on commit 376774b

Please sign in to comment.