redding / assert

Assertion style testing framework.
https://github.com/redding/assert
MIT License
10 stars 1 forks source link

Match arity when defining proxy method with stubbing #204

Closed jcredding closed 10 years ago

jcredding commented 10 years ago

This updates the stubbing logic to define its proxy method with matching arity to the method being stubbed. This ensures that singleton methods extended/inherited on a class will properly check their arity. For these cases, assert will define a proxy method that is aliased instead of using the inherited/extended method when. This is because using the inherited/extended method can effect other singletons and ensures assert is only modifying the current object it is working on. Previously, the proxy method was always defined to take any args, which had the side effect of allowing any number of args when stubbing or calling the method. This is against the spirit of assert's stubbing, so this updates the proxy method to match the arity of the method it is proxying. This allows the arity checking to properly ensure that a stub is created or called with the proper number of args.

@kellyredding - Ready for review.

kellyredding commented 10 years ago

@jcredding looks good - love the param list implementation and unit tests. sys test changes are as expected with this new behavior.

:-1: