class ActiveSupport::TestCase

Public Instance Methods

assert_difference(expression, difference = 1, message = nil, &block) click to toggle source

Checks the numeric difference between the return value of an expression as a result of what is evaluated.

assert_difference "User.count", +1 do
  User.create
end

See also Minitest::Rails::Expectations#must_change

# File lib/minitest/rails/assertions.rb, line 14
  
assert_no_difference(expression, message = nil, &block) click to toggle source

Checks that the numeric result of evaluating an expression is not changed before and after invoking.

assert_no_difference "User.count" do
  User.new
end

See also Minitest::Rails::Expectations#wont_change

# File lib/minitest/rails/assertions.rb, line 26
  
Also aliased as: refute_difference
refute_difference()

Checks that the numeric result of evaluating an expression is not changed before and after invoking.

refute_difference "User.count", do
  User.new
end

See also Minitest::Rails::Expectations#wont_change

:args: expression, message = nil, &block