This gem exists of two commands: a generator and a test. The generator creates for every .html(.erb) files in the project a spec file. This spec files is very simple, it visits the page and it should match the expectation:
describe "Base test for index.html.erb", :type => :feature, :js => true do
before(:each) do
visit "http://localhost:9000/index.html"
sleep 2
end
it { expect(page).to match_expectation }
end
When there's no expectation, it will save screenshots to a temporary folder. You should manually move these screenshots next to the specs. When running te test again, it will match against these screenshots.
Add this line to your application's Gemfile:
gem 'roger_visual_regression'
And then execute:
$ bundle
Or install it yourself as:
$ gem install roger_visual_regression
This gem exists of two commands: a generator and a test-command.
$ bundle exec roger generate rogervisualregression::
First add the following block to you Mockupfile
mockup.test do |test|
test.use :visual_regression, {spec_path: 'spec/'}
end
Then run the command on the commandline:
$ bundle exec roger test
When this is the first time you run this command, the screenshots can be found at: tmp/spec/expectation/**/test.png
. Copy the expectation folder to your spec path:
$ mv tmp/spec/expectation spec/expectation && find ./spec/expectation -iname "test.png" -exec bash -c 'mv $0 ${0/test.png/expected.png}' {} \;
Then u can checkout another commit and run the tests again (make sure the expected.png still exists), then it will tell you if it spot any differences!
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
- Fork it ( https://github.com/[my-github-username]/roger_visual_regression/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request