mobomo/green_onion

Name: green_onion

Owner: mobomo

Description: UI testing/screenshot diffing tool

Created: 2012-07-18 20:36:12.0

Updated: 2017-11-12 15:59:43.0

Pushed: 2016-06-30 01:56:52.0

Homepage: null

Size: 3182

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Code Climate

GreenOnion

Regression issues in the view make you cry.

GreenOnion is a testing library for the UI only. It alerts you when the appearance of a view has changed, let's you know the percentage of total change, and allows you to visualize the areas that have been changed. It fits right into your test suite, and is dependent on familiar tools like Capybara.

Documentation

RDoc

Installation

If you want to use capybara-webkit, you'll need to get Qt built in your testing environment. Follow these steps and gem install capybara-webkit to get it up and running. Overwise, you can just use 'selenium' (or another driver) in the configuration block.

Add this line to your application's Gemfile:

gem 'green_onion'

And then execute:

bundle

Or install it yourself as:

gem install green_onion
Usage
Command Line Interface
Skinning

To just run a comparison between skins in your shell, you can use the command below:

green_onion skin <url> [options]

Options

Generating skinner file

To generate a “skinner” file, which will test a Rails application with the routes without params included (this is an area that could be worked on a lot more :) ); use the command below:

green_onion generate [options]
Adding GreenOnion to integration tests with RSpec

For adding GreenOnion to your integration tests in RSpec, add require 'green_onion' to your spec_helper.rb file. Place this block in the file also:

GreenOnion.configure do |c|
  c.skins_dir = 'your/path/to/skins'
  c.skin_name = {
    :match => /[\/]/, 
    :replace => '_', 
    :prefix => nil,
    :root => 'root' 
  }
  c.driver = 'webkit'
  c.dimensions = { 
    :width => 1440, 
    :height => 768 
  }
  c.threshold = 20
end

Then use one of the three methods below in a test…

Percentage of change
GreenOnion.skin_percentage(url, threshold [optional])

The primary feature of GreenOnion is seeing how much (if at all) a view has changed from one instance to the next, and being alerted when a view has surpassed into an unacceptable threshold.

Viewing screenshot diffs
GreenOnion.skin_visual(url)

Once you are aware of a issue in the UI, you can also rip open your spec/skins directory and manually see what the differences are from one screenshot to the next.

Both viewing screenshot diffs and percentage of change
GreenOnion.skin_visual_and_percentage(url, threshold {optional})

This is just a combination of the two methods above.

Contributing
Testing

The best way to run the specs is with…

bundle exec rake spec

…this way a Sinatra WEBrick server will run concurrently with the test suite, and exit on completion. You can see the Sinatra app in spec/sample_app.

Roadmap
THANK YOU

Much of this work could not be completed without these people and projects

Jeff Kreeftmeijer

This is the post that got the wheels in motion: http://jeffkreeftmeijer.com/2011/comparing-images-and-creating-image-diffs/. Most of the GreenOnion::Compare class is based on this work alone. Great job Jeff!

Compatriot

Carol Nichols saw the same post, and worked on an excellent gem for cross-browser testing. That gem greatly influenced design decisions with GreenOnion.

VCR

Many patterns and ideas also came from VCR, because of its flexibility in allowing users to pick what gems to work with.

Capybara, ChunkyPNG, Thor, and OilyPNG

The land on which we sow our bulbs.

Contributor

Ted O'Meara

License

MIT License. See LICENSE for details.

Copyright

Copyright (c) 2012 Intridea, Inc.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.