From 4dea01a4b95fae9c29f751362c583c28b0fb9eba Mon Sep 17 00:00:00 2001 From: Nitish Rathi Date: Wed, 30 Oct 2019 21:24:38 +0000 Subject: [PATCH] use consistent phrasing for configured & invoked times --- lib/mocha/cardinality.rb | 5 +++-- ...play_matching_invocations_alongside_expectations_test.rb | 2 +- test/acceptance/exception_rescue_test.rb | 2 +- test/acceptance/expected_invocation_count_test.rb | 4 ++-- .../stub_any_instance_method_defined_on_superclass_test.rb | 2 +- .../stub_class_method_defined_on_superclass_test.rb | 2 +- test/integration/shared_tests.rb | 6 +++--- test/unit/expectation_test.rb | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/mocha/cardinality.rb b/lib/mocha/cardinality.rb index 4df969f37..6a69e662c 100644 --- a/lib/mocha/cardinality.rb +++ b/lib/mocha/cardinality.rb @@ -61,7 +61,7 @@ def anticipated_times if allowed_any_number_of_times? 'allowed any number of times' elsif required.zero? && maximum.zero? - 'expected never' + "expected #{times(maximum)}" elsif required == maximum "expected exactly #{times(required)}" elsif infinite?(maximum) @@ -74,7 +74,7 @@ def anticipated_times end def invoked_times - @invocations.none? ? 'not yet invoked' : "invoked #{times(@invocations.size)}" + "invoked #{times(@invocations.size)}" end def actual_invocations @@ -87,6 +87,7 @@ def actual_invocations def times(number) case number + when 0 then 'never' when 1 then 'once' when 2 then 'twice' else "#{number} times" diff --git a/test/acceptance/display_matching_invocations_alongside_expectations_test.rb b/test/acceptance/display_matching_invocations_alongside_expectations_test.rb index c3339b1e8..f5d39a391 100644 --- a/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +++ b/test/acceptance/display_matching_invocations_alongside_expectations_test.rb @@ -69,7 +69,7 @@ def assert_invocations(test_result, *invocations) assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.bar(1)', + '- expected exactly once, invoked never: #.bar(1)', 'satisfied expectations:', *invocations ], test_result.failure_message_lines diff --git a/test/acceptance/exception_rescue_test.rb b/test/acceptance/exception_rescue_test.rb index e8f4a5608..54905503a 100644 --- a/test/acceptance/exception_rescue_test.rb +++ b/test/acceptance/exception_rescue_test.rb @@ -48,7 +48,7 @@ def test_unsatisfied_expectation_exception_is_not_caught_by_standard_rescue assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.some_method(any_parameters)' + '- expected exactly once, invoked never: #.some_method(any_parameters)' ], test_result.failure_message_lines end end diff --git a/test/acceptance/expected_invocation_count_test.rb b/test/acceptance/expected_invocation_count_test.rb index fc177709a..9067df6a6 100644 --- a/test/acceptance/expected_invocation_count_test.rb +++ b/test/acceptance/expected_invocation_count_test.rb @@ -155,7 +155,7 @@ def test_should_fail_if_method_is_expected_at_least_once_but_is_never_called assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected at least once, not yet invoked: #.method(any_parameters)' + '- expected at least once, invoked never: #.method(any_parameters)' ], test_result.failure_message_lines end @@ -224,7 +224,7 @@ def test_should_fail_fast_if_there_is_no_matching_expectation assert_equal [ 'unexpected invocation: #.method()', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.method(1)' + '- expected exactly once, invoked never: #.method(1)' ], test_result.failure_message_lines end end diff --git a/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb b/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb index 27152c6d0..8087e1c11 100644 --- a/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +++ b/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb @@ -59,7 +59,7 @@ def my_instance_method; end assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.my_instance_method(any_parameters)' + '- expected exactly once, invoked never: #.my_instance_method(any_parameters)' ], test_result.failure_message_lines end end diff --git a/test/acceptance/stub_class_method_defined_on_superclass_test.rb b/test/acceptance/stub_class_method_defined_on_superclass_test.rb index 14797c65c..6b4a74f5f 100644 --- a/test/acceptance/stub_class_method_defined_on_superclass_test.rb +++ b/test/acceptance/stub_class_method_defined_on_superclass_test.rb @@ -138,7 +138,7 @@ def self.my_class_method; end assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: superklass.my_class_method(any_parameters)' + '- expected exactly once, invoked never: superklass.my_class_method(any_parameters)' ], test_result.failure_message_lines end # rubocop:enable Lint/DuplicateMethods diff --git a/test/integration/shared_tests.rb b/test/integration/shared_tests.rb index 00ea88292..f5ef1886f 100644 --- a/test/integration/shared_tests.rb +++ b/test/integration/shared_tests.rb @@ -63,7 +63,7 @@ def test_mock_object_unsatisfied_expectation assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.expected(any_parameters)' + '- expected exactly once, invoked never: #.expected(any_parameters)' ], test_result.failure_message_lines end @@ -101,7 +101,7 @@ def test_mock_object_unsatisfied_expectation_in_setup assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - '- expected exactly once, not yet invoked: #.expected(any_parameters)' + '- expected exactly once, invoked never: #.expected(any_parameters)' ], test_result.failure_message_lines end @@ -151,7 +151,7 @@ def test_real_object_unsatisfied_expectation assert_equal [ 'not all expectations were satisfied', 'unsatisfied expectations:', - "- expected exactly once, not yet invoked: #{object.mocha_inspect}.expected(any_parameters)" + "- expected exactly once, invoked never: #{object.mocha_inspect}.expected(any_parameters)" ], test_result.failure_message_lines end diff --git a/test/unit/expectation_test.rb b/test/unit/expectation_test.rb index 3a37dcd7e..8363df14a 100644 --- a/test/unit/expectation_test.rb +++ b/test/unit/expectation_test.rb @@ -283,7 +283,7 @@ def test_should_verify_successfully_if_expected_call_was_made_at_least_once def test_should_not_verify_successfully_if_expected_call_was_not_made_at_least_once expectation = new_expectation.with(1, 2, 3).at_least_once assert !expectation.verified? - assert_match(/expected at least once, not yet invoked/i, expectation.mocha_inspect) + assert_match(/expected at least once, invoked never/i, expectation.mocha_inspect) end def test_should_verify_successfully_if_expected_call_was_made_expected_number_of_times