[mocha-developer] More flexible return values?

Jaime Cham jaime_cham at yahoo.com
Mon Aug 13 16:52:30 EDT 2007


Thanks for the great library, we use Mocha extensibly on our test and 
love its readability and no-nonsense-ness.

 

One thing that would 
be great, but that seems to be against some of the testing philosophy (which we 
don't quite deeply understand yet, so we can't come up with kosher alternatives) 
is the ability to be more flexible with the return values. 

 

Presently the only 
flexibility is to pass a Proc, but even this is going away. Ideally you could be 
as flexible as passing a block that received the call's parameters (which the 
Proc presently doesn't receive) so arbitrary logic could be 
used.

 

Knowing that the 
more specific tests are the better, this flexibility allows for tests to be less 
brittle. More concretely, in our case we are using Mocha to mock and stub calls 
to a remote server. The code under test batches the calls for efficiency so that 
the exact request parameters are not known on each invokation, and the 
particular test wants to be independent of the batching parameters. 
Other cases 
might be that the number of possible return values is large given the inputs and 
can be expressed more succintly as a simple formula on the paramteters. Or the 
input and output must be ordered data but the order is not known or arbitrarily 
set by an intermediate component (e.g. a database).

 

Or is there some 
other way that we are missing? thanks for elucidating us and for the great work 
on this library.

 

Jaime 
Cham



More information about the mocha-developer mailing list