[rspec-users] problem with rspec_on_rails and @controller.should_receive(:render) in trunk

David Chelimsky dchelimsky at gmail.com
Thu Apr 19 10:52:53 EDT 2007

On 4/19/07, Marcus Ahnve <marcus at ahnve.com> wrote:
> On 4/18/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> > [...]
> > FYI - Chris says the error is:
> >
> > <UsersController:0x323fe94> expected :render with ({:layout=>false})
> > but received it with (no args)
> I am seeing this as well.
> I am running a spec like:
>    it "should use application layout" do
>      @controller.should_receive(:render).with(:layout => "/layouts/application")
>      get 'index'
>    end
> If I change the spec to fail on purpose by for example changing the
> expected layout name, I get the correct behaviour. The 'no args' thing
> appears when the spec passes.

OK - I'm getting somewhere with this. What happens is that render is
actually called twice. So if you do this:

it "should use application layout" do
  controller.should_receive(:render).with(:layout => "/layouts/application")
  get 'index'

... then the spec will pass.

The problem is really one of feedback, IMO. The mock should tell you
"hey, you said I should expect a single call w/ these args, but I got
another one with these other args". Right now it's not telling you
that your expectation was met AND there was a problem - just that
there was a problem.


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

More information about the rspec-users mailing list