diff options
author | Dan Ott <thedanielott@gmail.com> | 2017-11-06 10:56:24 -0500 |
---|---|---|
committer | Dan Ott <thedanielott@gmail.com> | 2017-11-06 12:16:49 -0500 |
commit | 1fe7168df0a23b69539b60327943495a3dded9e5 (patch) | |
tree | 93ce7dfb318015fe550cad8940003b389813450b /activesupport | |
parent | 0ddde0a8fca6a0ca3158e3329713959acd65605d (diff) | |
download | rails-1fe7168df0a23b69539b60327943495a3dded9e5.tar.gz rails-1fe7168df0a23b69539b60327943495a3dded9e5.tar.bz2 rails-1fe7168df0a23b69539b60327943495a3dded9e5.zip |
Resolve Minitest 6 deprecation in assert_no_changes
These changes resolve a deprecation warning in `assert_no_changes`
when asserting that an expression evaluates to `nil` before and after
the passed block is evaluated.
The smallest demonstration of this edge case:
```ruby
assert_no_changes "nil" do
true # noop
end
```
Under the covers, this is evaluating
```ruby
assert_equal nil, nil
```
Minitest 5 issues a deprecation warning, and Minitest will fail
completely.
For additional context, the motivations and implications of this change
to Minitest have been discussed at length in [seattlerb/minitest#666][].
[seattlerb/minitest#666]: https://github.com/seattlerb/minitest/issues/666
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/testing/assertions.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index e2bc51ff7a..46eed73d24 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -190,7 +190,12 @@ module ActiveSupport error = "#{expression.inspect} did change to #{after}" error = "#{message}.\n#{error}" if message - assert_equal before, after, error + + if before.nil? + assert_nil after, error + else + assert_equal before, after, error + end retval end |