On Wed, Nov 5, 2008 at 8:05 AM, Fernando Perez <[EMAIL PROTECTED]> wrote:
> I'm also having problems stubbing current_user.
>
> I cannot put
> controller.stub!(:current_user).and_return(@current_user)
>  in a before(:all) block. The stubbing doesn't happen.

Stubs and mocks get cleared out after each example. before(:all) only
runs once, so after the first example in a group runs, the stub gets
cleared out and does not get recreated.

before(:each) runs before each example, setting the stub each time.

So use before(:each) instead of before(:all).

Make sense?

There's a little more info about this on
http://rspec.info/documentation/before_and_after.html (near the
bottom).

Cheers,
David

>
> However if I put it in the it "should..." block, then it works.
>
> Why is that?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to