-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenv.rb
61 lines (49 loc) · 1.82 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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)
profile = Selenium::WebDriver::Firefox::Profile.new
profile['webdriver.log.level'] = 'ALL'
profile['browser.download.dir'] = Dir.tmpdir
profile['browser.download.folderList'] = 2
profile['browser.helperApps.alwaysAsk.force'] = false
profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/msword, application/csv, application/pdf, application/xml, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed'
profile['pdfjs.disabled'] = true
options.profile = profile
Capybara::Selenium::Driver.new(app, browser: :firefox, options:)
end
Capybara.register_driver :firefox_alternative_session 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