Flash.now

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

2009/3/28 Yi [email protected]:

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

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-of-the-flash-in-rails/

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