Skip to content

Commit

Permalink
Check test passed before deprecation warning check
Browse files Browse the repository at this point in the history
The test passing is more important than whether there was a deprecation
warning.

Also it means we can use a guard condition and thus avoid the
indentation in the `if` condition branch which I think makes the tests
more readable.
  • Loading branch information
floehopper committed Jan 4, 2025
1 parent a19bed1 commit 6f51631
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions test/acceptance/loose_keyword_argument_matching_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def test_should_match_hash_parameter_with_keyword_args
mock.method({ key: 42 })
end
end
if Mocha::RUBY_V27_PLUS
assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end
assert_passed(test_result)
return unless Mocha::RUBY_V27_PLUS

assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end

def test_should_match_hash_parameter_with_splatted_keyword_args
Expand All @@ -46,13 +46,13 @@ def test_should_match_hash_parameter_with_splatted_keyword_args
mock.method({ key: 42 })
end
end
if Mocha::RUBY_V27_PLUS
assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end
assert_passed(test_result)
return unless Mocha::RUBY_V27_PLUS

assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end

def test_should_match_positional_and_keyword_args_with_last_positional_hash
Expand All @@ -64,13 +64,13 @@ def test_should_match_positional_and_keyword_args_with_last_positional_hash
mock.method(1, key: 42)
end
end
if Mocha::RUBY_V27_PLUS
assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected positional hash ({key: 42}), but received keyword arguments (key: 42)'
)
end
assert_passed(test_result)
return unless Mocha::RUBY_V27_PLUS

assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected positional hash ({key: 42}), but received keyword arguments (key: 42)'
)
end

def test_should_match_last_positional_hash_with_keyword_args
Expand All @@ -82,13 +82,13 @@ def test_should_match_last_positional_hash_with_keyword_args
mock.method(1, { key: 42 })
end
end
if Mocha::RUBY_V27_PLUS
assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end
assert_passed(test_result)
return unless Mocha::RUBY_V27_PLUS

assert_deprecation_warning_location(test_result, execution_point)
assert_deprecation_warning(
test_result, 'expected keyword arguments (key: 42), but received positional hash ({key: 42})'
)
end

private
Expand Down

0 comments on commit 6f51631

Please sign in to comment.