Forum: Ruby on Rails Cookies and functional tests

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.
13ee02bb9012e843dbe7d0a23a6656f7?d=identicon&s=25 David Salgado (Guest)
on 2006-04-03 15:09
(Received via mailing list)
Hi there

Is there any way that my functional tests can check to see if the
controller has set a cookie?

I've got this in a controller action;

   def login
     cookies[:foo] = 'bar'
   end

Using a web browser, I can see that the cookie is being set when the
action is invoked. But, a functional test like this;

   def test_cookie
       assert_equal nil, cookies[:foo]

       post :login, :user => {
           :name => users(:david).name,
           :password => users(:david).password,
       }

       assert_equal 'bar', cookies[:foo]
   end

Fails, saying that cookies[:foo] is <nil>.

Is there anything I can do to have meaningful functional testing of
cookies that are set by my controllers?

Thanks in advance

David
This topic is locked and can not be replied to.