sameers
sameers

Reputation: 5095

What Mocha API call will stub a method which takes no arguments?

I seem to only find SO posts asking how to assert that a method has no return value but what I want is to require that a method call in my tests never see any arguments passed to the method.

I expected to find some documentation in http://gofreerange.com/mocha/docs/Mocha/ParameterMatchers.html, but no luck ... should I be looking elsewhere?

Upvotes: 1

Views: 761

Answers (1)

sameers
sameers

Reputation: 5095

The documentation for the with method doesn't appear to say this, but I discovered that calling with() with no parameters will force Mocha to check that the method call happens with no arguments.

Example:

MyClass.any_instance.stubs(:its_method).with.return true

Upvotes: 1

Related Questions