The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
assert_no_cookie dammit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian Ford

Posts: 153
Nickname: brixen
Registered: Dec, 2005

Brian Ford is Rails developer with PLANET ARGON.
assert_no_cookie dammit Posted: Aug 28, 2006 12:44 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Brian Ford.
Original Post: assert_no_cookie dammit
Feed Title: def euler(x); cos(x) + i*sin(x); end
Feed URL: http://feeds.feedburner.com/defeulerxcosxisinxend
Feed Description: euler(PI) # => -1
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Brian Ford
Latest Posts From def euler(x); cos(x) + i*sin(x); end

Advertisement

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:


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).

Read: assert_no_cookie dammit

Topic: Ruport News, Issue 3 Previous Topic   Next Topic Topic: Dialogue-Driven Development is about Listening

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use