rspec/rspec-mocks — pull request #340 by cupakromer (2013-07-04 21:00:16+00:00)
Title: Replace string eval

First pass at replacing all uses of string eval per https://github.com/rspec/rspec-mocks/issues/267

I've tested on 1.8.7-p374, 1.9.3-p392, and 2.0.0-p247.

One potential issue is that I made the decision to use [`Module#class_exec`](http://ruby-doc.org/core-1.8.7/Module.html#method-i-class_exec) which was only added in 1.8.7 and 1.9. I did this for two reasons:

1. It only supports blocks (not possible to pass strings)
2. It provides the ability to directly pass instance variables into the evaluation block, instead of having to exploit the block closure with local variables:

```ruby
# Using class_exec
@klass.class_exec(@method_name) do |method_name|
define_method(method_name) do
# ...
end
end

# Using class_eval
method_name = @method_name
@klass.class_eval do
define_method(method_name) do
# ...
end
end
```

This will break 1.8.6 support. Let me know what you think.