1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix asserting the correct exception message in dependencies test

In Minitest, the second argument of assert_raise(s) accepts a string as
the message that should be shown in case of a failure in the assertion
(eg nothing was raised when it should), and not the exception message to
be matched.

To do that we need to save the exception returned from assert_raise(s)
into a local variable and check for the exception message using it.
This commit is contained in:
Carlos Antonio da Silva 2013-12-19 08:47:06 -02:00
parent 813ab76788
commit d799b9c1cf

View file

@ -543,8 +543,8 @@ class DependenciesTest < ActiveSupport::TestCase
require_dependency 'e'
mod = Module.new
msg = 'E cannot be autoloaded from an anonymous class or module'
assert_raise(NameError, msg) { mod::E }
e = assert_raise(NameError) { mod::E }
assert_equal 'E cannot be autoloaded from an anonymous class or module', e.message
end
end