[rspec-users] Deprecating the mocking framework?
Rodrigo Alvarez Fernández
papipo at gmail.com
Mon Sep 3 05:45:53 EDT 2007
On 9/3/07, Peter Marklund <peter_marklund at fastmail.fm> wrote:
> > 2) Chained stubs/expectations
> >
> > mock.stub!(:valid?).and_return(false)
> > mock.stub!(:valid?).and_return(true).after_receiving
> > (:save).and_return(true)
>
> On first look, that last line is pretty hard to read. I think I
> understand the intention now, but I'm not sure it harmonizes with the
> "Clarity over Cleverness" motto.
>
I understand that there are maybe too many method calls there, but it
would be a nice feature.
Another approach could be using blocks:
mock.stub?(:save).and_return(true) do |saved_mock|
saved_mock.stub!(:valid?).and_return(true)
end
WDYT?
--
http://papipo.blogspot.com
More information about the rspec-users
mailing list