rails/rails — pull request #11626 by Nerian (2013-07-27 18:33:49+00:00)
Title: Wrap Minitest's assert_raise so that it assert on the message.

Wrap Minitest's assert_raise so that it assert on the message.

There are 14 assertions in the test suite that assert that a particular exception is raised and its message.

Unfortunately Minitest don't test the message part. So all those tests are red herrings. This commit fixes it by wrapping the `assert_raise` method and adding the message assertion.

For example, currently, in `activesupport/test/core_ext/hash_ext_test.rb` if you change the ` "Unknown key: failore"` to something else like `"This should fail"` it won't raise any error. I found this while I was working on https://github.com/rails/rails/pull/11624

```ruby
def test_assert_valid_keys
assert_nothing_raised do
{ :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
{ :failure => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
end

assert_raise(ArgumentError, "Unknown key: failore") do
{ :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
{ :failore => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
end
end
```

With this commit, it will.

You can find all the red herring with this regular expression: `assert_raise\(\S*, "`

I add the method to the base helper of each project. Do we have a singular place where we could put this sort of thing?