Skip to content

Instantly share code, notes, and snippets.

@stephen-puiszis
Last active June 2, 2016 22:34
Show Gist options
  • Save stephen-puiszis/722abdabcf8f96f2f187c58c5386ec24 to your computer and use it in GitHub Desktop.
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
# 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