Skip to content

Commit

Permalink
Use the generated name in instance_exec (Ruby 1.8.6 only)
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Aug 2, 2010
1 parent 6e6d903 commit 1b63ca2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rspec/mocks/extensions/instance_exec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def instance_exec(*args, &block)
orig_critical, Thread.critical = Thread.critical, true orig_critical, Thread.critical = Thread.critical, true
n = 0 n = 0
n += 1 while respond_to?(method_name="__instance_exec#{n}") 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 ensure
Thread.critical = orig_critical Thread.critical = orig_critical
end end
begin begin
return send(:__instance_exec, *args) return send(method_name, *args)
ensure ensure
singleton_class.module_eval{ remove_method(:__instance_exec) } rescue nil singleton_class.module_eval{ remove_method(method_name) } rescue nil
end end
end end
end end
Expand Down

0 comments on commit 1b63ca2

Please sign in to comment.