Problem with cookies in tests (TDD)

The problem I’m having is that I can’t seem to destroy the cookies and
assert that they were indeed destroyed inside the test.
The code to do this does work - the cookies are created, and are
destroyed when this is done in a browser, but I can’t seem to make the
test pass.


def test_should_pass_if_logout_destroys_cookie_data
post :login, { :user => { :login => ‘ben’, :password => ‘password’
}, :remember => 1 }
assert_equal(User.hash_password(‘password’), cookies[“password”][0])
assert_equal(‘ben’, cookies[“login”][0])
get :logout
assert_nil cookies[“password”][0]
assert_nil cookies[“login”][0]


def logout
session[‘user’] = nil
cookies.delete :login if cookies[:login]
cookies.delete :password if cookies[:password]

rake test failure (assert_nil cookies[“password”][0] is what fails):

  1. Failure:
    expected but was

Thanks in advance,

Benjamin Kuz
Bravenet Web Services

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs