[rspec-users] How to spec error_messages_for

David Chelimsky dchelimsky at gmail.com
Wed Mar 21 13:12:12 EDT 2007

On 3/21/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Hi
> I'm trying to spec a call to error_messages_for to avoid stubbing out
> whole models.  Something like this:
> context "A rendered calculate_quote view" do
>    setup do
>      @form = mock("form")
>      assigns[:form] = @form
>    end
>    specify "should render the error messages" do
>      <SOMETHING>.should_receive(:error_messages_for).with
> ('form', :anything)
>      render 'gap/calculate_quote'
>    end
> end
> What can I put as <SOMETHING>?

"Danger, danger, Will Robinson!"

The fact that you have to ask this question is a sign that you
probably shouldn't be doing this. The answer lies in AR internals,
which is stuff you really shouldn't be mocking.

Imagine that you do this, and a new version of rails implements this
differently. You may start getting a bunch of failing integration
tests w/o failing isolation tests and they'll be very difficult to
track down.



> Thanks...
> Ashley
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list