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
|
# File 'lib/capybara-box/screenshot.rb', line 7
def configure(options, browser_name)
return unless ::CapybaraBox::Helper.true?(options[:enabled])
require 'capybara-screenshot/rspec'
Capybara::Screenshot.append_timestamp = false
Capybara::Screenshot.prune_strategy = :keep_last_run
Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = false
Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
example.full_description.downcase.gsub('#', '--').tr ' ', '-'
end
if ::CapybaraBox::Helper.true?(options[:s3])
bucket_name = ENV['CAPYBARA_BOX__S3_BUCKET_NAME']
region = ENV['CAPYBARA_BOX__S3_REGION']
s3_configuration = {
bucket_name: bucket_name,
bucket_host: "#{bucket_name}.#{region}.amazonaws.com",
s3_client_credentials: {
access_key_id: ENV['CAPYBARA_BOX__S3_ACCESS_KEY_ID'],
region: region,
secret_access_key: ENV['CAPYBARA_BOX__S3_SECRET_ACCESS_KEY']
},
}
else
s3_configuration = {}
end
Capybara::Screenshot.s3_configuration = s3_configuration
Capybara::Screenshot.register_driver(browser_name) do |driver, path|
driver.browser.save_screenshot(path)
end
end
|