Skip to content

Commit

Permalink
Capybara screenshot gem added
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Nov 28, 2019
1 parent 4f44f5c commit e2724bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ group :test do
gem 'simplecov', :require => false
gem 'selenium-webdriver'
gem 'chromedriver-helper' if ENV['CI']
gem 'capybara-screenshot'
end


Expand Down
18 changes: 17 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,28 @@

require 'rspec/rails'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'spec_helper'

Capybara.javascript_driver = :selenium_chrome_headless
Capybara.javascript_driver = :chrome # :selenium_chrome_headless
Capybara.server = :webrick

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.load_selenium
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--window-size=1366,768'
browser_options.args << '--disable-gpu' if Gem.win_platform?
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

Capybara::Screenshot.register_driver(:chrome) do |driver, path|
driver.browser.save_screenshot(path)
end

Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
"screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
end

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Expand Down

0 comments on commit e2724bc

Please sign in to comment.