mockolate icon indicating copy to clipboard operation
mockolate copied to clipboard

allow stubbing & mocking by RegExp or Matcher

Open drewbourne opened this issue 15 years ago • 3 comments

As a convenience allow stubbing and mocking multiple methods or properties by providing a RegExp or Matcher as the method name.

// using a RegExp
stub(permissions).method(/can(Edit|Show|Delete)/).returns(true);

// using a Matcher
var eventDispatcherMethods:Array = ['addEventListener', 'dispatchEvent', 'hasEventListener', 'removeEventListener', 'willTrigger'];
stub(permissions).method(inArray(eventDispatcherMethods)).anyArgs().pass();

drewbourne avatar Aug 16 '10 00:08 drewbourne

added support for matching method and property names with a RegExp:

mock(permissions).methods(/^can/)
stub(slotmachine).setters(/^slot\d/).arg(Number);
stub(slotmachine).getters(/^slot\d/).returns(10);

drewbourne avatar Sep 23 '10 13:09 drewbourne

TODO add support to test spies

drewbourne avatar Oct 12 '10 11:10 drewbourne

added support for matching methods, getters, and setters by RegExp to test spies.

drewbourne avatar Oct 23 '10 06:10 drewbourne