freerange / mocha

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

Fix regression when stubbed method invoked with no arguments #663

Closed floehopper closed 3 months ago

floehopper commented 3 months ago

In this commit which was part of #660 and was released in v2.4.3, the new code didn't take into account that the parameter local variable in HasEntries#matches? can be nil if the stubbed method expects a Hash or keyword arguments but is called with no arguments.

Previously this wasn't a problem, because the nil was handled by this guard condition in HasEntry#matches?. However, now we're calling #length on parameter when exact is true, we need this new guard condition in HasEntries#matches?.

Fixes #662.