Skip to content

Instantly share code, notes, and snippets.

@mscottford
Created September 16, 2013 14:11
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 mscottford/6581190 to your computer and use it in GitHub Desktop.
Save mscottford/6581190 to your computer and use it in GitHub Desktop.
PoltergeistScreenshotHelper
# spec/support/poltergeist_screenshot_helper.rb
module PoltergeistScreenshotHelper
# FROM http://blog.jerodsanto.net/2012/12/capybara-and-poltergeist-snap/
def snap!(options={})
path = options.fetch :path, "~/.Trash"
file = options.fetch :file, "#{Time.now.to_i}.png"
full = options.fetch :full, true
path = File.expand_path path
path = "/tmp" if !File.exists?(path)
uri = File.join path, file
page.driver.render uri, full: full
system "open #{uri}"
end
end
RSpec.configure do |config|
config.include PoltergeistScreenshotHelper, :type => :request
config.include PoltergeistScreenshotHelper, :type => :feature
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment