-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.rb
45 lines (36 loc) · 1.03 KB
/
env.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'byebug'
require 'capybara/cucumber'
require 'selenium-webdriver'
case ENV.fetch('HOST', nil)
when 'localhost', 'http://localhost:8080'
BASE_URL = 'http://localhost:8080'
PUBLIC_URL = 'http://localhost:8081'
STAFF_URL = BASE_URL
else
BASE_URL = 'https://e2e.archivesspace.org'
PUBLIC_URL = BASE_URL.freeze
STAFF_URL = "#{BASE_URL}/staff".freeze
end
case ENV.fetch('HEADLESS', nil)
when 'true'
HEADLESS = '--headless'
else
HEADLESS = ''
end
Capybara.register_driver :firefox do |app|
options = Selenium::WebDriver::Firefox::Options.new
options.add_argument(HEADLESS)
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
end
Capybara.default_driver = :firefox
Capybara.default_max_wait_time = 10
BeforeAll do
connection_error = "\nNo server found running on #{STAFF_URL}.\n\n"
begin
response = Net::HTTP.get_response(URI(STAFF_URL))
raise connection_error if response.code != '200'
rescue Errno::ECONNREFUSED, Errno::ECONNRESET
raise connection_error
end
end