Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade ruby and capybara and fix tests #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.bundle
.config
.yardoc
.DS_Store
Gemfile.lock
InstalledFiles
_yardoc
Expand All @@ -12,6 +13,7 @@ lib/bundler/man
pkg
rdoc
spec/reports
TAGS
test/tmp
test/version_tmp
tmp
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
green_onion
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.3
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
rvm:
- 1.9.2
- 2.2.3
before_install:
- sudo apt-get install libqt4-dev libqtwebkit-dev
before_script:
Expand Down
3 changes: 2 additions & 1 deletion green_onion.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "rspec"
gem.add_development_dependency "sinatra"
gem.add_development_dependency "capybara-webkit"
gem.add_development_dependency "selenium-webdriver"
gem.add_development_dependency "poltergeist"

gem.add_dependency "capybara", " ~> 1.1"
gem.add_dependency "capybara", " ~> 2.5"
gem.add_dependency "oily_png", "~> 1.0.2"
gem.add_dependency "rainbow"
gem.add_dependency "fileutils"
Expand Down
4 changes: 2 additions & 2 deletions lib/green_onion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "green_onion/configuration"
require "green_onion/errors"
require "green_onion/browser"
require "rainbow"
require 'rainbow/ext/string'

module GreenOnion
class << self
Expand Down Expand Up @@ -71,7 +71,7 @@ def skin_picker(url, type, threshold=100)
# This is used in skin_percentage to raise error if a set of skins are ok or not
def threshold_alert(actual, threshold)
if actual > threshold
abort "#{actual - threshold}% above threshold set @ #{threshold}%".color(:red) +
abort "#{actual - threshold}% above threshold set @ #{threshold}%".color(:red) +
"\npixels changed (%): #{@compare.percentage_changed}%" +
"\npixels changed/total: #{@compare.changed_px}/#{@compare.total_px}"
else
Expand Down
8 changes: 4 additions & 4 deletions lib/green_onion/compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def diff_iterator
@images.first.height.times do |y|
@images.first.row(y).each_with_index do |pixel, x|
unless pixel == @images.last[x,y]
@diff_index << [x,y]
@diff_index << [x,y]
pixel_difference_filter(pixel, x, y)
end
end
Expand All @@ -38,7 +38,7 @@ def diff_iterator
# Changes the pixel color to be the opposite RGB value
def pixel_difference_filter(pixel, x, y)
chans = []
[:r, :b, :g].each do |chan|
[:r, :b, :g].each do |chan|
chans << channel_difference(chan, pixel, x, y)
end
@images.last[x,y] = ChunkyPNG::Color.rgb(chans[0], chans[1], chans[2])
Expand Down Expand Up @@ -73,9 +73,9 @@ def save_visual_diff(org, fresh)
rescue NoMethodError
puts "Both skins are the same.".color(:yellow)
end

@images.last.save(@diffed_image)
end

end
end
end
10 changes: 5 additions & 5 deletions lib/green_onion/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Configuration
def dimensions=(options)
@dimensions = options
end

def dimensions
@dimensions ||= { :height => 768, :width => 1024 }
end
Expand Down Expand Up @@ -41,13 +41,13 @@ def skin_name

