Forum: RSpec flash.now

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
874be46e8593deadb2cec84b70b26725?d=identicon&s=25 Yi Wen (hayafirst)
on 2009-03-28 05:26
(Received via mailing list)
Hi,

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

Thanks

Yi
D069ac0170dc6c93bad77734258fadae?d=identicon&s=25 Peter Jaros (Guest)
on 2009-03-29 18:02
(Received via mailing list)
2009/3/28 Yi <hayafirst@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/class...

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
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-03-29 18:36
(Received via mailing list)
Yi wrote:
> Yi
>
> --
> http://yiwenandsoftware.wordpress.com


In the past I have used this article to test flash.now in rspec:
http://www.kerrybuckley.org/2007/07/04/correct-use...

Note, that the post is pretty old and so rspec-rails may support this
out of the box by now.. I don't know though.

-Ben
This topic is locked and can not be replied to.