Last active
June 2, 2016 22:34
-
-
Save stephen-puiszis/722abdabcf8f96f2f187c58c5386ec24 to your computer and use it in GitHub Desktop.
Automatically take full page screenshots of failed Capybara test failures in RSpec 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails_helper.rb | |
RSpec.configure do |config| | |
# other config | |
config.after(:each, js: true) do |example| | |
if example.exception | |
meta = example.metadata | |
name = "test-failure-#{File.basename(meta[:file_path])}-#{meta[:line_number]}.png" | |
self.page.save_screenshot(screenshot_path, full: true) | |
$stdout << "\n Screenshot Taken: " + [Rails.root.join("tmp", "capybara"), name].join("/") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment