Skip to content

Commit

Permalink
Enable failure message with kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
KnVerey committed Apr 21, 2017
1 parent 1733e0d commit b0a3869
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ def assert_logs_match(regexp, times = nil)
end

alias_method :orig_assert_raises, :assert_raises
def assert_raises(*args)
def assert_raises(*args, msg: nil)
case args.last
when Regexp, String
flunk("Please use assert_raises_msg to check the exception message.\n"\
"That is not what the last argument of assert_raises does.")
flunk("Please use assert_raises_msg to check the exception message,\n"\
"or use the msg keyword argument to specify a message to use when the assertion fails.")
else
orig_assert_raises(*args) { yield }
args_for_orig = (args + Array(msg)).compact
orig_assert_raises(*args_for_orig) { yield }
end
end

Expand Down

0 comments on commit b0a3869

Please sign in to comment.