Mocking framework
- From: Brian Guthrie <btguthrie@gmail.com>
- To: dev@ioke.kenai.com
- Subject: Mocking framework
- Date: Mon, 26 Jan 2009 02:43:34 -0500
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=FAB4VOs5a7mU006uPLOCS8qKEIB6lvBzkvdNAFWtf85c64GYH0fSFD2XHv3Ig8C2uu VQ7yPHArhaxlGu7a9/v8P+ar0yL8uIQczr3uDf3JthqPU4RIpoYPg4btEOY5v2Vpm14z uq4ei+UR90l0IV3nxdkJ7/jYAxzRoyyaVZ7D8=
Hi all,
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)")
Here's what's still missing:
- argument matcher is too simple, so "should not receive" isn't
working well right now
- simple creation of mock objects (foo = mock(bar: 5)), which may end
up next on my list
- awkward ISpec runner integration, with potential concurrency
concerns if tests were to run in parallel
- more advanced mocking features, which I may add in bits in pieces
since I tend not to get too fussy when I use mocking in my own code
Please take a look when you get the chance and let me know what you
think. I've tried to match Ola's style and produce idiomatic Ioke but
I'm sure there are spots where I'm not going about it in the best
possible way.
Cheers,
Brian
|
Mocking framework |
Brian Guthrie | 01/26/2009 |
| Ola Bini | 01/26/2009 | |
|
Message not available |
||
|
Message not available |
||
|
Message not available |
||
| Ola Bini | 01/27/2009 | |
| Brian Guthrie | 01/27/2009 |





