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

Instance Method Details

#switch_to_default_hostObject



16
17
18
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 16

def switch_to_default_host
  Capybara.app_host = nil
end

#switch_to_host(host = "lvh.me") ⇒ Object



9
10
11
12
13
14
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 9

def switch_to_host(host = "lvh.me")
  raise "Can't switch to a custom host unless it really exists. Use `whatever.lvh.me` as a workaround." unless /lvh\.me$/.match?(host)

  app_host = (host ? "http://#{host}" : nil)
  Capybara.app_host = app_host
end

#switch_to_secure_context_hostObject



20
21
22
# File 'lib/decidim/dev/test/rspec_support/capybara.rb', line 20

def switch_to_secure_context_host
  Capybara.app_host = "http://localhost"
end