Skip to content

Commit

Permalink
Make kwarg matcher test more consistent
Browse files Browse the repository at this point in the history
Even though we're not asserting the return value from
`PositionalOrKeywordHash#matches?` in this test, I think it's clearer to
use the same guard condition style to be more consistent with other
tests in the test case.
  • Loading branch information
floehopper committed Jan 4, 2025
1 parent 302e918 commit 9bbeb32
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,17 @@ def test_should_match_keyword_args_with_hash_arg_but_display_deprecation_warning
assert_includes message, 'See the documentation for Mocha::Configuration#strict_keyword_argument_matching=.'
end

if Mocha::RUBY_V27_PLUS
def test_should_display_deprecation_warning_even_if_parent_expectation_is_nil
expectation = nil
matcher = build_matcher({ key_1: 1, key_2: 2 }, expectation)
capture_deprecation_warnings do
matcher.matches?([Hash.ruby2_keywords_hash({ key_1: 1, key_2: 2 })])
end

message = last_deprecation_warning
assert_includes message, 'Expectation expected positional hash ({key_1: 1, key_2: 2})'
assert_includes message, 'but received keyword arguments (key_1: 1, key_2: 2)'
def test_should_display_deprecation_warning_even_if_parent_expectation_is_nil
expectation = nil
matcher = build_matcher({ key_1: 1, key_2: 2 }, expectation)
capture_deprecation_warnings do
matcher.matches?([Hash.ruby2_keywords_hash({ key_1: 1, key_2: 2 })])
end
return unless Mocha::RUBY_V27_PLUS

message = last_deprecation_warning
assert_includes message, 'Expectation expected positional hash ({key_1: 1, key_2: 2})'
assert_includes message, 'but received keyword arguments (key_1: 1, key_2: 2)'
end

private
Expand Down

0 comments on commit 9bbeb32

Please sign in to comment.