thoughtbot / clearance

Rails authentication with email & password.

Home Page:https://thoughtbot.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated specs don't work with secure cookies

philliplongman opened this issue · comments

Six of the specs created by the generator will fail if you use the recommended setting of secure_cookie = true. If this is something that's expected in the test environment, I think that should be covered in the readme. If not, it probably needs to be fixed.

I made an example app to demonstrate the problem:
https://github.com/philliplongman/clearance_test

I do see what you're talking about here.

One thing in particular I noticed was lib/clearance/configuration.rb states that secure_cookie should default to false, but it clearly defaults to nil. I'm marking this as a bug to look into further. Thank you for pointing this out.

I also ran into this issue recently. As soon as I set secure_cookie = true, my tests that rely on login don't work. I wasn't sure if it's possibly related to this. rspec/rspec-rails#1658

As a temporary fix, I'm doing this:

config.secure_cookie = Rails.env.test? ? false : true