freerange / mocha

A mocking and stubbing library for Ruby
https://mocha.jamesmead.org
Other
1.23k stars 158 forks source link

Improve rendering of keyword arguments #652

Closed floehopper closed 5 months ago

floehopper commented 5 months ago

Using the => for them was a bit confusing.

The string representation of the keyword hash {a: true, b: 'c'} is now 'a: true, b: "c"' instead of ':a => true, :b => "c"'.

One reason (perhaps the only reason?) we didn't make this change when we introduced keyword argument matching was the theoretical edge case where a keyword-style hash could have a non-symbol key.

However, the changes in this commit handle that scenario while still rendering a less-confusing string representation of a keyword hash in the most common scenario where the keys are all symbols.

I've taken @casoerisfine's changes from #649 and added some unit test coverage and expanded the commit note.

floehopper commented 5 months ago

Released in v2.4.0.