mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
assert_changes works on including Assertions class
assert_not_equal is an alias for refute_equal that is defined only on the class ActiveSupport::TestCase. This commit ensures ActiveSupport::Testing::Assertions#assert_changes doesn't depends on ActiveSupport::TestCase to work.
This commit is contained in:
parent
5db5de5341
commit
f6ffdcfcff
2 changed files with 17 additions and 1 deletions
|
@ -189,7 +189,7 @@ module ActiveSupport
|
|||
error = "#{expression.inspect} didn't change"
|
||||
error = "#{error}. It was already #{to}" if before == to
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert_not_equal before, after, error
|
||||
refute_equal before, after, error
|
||||
|
||||
unless to == UNTRACKED
|
||||
error = "Expected change to #{to}\n"
|
||||
|
|
|
@ -200,4 +200,20 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase
|
|||
assert_equal instance, Level.new
|
||||
end
|
||||
end
|
||||
|
||||
def test_assert_changes_when_assertions_are_included
|
||||
test_unit_class = Class.new(Minitest::Test) do
|
||||
include ActiveSupport::Testing::Assertions
|
||||
|
||||
def test_assert_changes
|
||||
counter = 1
|
||||
assert_changes(-> { counter }) do
|
||||
counter = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test_results = test_unit_class.new(:test_assert_changes).run
|
||||
assert test_results.passed?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue