[rspec-devel] Congrats & stubbing methods with specific args question

David Chelimsky dchelimsky at gmail.com
Sun Sep 2 00:08:45 EDT 2007


On 9/1/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>
> On Sep 1, 2007, at 1:33 PM, David Chelimsky wrote:
>
> > On 9/1/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> >>
> >> Congratulations on the 1.0.9 release!
> >
> > Huh? Release? News to me.
> >
> >> This release, I think, is
> >> worth at least a major version number (if not 2.0)- with rbehave, the
> >> internals of rspec completely refactored, the textmate bundle with
> >> lots of new features, enhancements to the mocking framework, etc.  So
> >> thanks for all the hard work - especially Dan North, Brian Takita -
> >> and the usual suspects: David & Aslak.
> >
> > We'll probably make it 1.1. There's still a lot of unification of the
> > runners to happen before we get anywhere near a 2.0.
> >
> >>
> >> Just one thing on the changeset that I saw:
> >>
> >> * You can now stub!(:msg).with(specific args)
> >>
> >>   Does this mean that a stub with specific args will only be stubbed
> >> in those cases, but in others it will act as if it weren't?
> >
> > Not quite. It means that you can set up different stub return values
> > for different argument values, but it does NOT mean that the call will
> > be passed on to the object if those values are not sent in. Once you
> > stub or mock a method on a real object, that method is owned by the
> > mock framework.
>
> So say you have the following
>
> obj.stub!(:a_method).with(1)
>
> and the object receives:
>
> obj.a_method(2)
>
> Is there something like a MockExpectationError which is raised?

As of now, no. This is a problem use case that we should figure out
how it should behave. It's a stub, so you don't expect it to complain.
But how should obj behave when it does receive :a_method with 2?

Thoughts?

>
> Scott
>
> _______________________________________________
> rspec-devel mailing list
> rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list