Skip to content

Instantly share code, notes, and snippets.

@pmoran
Created December 13, 2010 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmoran/739583 to your computer and use it in GitHub Desktop.
Save pmoran/739583 to your computer and use it in GitHub Desktop.
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb
module Screenshots
if Cucumber::OS_X
def embed_screenshot(id)
`screencapture -t png reports/#{id}.png`
embed("#{id}.png", "image/png")
end
else
def embed_screenshot(id)
`import -window root reports/#{id}.png`
embed("#{id}.png", "image/png")
end
end
end
World(Screenshots)
After do |scenario|
if scenario.failed? && defined?(Capybara) && Capybara.current_session
embed_screenshot("screenshot-#{Time.new.to_i}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment