Re: Mocking framework
- From: Ola Bini <ola.bini@gmail.com>
- To: Brian Guthrie <btguthrie@gmail.com>, dev@ioke.kenai.com
- Subject: Re: Mocking framework
- Date: Tue, 27 Jan 2009 08:12:21 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=UtXFt+cY+7TBY72smFg0Mp7IYLFlyFmc78ezUZQEHZaA91Tlkz/gU5GBds3YYqogDE e5PrAOX7ZfQxNCn71UjO2A8dPxBw0ywyt3GxFdJXY60/OV2xFOUGgfialr2CMU3B3+75 hIdlpivGw7JMQNE8gh5hUQ5+0g4vTy1mWH2WU=
Okay, I've modified the should receive syntax to perform in the way
you suggested and pushed it up to Github, although 'foo expects' still
works. Would it be better to just go whole-hog and throw it out? I
just feel burned by the mocha vs. RSpec mocking religious war in the
Ruby world but since we have a chance to start over here maybe I'm
over-thinking it.
I think I'm going to provide a mock() primitive for easy mock creation
through a hash primitive, but I'm left with a question about syntax
that's been bugging me. The with() macro accepts a JS-style hash-like
syntax that appears to require special handling to support (arg name
asText[0..0-2]) and doesn't have wider support in the codebase AFAICT.
Is that the kind of syntax you'd expect to see from a call to mock?
Or should it just accept a plain old hash? E.g.
foo = mock(foo: "bar", baz: "qux") vs.
foo = mock(:foo => "bar", :baz => "qux")
or am I barking up the wrong tree entirely? Ola, did you have a more
succinct syntax you imagined for that kind of a construct? Or is
with() a failed experiment? I don't see it referenced anywhere in the
wiki guide.
Taking this to the mailing lists - since its of general interest.
First, mocking. Well, community, what do you think? I don't have a strong opinion.
Second, the with-macro could almost be implemented as regular keyword arguments. The reason it is not is that doing it this way allow you to intersperse regular code with the arguments. So, you can do:
Origin with(foo: 42,
"hello world" println)
it is not a failed experiment, it just isn't documented. =)
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 | |
| Ola Bini | 01/26/2009 | |
|
Message not available |
||
|
Message not available |
||
|
Message not available |
||
|
Re: Mocking framework |
Ola Bini | 01/27/2009 |
| Brian Guthrie | 01/27/2009 |





