This example should print out :here but it does not, because the non-local return in the define_method block causes the test method to return early.
class Foo
def define(name, &block)
class << self; self; end.send(:define_method, name, block)
end
def define2(name, &block)
define(name, &block)
end
def test
define(:foo) { return 1 }
call_foo
puts :here
end
def call_foo
foo
end
end
Foo.new.test
This is causing mocha's test suite to bail out prematurely.