On 9/3/07, Peter Marklund <[EMAIL PROTECTED]> 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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to