Re: Mocking framework
- From: Ola Bini <ola.bini@gmail.com>
- To: Brian Guthrie <btguthrie@gmail.com>
- Cc: dev@ioke.kenai.com
- Subject: Re: Mocking framework
- Date: Mon, 26 Jan 2009 09:02:19 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=CbQSoXWWsi3lVJD+6D/yWj160wEomcGma5eAm37fFfWVW1D1GVzTf4WhGiWACTDEiA 9NSoZa/1D7UHvDyUdsX8OvpmddRqwcg/RUC6K7qC6+X49S8ukkusfgPIrOy9HYTF/tgy YhIds3beJpWWatr3WlbMTSHtpuBH75AmcApUU=
Brian Guthrie wrote:
Hi all,Good work.
I've taken a stab at building out a mocking framework for ISpec, and
the results are up on my fork at
http://github.com/bguthrie/ioke/tree/master. Here's what it supports
so far:
- stubs
- mocking with simple argument matching (expects("foo") with(5),
expects("foo") with (5, :bar))
- mocking with number-of-times-called verification
- ISpec-friendly "foo should receive" syntax or Mocha-friendly "foo
expects" syntax
- unmocking of the object in question after verification is complete
Example:
it("should make a call to the remote service",
User should receive("find") with(:all) andReturn([])
) ... ISpec ExpectationNotMet("expected find to be called 1 time(s)")
I keep thinking that there should be a better way of expressing this that isn't so tied to the verbose Ruby-DSLs. Something like:
User should receive find(:all) andReturn([])
That should be pretty easy to implement.
Cheers
--
Ola Bini (http://olabini.com) Ioke creator (http://ioke.org)
JRuby Core Developer (http://jruby.org)
Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
Practical JRuby on Rails (http://apress.com/book/view/9781590598818)
"Yields falsehood when quined" yields falsehood when quined.
| Brian Guthrie | 01/26/2009 | |
|
Re: Mocking framework |
Ola Bini | 01/26/2009 |
|
Message not available |
||
|
Message not available |
||
|
Message not available |
||
| Ola Bini | 01/27/2009 | |
| Brian Guthrie | 01/27/2009 |





