Skip to content

Instantly share code, notes, and snippets.

@palkan
Created December 19, 2015 18:52
Show Gist options
  • Save palkan/f5c365ef39c0a9c01fff to your computer and use it in GitHub Desktop.
Save palkan/f5c365ef39c0a9c01fff to your computer and use it in GitHub Desktop.
Capture exceptions with screenshots (feature specs)
shared_context "feature", type: :feature do
after(:each) do |example|
next unless example.exception
meta = example.metadata
next unless meta[:js] == true
filename = File.basename(meta[:file_path])
line_number = meta[:line_number]
screenshot_name = "screenshot-#{filename}-#{line_number}.png"
save_screenshot(screenshot_name) # rubocop:disable Lint/Debugger
puts meta[:full_description] + "\n Screenshot: #{screenshot_name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment