Repository is archived
No commit activity in last 3 years
No release in over 3 years
Custom percy-capybara loader for Bedrock projects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

~> 3.13, >= 3.13.2
~> 1.18, >= 1.18.1
 Project Readme

percy-capybara-bedrock

Build Status Gem Version Gem Download License Hire Itineris

  • Goal
  • Minimum Requirements
  • Installation
  • Usage
  • FAQ
    • Does it support Sage?
    • Is it a must to use Sage?
    • It looks awesome. Where can I find some more goodies like this?
    • This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?
  • Feedback
  • Security
  • Change log
  • Credits
  • License
  • Releasing

Goal

The official Percy Anywhere uploads all static files (resources) under assets_dir. This breaks when taking snapshots on a Bedrock project because of the resource limit (15,000 files).

percy-capybara-bedrock fixes the issue by defining a custom loader which:

  • looks for static files under certain directories only
  • excludes certain directories, e.g: .git, vendor and node_modules
  • excludes certain file extensions, e.g: .php and .sql

Minimum Requirements

Installation

$ bundle add percy-capybara-bedrock

Under the hood, percy-capybara-bedrock uses Poltergeist (a driver for Capybara) which requires PhantomJS. Follow the instructions at: https://github.com/teampoltergeist/poltergeist#installing-phantomjs

Usage

Create a percy.rb file under bedrock project root:

require "percy/capybara/bedrock/anywhere"

# URL pointing to the local or remote host
server = "http://localhost:8080"

# Absolute path to a web root directory
web_root = File.expand_path("../web/", __FILE__)

# Path where your webserver hosts the WordPress site
assets_base_url = "/"

Percy::Capybara::Bedrock::Anywhere.run(server, web_root, assets_base_url) do|page|
  # Basic
  page.visit("/")
  Percy::Capybara.snapshot(page, name:"/")

  # Allow Javascript execution to finish
  page.visit("/about-us/")
  sleep(1)
  Percy::Capybara.snapshot(page, name:"/about-us/")

  # Capybara DSL
  # More at: https://github.com/teamcapybara/capybara#the-dsl
  page.visit("/contact-us")
  fill_in("Name", with: "Tang Rufus")
  fill_in("Message", with: "Testing contact form submission")
  click_button('Send')
  sleep(1) # Wait for thank you page to show up
  Percy::Capybara.snapshot(page, name:"/contact-us/thank-you/")
end

Given that your WordPress site is running at http://localhost:8080, take percy snapshots:

$ PERCY_TOKEN=my-secret-token PERCY_BRANCH=local PERCY_DEBUG=1 bundle exec ruby percy.rb

FAQ

Does it support Sage?

Yes, run $ yarn build:production before snapshot.

Is it a must to use Sage?

No, Sage is optional.

It looks awesome. Where can I find some more goodies like this?

This isn't on wp.org. Where can I give a ⭐️⭐️⭐️⭐️⭐️ review?

Thanks! Glad you like it. It's important to let my boss knows somebody is using this project. Instead of giving reviews on wp.org, consider:

Feedback

Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.

Security

If you discover any security related issues, please email hello@itineris.co.uk instead of using the issue tracker.

Change log

Please see CHANGELOG for more information on what has changed recently.

Credits

percy-capybara-bedrock is a Itineris Limited project created by Tang Rufus.

Full list of contributors can be found here.

License

percy-capybara-bedrock is released under the MIT License.

Releasing

For maintainers only

$ gem install github_changelog_generator
$ gem install gem-release

$ git checkout -b version-bump

$ gem bump --sign --tag --release --version patch --pretend
  git push --tags && \
  github_changelog_generator && \
  npx doctoc README.md && \
  git add CHANGELOG.md README.md && \
  git commit -m "github_changelog_generator && npx doctoc README.md" && \
  git push origin version-bump && \
  hub pull-request