assert_no_cookie dammit
I hate cookies. Or maybe I’m just feeling schizo today. Actually, I do love cookies, just not testing them with Rails.
I’ve added assert_no_cookie method to the assert_cookie plugin. That’s because in your functional tests, cookies['chocolate'] may be something, nil, or an empty array depending on what you’ve just done. For example, in this code I had tried assert_nil cookies['pass'] but that failed because cookies['pass'] was [] after calling cookies.delete :pass in the controller:
1 2 3 4 5 6 7 8 9 10 11 12 |
def test_destroy_should_remove_persistent_login_cookie post :create, :username => 'brian.ford', :password => 'secret', :remember_me => '1' pass = cookies['pass'] @request.cookies['pass'] = cookies['pass'] post :destroy, :_method => 'delete' assert_no_cookie :pass user = User.find_by_username 'brian.ford' assert_nil user.persistent_logins.find_by_pass(pass) end |
Anyway, as before, you can get this by script/plugin http://svn.planetargon.org/rails/plugins/assert_cookie.
And thanks yet again to Pluit Solutions for helping me keep my head straight about how to work with cookies in functional tests. Next stop, a patch for Rails (would a generous soul please donate some time to this so I don’t have to).
About this entry
You’re currently reading “assert_no_cookie dammit,” an entry on def euler(x); cos(x) + i*sin(x); end
- Published:
- August 28th 04:51 AM
- Updated:
- February 8th 11:49 PM
- Sections:

0 comments
Jump to comment form | comments rss [?]