Module: Minitest::Rails::Expectations::ActiveSupport
- Included in:
- Object
- Defined in:
- lib/minitest/rails/expectations/active_support.rb
Instance Method Summary collapse
-
#assert_changes ⇒ Object
Assertion that the result of evaluating an expression is changed before and after invoking the passed in block.
-
#assert_difference ⇒ Object
Test numeric difference between the return value of an expression as a result of what is evaluated.
-
#refute_changes ⇒ Object
Assertion that the result of evaluating an expression is not changed before and after invoking the passed in block.
-
#refute_difference ⇒ Object
Assertion that the numeric result of evaluating an expression is not changed before and after invoking.
Instance Method Details
#assert_changes ⇒ Object
Assertion that the result of evaluating an expression is changed before and after invoking the passed in block.
value { User.create password: "valid" }.must_change "User.count"
value { 3.times do
User.create password: "valid"
end }.must_change "User.count", from: 5, to: 8
See also ActiveSupport::TestCase#assert_difference See api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes
:method: must_change :args: expression, from: UNTRACKED, to: UNTRACKED
19 |
# File 'lib/minitest/rails/expectations/active_support.rb', line 19 infect_an_assertion :assert_changes, :must_change, :block |
#assert_difference ⇒ Object
Test numeric difference between the return value of an expression as a result of what is evaluated.
value { User.create password: "valid" }.must_differ "User.count"
value { 3.times do
User.create password: "valid"
end }.must_differ "User.count", 3
See also ActiveSupport::TestCase#assert_difference See api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
:method: must_differ :args: expression, *args
50 |
# File 'lib/minitest/rails/expectations/active_support.rb', line 50 infect_an_assertion :assert_difference, :must_differ, :block |
#refute_changes ⇒ Object
Assertion that the result of evaluating an expression is not changed before and after invoking the passed in block.
refute_changes "Status.all_good?" do
post :create, params: { status: { ok: true } }
end
See also ActiveSupport::TestCase#assert_difference See api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes
:method: wont_change :args: expression
34 |
# File 'lib/minitest/rails/expectations/active_support.rb', line 34 infect_an_assertion :refute_changes, :wont_change, :block |
#refute_difference ⇒ Object
Assertion that the numeric result of evaluating an expression is not changed before and after invoking.
value { User.new }.wont_differ "User.count"
See also ActiveSupport::TestCase#refute_difference See api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
:method: wont_differ :args: expression
63 |
# File 'lib/minitest/rails/expectations/active_support.rb', line 63 infect_an_assertion :refute_difference, :wont_differ, :block |