0.13
There's a lot of open issues
A long-lived project that still receives updates
Percy
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

>= 2.0
~> 3.31
~> 0.7.0
~> 13.0
~> 3.5
 Project Readme

percy-capybara

Gem Version Test

Percy visual testing for Ruby Selenium.

Installation

npm install @percy/cli:

$ npm install --save-dev @percy/cli

gem install percy-capybara package:

$ gem install percy-capybara

Usage

In your test setup file, require percy/capybara. For example if you're using rspec, you would add the following to your spec_helper.rb file:

require 'percy/capybara'

Now you can use page.percy_snapshot to capture snapshots.

Note: you may need to add js: true to your specs, depending on your driver setup

describe 'my feature, type: :feature do
  it 'renders the page' do
    visit 'https://example.com'
    page.percy_snapshot('Capybara snapshot')
  end
end

Running the test above normally will result in the following log:

[percy] Percy is not running, disabling snapshots

When running with percy exec, and your project's PERCY_TOKEN, a new Percy build will be created and snapshots will be uploaded to your project.

$ export PERCY_TOKEN=[your-project-token]
$ percy exec -- [test command]
[percy] Percy has started!
[percy] Created build #1: https://percy.io/[your-project]
[percy] Snapshot taken "Capybara example"
[percy] Stopping percy...
[percy] Finalized build #1: https://percy.io/[your-project]
[percy] Done!

Configuration

page.snapshot(name[, options])

Upgrading

Manually

Require change

The name of the require has changed from require 'percy' to require 'percy/capybara'. This is to avoid conflict with our Ruby Selenium SDK's require statement.

API change

The previous version of this SDK had the following function signature:

Percy.snapshot(driver, name, options)

v5.x of this SDK has a significant change to the API. There no longer is a stand alone module to call and you no longer need to pass the page/driver. It's available on the current Capybara session (page):

page.percy_snapshot(name, options)

If you were using this SDK outside of Capybara, you'll likely find the Ruby Selenium SDK a better fit

Installing @percy/cli & removing @percy/agent

If you're coming from a 4.x version of this package, make sure to install @percy/cli after upgrading to retain any existing scripts that reference the Percy CLI command. You will also want to uninstall @percy/agent, as it's been replaced by @percy/cli.

$ npm uninstall @percy/agent
$ npm install --save-dev @percy/cli

Migrating config

If you have a previous Percy configuration file, migrate it to the newest version with the config:migrate command:

$ percy config:migrate