published under license Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)copy! share!
posted in category Software Development & Programming / Rails Testing
posted at 17. Jun '20
Capybara Dropping Session During Test
Rack::Test driver drops session during test, which means you lose
Rack::Test uses by default
HTTP_HOST set to “http://www.example.com”. I don’t know why, but after login,
HTTP_HOST was “localhost”.
The solution - fix capybara default host. Put this into
rails_helper.rb or you know, support files which are loaded by it.
Capybara.default_host = 'http://localhost'
When I tried to set it to example.com -
Capybara.default_host = 'http://example.com', didn’t work, still changed to