Module: Decidim::CapybaraTestHelpers
- Defined in:
- lib/decidim/dev/test/rspec_support/capybara.rb
Overview
Helpers meant to be used only during capybara test runs.
Instance Method Summary collapse
- #protocol ⇒ Object
- #switch_to_default_host ⇒ Object
- #switch_to_host(host = "lvh.me") ⇒ Object
- #switch_to_secure_context_host ⇒ Object
Instance Method Details
#protocol ⇒ Object
25 26 27 28 29 |
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 25 def protocol return "https" if ENV["TEST_SSL"] "http" end |
#switch_to_default_host ⇒ Object
17 18 19 |
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 17 def switch_to_default_host Capybara.app_host = nil end |
#switch_to_host(host = "lvh.me") ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 9 def switch_to_host(host = "lvh.me") raise "Cannot switch to a custom host unless it really exists. Use `whatever.lvh.me` as a workaround." unless /lvh\.me$/.match?(host) app_host = (host ? "#{protocol}://#{host}" : nil) Capybara.app_host = app_host Rails.application.config.action_controller.asset_host = host end |
#switch_to_secure_context_host ⇒ Object
21 22 23 |
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 21 def switch_to_secure_context_host Capybara.app_host = "#{protocol}://localhost" end |