class ActiveSupport::TestCase

Public Instance Methods

assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block) click to toggle source

Assertion that the result of evaluating an expression is changed before and after invoking the passed in block.

assert_changes "Status.all_good?" do
  post :create, params: { status: { ok: false } }
end

See also Minitest::Rails::Expectations::ActiveSupport#must_change See api.rubyonrails.org/v6.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes

# File lib/minitest/rails/assertions/active_support.rb, line 16
  
assert_difference(expression, *args, &block) click to toggle source

Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.

assert_difference "Article.count" do
  post :create, params: { article: {...} }
end

See also Minitest::Rails::Expectations::ActiveSupport#must_change See api.rubyonrails.org/v6.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference

# File lib/minitest/rails/assertions/active_support.rb, line 44