Permalink
Browse files

Use the generated name in instance_exec (Ruby 1.8.6 only)

  • Loading branch information...
1 parent 6e6d903 commit 1b63ca2de38ae57d6091a3dded41151dab20c52f @dchelimsky dchelimsky committed Aug 2, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/rspec/mocks/extensions/instance_exec.rb
@@ -15,14 +15,14 @@ def instance_exec(*args, &block)
orig_critical, Thread.critical = Thread.critical, true
n = 0
n += 1 while respond_to?(method_name="__instance_exec#{n}")
- singleton_class.module_eval{ define_method(:__instance_exec, &block) }
+ singleton_class.module_eval{ define_method(method_name, &block) }
ensure
Thread.critical = orig_critical
end
begin
- return send(:__instance_exec, *args)
+ return send(method_name, *args)
ensure
- singleton_class.module_eval{ remove_method(:__instance_exec) } rescue nil
+ singleton_class.module_eval{ remove_method(method_name) } rescue nil
end
end
end

0 comments on commit 1b63ca2

Please sign in to comment.