[rspec-users] flash.now

Peter Jaros peter.a.jaros at gmail.com
Sun Mar 29 11:37:26 EDT 2009


2009/3/28 Yi <hayafirst at gmail.com>:

> How can I test flash.now[:key] is being set in a controller test? Both
> flash[:key] and flash.now[:key].should == message didn't work
>
> I can use response.session["flash"][:key].should == message . Just looks bad

That's odd.  In a controller example, you should have a #flash method
available to do exactly what you tried:

http://rspec.rubyforge.org/rspec-rails/1.2.2/classes/Spec/Rails/Example/FunctionalExampleGroup.html#M000051

Try this: where you would like to put the expectation, put "puts
self.class".  Then run it and see what class name it prints.  If it's
ControllerExampleGroup, then there's something weird going on.  If
it's not, then it hasn't figured out that you're spec'ing a
controller.  In that case, post the opening of the describe block and
we'll be able to see what's going on.

Peter


More information about the rspec-users mailing list