# Serves as a template for skin_name getter/setter
def skin_namespace_hash(options = {})
{
:match => options[:match] ? options[:match] : /[\/]/,
:replace => options[:replace] ? options[:replace] : "_",
{
:match => options[:match] ? options[:match] : /[\/]/,
:replace => options[:replace] ? options[:replace] : "_",
:prefix => options[:prefix] ? options[:prefix] : nil,
:root => options[:root] ? options[:root] : "root"
}
end

end
end
end
4 changes: 2 additions & 2 deletions lib/green_onion/drivers/webkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def initialize

def record(url, path, dimensions)
visit url
page.driver.render(path, dimensions)
page.driver.save_screenshot(path, dimensions)
end

end
end
end
8 changes: 4 additions & 4 deletions lib/green_onion/generators/skinner.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ GreenOnion.configure do |c|
# c.threshold = 100
# c.dimensions = { :width => 1024, :height => 768 }
# c.skin_name = {
# :match => /[\/]/,
# :replace => "_",
# :match => /[\/]/,
# :replace => "_",
# :prefix => nil,
# :root => "root"
# :root => "root"
# }
end

Expand All @@ -24,4 +24,4 @@ routes = all_routes.collect { |r| r.path.spec.to_s.gsub(/\/*(\(\.)*:(\w*)(\))*\/

routes.each do |route|
GreenOnion.skin_visual_and_percentage("<%= config[:url] %>" + route)
end
end
8 changes: 4 additions & 4 deletions lib/green_onion/screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def url_to_path(url)
else
@shot_path = @paths_hash[:original]
end
end
end

def url_matcher(url)
url_match = url.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/).to_a.compact
Expand All @@ -52,7 +52,7 @@ def create_dir(dir)

def get_path(url)
url_matcher(url)
if @filename.empty? || @filename == '/'
if @filename.empty? || @filename == '/'
@paths_hash[:original] = "#{@dir}/#{@skin_name[:root]}.png"
else
file_namer
Expand All @@ -68,10 +68,10 @@ def destroy_files(org, fresh)
if File.exist?(org)
FileUtils.rm(org)
if File.exist?(fresh)
FileUtils.rm(fresh)
FileUtils.rm(fresh)
end
end
end

end
end
end
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
require 'bundler/setup'
require 'fileutils'
require 'green_onion'
require 'open3'

RSpec.configure do |config|
# some (optional) config here
end
end
12 changes: 6 additions & 6 deletions spec/unit/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

after(:each) do
FileUtils.rm_r(@tmp_path, :force => true)
end
end

it "should run the skin task w/o any flags (need the --dir flag to keep spec directory clean)" do
`bin/green_onion skin #{@url} -d=#{@tmp_path}`
File.exist?(@file1).should be_true
File.exist?(@file1).should be true
end

it "should run the skin task w/ --method=p flag to run only percentage diff" do
Expand All @@ -32,18 +32,18 @@

after(:each) do
FileUtils.rm_r(@tmp_path, :force => true)
end
end

it "should build the skinner file" do
`bin/green_onion generate --dir=#{@tmp_path}`
File.exist?(@skinner_file).should be_true
File.exist?(@skinner_file).should be true
end

it "should build the skinner file with the url included correctly" do
`bin/green_onion generate --url=#{@url} --dir=#{@tmp_path}`
skinner = IO.read(@skinner_file)
skinner.should include("GreenOnion.skin_visual_and_percentage(\"http://localhost:8070\" + route)")
end

end
end
end
4 changes: 2 additions & 2 deletions spec/unit/compare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

it 'should create a new file with a visual diff between two shots' do
@comparison.visual_diff(@spec_shot1, @spec_shot2)
File.exist?(@diff_shot).should be_true
File.exist?(@diff_shot).should be true
end

it "should not throw error when dimensions are off" do
expect { @comparison.visual_diff(@spec_shot1, @spec_shot_resize) }.to_not raise_error
end

end
end
end
6 changes: 3 additions & 3 deletions spec/unit/drivers/poltergeist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@screenshot = GreenOnion::Screenshot.new(
:browser => @browser,
:dir => @tmp_path,
:skin_name => {
:skin_name => {
:match => /[\/]/,
:replace => "_",
:prefix => nil,
Expand All @@ -32,6 +32,6 @@

it "should snap and save screenshot w/ Poltergeist" do
@screenshot.test_screenshot(@url_w_uri)
File.exist?(@file).should be_true
File.exist?(@file).should be true
end
end
end
6 changes: 3 additions & 3 deletions spec/unit/drivers/selenium_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@screenshot = GreenOnion::Screenshot.new(
:browser => @browser,
:dir => @tmp_path,
:skin_name => {
:skin_name => {
:match => /[\/]/,
:replace => "_",
:prefix => nil,
Expand All @@ -32,6 +32,6 @@

it "should snap and save screenshot w/ Selenium" do
@screenshot.test_screenshot(@url_w_uri)
File.exist?(@file).should be_true
File.exist?(@file).should be true
end
end
end
6 changes: 3 additions & 3 deletions spec/unit/drivers/webkit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@screenshot = GreenOnion::Screenshot.new(
:browser => @browser,
:dir => @tmp_path,
:skin_name => {
:skin_name => {
:match => /[\/]/,
:replace => "_",
:prefix => nil,
Expand All @@ -32,6 +32,6 @@

it "should snap and save screenshot w/ Webkit" do
@screenshot.test_screenshot(@url_w_uri)
File.exist?(@file).should be_true
File.exist?(@file).should be true
end
end
end
Loading