Module: Decidim::CapybaraTestHelpers

Defined in:
decidim-dev/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

#protocolObject



23
24
25
26
27
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara.rb', line 23

def protocol
  return "https" if ENV["TEST_SSL"]

  "http"
end

#switch_to_default_hostObject



15
16
17
# File 'decidim-dev/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 'decidim-dev/lib/decidim/dev/test/rspec_support/capybara.rb', line 8

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
end

#switch_to_secure_context_hostObject



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

def switch_to_secure_context_host
  Capybara.app_host = "#{protocol}://localhost"
end