Do not swallow exception on NameError within constant.

Fixes https://github.com/rails/rails/issues/9933.
there is a PR to switch the whole test to use that helper. Should be fine to start introducing that.