Created
April 1, 2011 04:19
-
-
Save jmccartie/897722 to your computer and use it in GitHub Desktop.
simple helper with cookie and it's test that won't work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# helper | |
# Set first_time? cookie | |
def set_first_time_cookie | |
cookies[:first_time] = { | |
:value => 'false', | |
:expires => 30.years.from_now, | |
} | |
end | |
# spec | |
describe "set_first_time_cookie" do | |
it "sets the cookie" do | |
helper.set_first_time_cookie() | |
helper.request.cookies[:first_time].should == "false" | |
end | |
end | |
# Result | |
# expected: "false" | |
# got: nil (using ==) | |
# also, helper.request.cookies = {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I not sure if this is the way to test cookies. In my specs, I am testing a controller, so I can actually issue a 'GET' request.