From 88439585edbb49ecacce72a4277992f212dbbc75 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Tue, 14 Aug 2018 08:52:42 +0300 Subject: Test `assert_called` and `assert_called_with` - ActiveSupport::Testing::MethodCallAssertions#assert_called - Ensure that the method stubbed by `assert_called` returns correct value after - ActiveSupport::Testing::MethodCallAssertions#assert_called_with - Ensure that `#assert_called_with` stubs the method to return a specific value - Ensure that the method stubbed by `assert_called_with` returns correct value after --- activesupport/test/testing/method_call_assertions_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activesupport/test/testing') diff --git a/activesupport/test/testing/method_call_assertions_test.rb b/activesupport/test/testing/method_call_assertions_test.rb index 0500e47def..5cdeb683e3 100644 --- a/activesupport/test/testing/method_call_assertions_test.rb +++ b/activesupport/test/testing/method_call_assertions_test.rb @@ -36,6 +36,8 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase assert_called(@object, :increment, returns: 10) do assert_equal 10, @object.increment end + + assert_equal 1, @object.increment end def test_assert_called_failure @@ -70,6 +72,14 @@ class MethodCallAssertionsTest < ActiveSupport::TestCase 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 assert_raises(MockExpectationError) do assert_called_with(@object, :<<, [ 4567 ]) do -- cgit v1.2.3