def test_blocks_can_return_for_methods
assert_nothing_raised do
blk{return}
end
end
def test_blocks_cannot_return_for_methods
assert_raise LocalJumpError do
blk{return}
end
end
end
#In fact it calling a method with a block with top level return raises
a LocalJumpError. So why is the assert_nothing_raised do; blk{return};
end passing?
Thanks,
Tim
#In fact, calling a method within a block with top level return
raises
a LocalJumpError. So why is the assert_nothing_raised do;
blk{return};
end passing?
Thanks,
Tim
One last try: #In fact, calling a method with a block with top level return
raises a LocalJumpError. So why is the assert_nothing_raised do;
blk{return}; end passing?
probably because it returns from your test method without further
processing the assert_nothing_raised call. It’s placed correctly, as
it’s within a method and evaluated while the method is still on the
stack
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.