Created
April 24, 2017 16:07
-
-
Save fotinakis/d01ebc0fc3a939cd43de6eff95f28b36 to your computer and use it in GitHub Desktop.
Percy native loader remote example
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
# Example to use Percy against a remote host. | |
# Requires: poltergeist gem, and phantomjs. | |
# | |
# This uses the percy-capybara native loader, which is slower and less accurate | |
# than other loaders. See: | |
# https://percy.io/docs/clients/ruby/capybara-other#non-rails-asset-setup | |
require 'percy/capybara' | |
require 'capybara/poltergeist' | |
# | |
# CONFIGURATION. | |
# | |
SERVER = 'http://example.com' | |
unless ENV['PERCY_PROJECT'] && ENV['PERCY_TOKEN'] | |
raise 'Whoops! You need to setup the PERCY_PROJECT and PERCY_TOKEN environment variables.' | |
end | |
::Capybara.run_server = false | |
::Capybara.app_host = SERVER | |
page = ::Capybara::Session.new(:poltergeist) | |
Percy::Capybara.use_loader(:native) | |
build = Percy::Capybara.initialize_build | |
# | |
# PAGE VISITS/INTERACTIONS HERE. | |
# | |
page.visit('/') | |
Percy::Capybara.snapshot(page, name: 'homepage') | |
page.visit('/about') | |
Percy::Capybara.snapshot(page, name: 'about') | |
Percy::Capybara.finalize_build | |
puts | |
puts 'Done! Percy snapshots are now processing...' | |
puts "--> #{build['data']['attributes']['web-url']}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment