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



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

def switch_to_default_host
  Capybara.app_host = nil
end

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



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

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