Skip to content

Commit

Permalink
Remove unused arg for HashMethods#mocha_inspect
Browse files Browse the repository at this point in the history
This was introduced in this commit [1] apparently as a precursor to the
addition of ParameterMatchers::HasKeys in this commit [2]. However, the
latter only actually used the new optional `wrapped` argument when
calling ArrayMethods#mocha_inspect, and so I think the change to
HashMethods#mocha_inspect was unnecessary.

Since HashMethods#mocha_inspect is not a published part of the API, this
shouldn't require a major version bump.

Thanks to @wasabigeek for highlighting [3] this issue in
wasabigeek#2.

[1]: d8f44bc
[2]: 18d8104
[3]: https://github.com/wasabigeek/mocha/pull/2/files#r989194611
  • Loading branch information
floehopper committed Oct 9, 2022
1 parent af2194c commit 4f59e27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/mocha/inspect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def mocha_inspect(wrapped = true)
end

module HashMethods
def mocha_inspect(wrapped = true)
def mocha_inspect
unwrapped = collect { |key, value| "#{key.mocha_inspect} => #{value.mocha_inspect}" }.join(', ')
wrapped ? "{#{unwrapped}}" : unwrapped
"{#{unwrapped}}"
end
end

Expand Down
5 changes: 0 additions & 5 deletions test/unit/hash_inspect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ def test_should_keep_spacing_between_key_value
assert_equal '{:a => true}', hash.mocha_inspect
end

def test_should_return_unwrapped_hash_when_wrapped_is_false
hash = { :a => true }
assert_equal ':a => true', hash.mocha_inspect(false)
end

def test_should_use_mocha_inspect_on_each_item
hash = { :a => 'mocha' }
assert_equal %({:a => "mocha"}), hash.mocha_inspect
Expand Down

0 comments on commit 4f59e27

Please sign in to comment.