Created
April 14, 2014 01:21
-
-
Save osulyanov/10609515 to your computer and use it in GitHub Desktop.
Capybara auto-saving screenshots on test failures
This file contains 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
RSpec.configure do |config| | |
config.after(:each) do | |
if example.exception && example.metadata[:js] | |
meta = example.metadata | |
filename = File.basename(meta[:file_path]) | |
line_number = meta[:line_number] | |
screenshot_name = "screenshot-#{filename}-#{line_number}.png" | |
screenshot_path = "#{Rails.root.join("tmp")}/#{screenshot_name}" | |
page.save_screenshot(screenshot_path) | |
puts meta[:full_description] + "\n Screenshot: #{screenshot_path}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment