This repository has been archived by the owner on Jan 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
195 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,5 +34,6 @@ dist | |
|
||
# Directories with test images | ||
tests/sass | ||
tests/less | ||
tests/reference | ||
tests/failures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--color | ||
--require spec_helper | ||
--format progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
language: ruby | ||
rvm: | ||
- 2.0.0 | ||
before_install: | ||
- "npm install" | ||
before_script: | ||
- bundle exec rake compile | ||
- bundle exec rake serve > /dev/null 2>&1 & | ||
- export PID=$! | ||
- sleep 3 | ||
script: | ||
- bundle exec grunt test | ||
- bundle exec rake spec | ||
after_failure: | ||
- bundle exec rake upload | ||
after_script: | ||
- kill -2 $PID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,8 @@ end | |
group :test do | ||
gem 'rake' | ||
gem 'webrick' | ||
gem 'rspec' | ||
gem 'nokogiri' | ||
gem 'rmagick' | ||
gem 'imgur-api' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'net/http' | ||
require 'nokogiri' | ||
require 'rmagick' | ||
|
||
RSpec.describe "compare SASS with LESS screenshots" do | ||
BASEURL = "http://localhost:9000" | ||
RESOLUTIONS = [[320, 480], [768, 1024], [1280, 1024]] | ||
CONTEXTS = %w(less sass) | ||
TOLERANCE = 0.05 | ||
|
||
html = Net::HTTP.get(URI("#{BASEURL}/less/patternfly/index.html")) | ||
document = Nokogiri::HTML(html) | ||
|
||
document.css(".row a").each do |link| | ||
file = link['href'] | ||
context "#{file}" do | ||
title = file.sub('.html', '') | ||
RESOLUTIONS.each do |w,h| | ||
it "#{w}x#{h}" do | ||
CONTEXTS.each do |ctx| | ||
`phantomjs tests/capture.js #{w} #{h} #{BASEURL}/#{ctx}/patternfly/#{file} tests/#{ctx}/#{title}-#{w}x#{h}.png` | ||
end | ||
img_less = Magick::Image.read("tests/less/#{title}-#{w}x#{h}.png").first | ||
img_sass = Magick::Image.read("tests/sass/#{title}-#{w}x#{h}.png").first | ||
|
||
cols = [img_less.base_columns, img_sass.base_columns].max | ||
rows = [img_less.base_rows, img_sass.base_rows].max | ||
img_base = Magick::Image.new(cols, rows) { self.background_color = 'black' } | ||
|
||
img_less = img_base.composite(img_less, 0, 0, Magick::OverCompositeOp) | ||
img_sass = img_base.composite(img_sass, 0, 0, Magick::OverCompositeOp) | ||
|
||
img_diff, diff_rate = img_less.compare_channel img_sass, Magick::MeanAbsoluteErrorMetric, Magick::AllChannels | ||
|
||
img_diff.write("tests/failures/#{title}-#{w}x#{h}.png") unless diff_rate <= TOLERANCE | ||
expect(diff_rate).to be <= TOLERANCE | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
RSpec.configure do |config| | ||
config.expect_with :rspec do |expectations| | ||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true | ||
end | ||
|
||
config.mock_with :rspec do |mocks| | ||
mocks.verify_partial_doubles = true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Usage: phantomjs capture.js [width] [height] [url] [output] | ||
*/ | ||
|
||
var system = require('system'); | ||
var args = system.args; | ||
|
||
if (args.length === 5) { | ||
var width = args[1]; | ||
var height = args[2]; | ||
var url = args[3]; | ||
var output = args[4]; | ||
var page = require('webpage').create(); | ||
page.viewportSize = { width: width, height: height }; | ||
page.open(url, function() { | ||
page.evaluate(function() { | ||
var style = document.createElement('style'); | ||
style.innerHTML = [ | ||
'* {', | ||
'animation: none !important;', | ||
'transition: none !important;', | ||
'-webkit-animation: none !important;', | ||
'-webkit-transition: none !important;', | ||
'}'].join('\n'); | ||
document.body.appendChild(style); | ||
}); | ||
page.render(output); | ||
phantom.exit(); | ||
}); | ||
} else { | ||
console.log("Invalid argument!"); | ||
} |