mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #33612 from bogdanvlviv/test-assert_called
Test `assert_called` and `assert_called_with`
This commit is contained in:
commit
111643b8a3
1 changed files with 10 additions and 0 deletions
|
@ -36,6 +36,8 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase
|
||||||
assert_called(@object, :increment, returns: 10) do
|
assert_called(@object, :increment, returns: 10) do
|
||||||
assert_equal 10, @object.increment
|
assert_equal 10, @object.increment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_equal 1, @object.increment
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assert_called_failure
|
def test_assert_called_failure
|
||||||
|
@ -70,6 +72,14 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_assert_called_with_arguments_and_returns
|
||||||
|
assert_called_with(@object, :<<, [ 2 ], returns: 10) do
|
||||||
|
assert_equal(10, @object << 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_nil(@object << 2)
|
||||||
|
end
|
||||||
|
|
||||||
def test_assert_called_with_failure
|
def test_assert_called_with_failure
|
||||||
assert_raises(MockExpectationError) do
|
assert_raises(MockExpectationError) do
|
||||||
assert_called_with(@object, :<<, [ 4567 ]) do
|
assert_called_with(@object, :<<, [ 4567 ]) do
|
||||||
|
|
Loading…
Reference in a new issue