spec/compare_spec.rb in patternfly-sass-1.3.1 vs spec/compare_spec.rb in patternfly-sass-2.0.0
- old
+ new
@@ -1,18 +1,21 @@
require 'net/http'
require 'nokogiri'
require 'rmagick'
+require 'selenium-webdriver'
RSpec.describe "compare SASS with LESS screenshots" do
BASEURL = "http://localhost:9000"
RESOLUTIONS = [[320, 480], [768, 1024], [1280, 1024]]
CONTEXTS = %w(less sass)
# TODO: Set this to 0 when SASS 3.4.15 is released.
# See https://github.com/sass/sass/issues/1732
TOLERANCE = 0.05
+ driver = Selenium::WebDriver.for(:firefox)
+
# Give some time for the testing server to start
html = nil
5.times do |t|
html = Net::HTTP.get(URI("#{BASEURL}/less/patternfly/index.html")) rescue nil
break unless html.nil?
@@ -23,14 +26,22 @@
document.css(".row a").each do |link|
file = link['href']
context "#{file}" do
title = file.sub('.html', '')
- RESOLUTIONS.each do |w,h|
+ RESOLUTIONS.each do |w, h|
it "#{w}x#{h}" do
+ driver.manage.window.resize_to(w, h)
CONTEXTS.each do |ctx|
- `phantomjs spec/capture.js #{w} #{h} #{BASEURL}/#{ctx}/patternfly/#{file} spec/results/#{ctx}/#{title}-#{w}x#{h}.png`
+ driver.navigate.to("#{BASEURL}/#{ctx}/patternfly/#{file}")
+ driver.execute_script("
+ var style = document.createElement('style');
+ style.innerHTML = '* { -moz-animation: none !important; -moz-transition: none !important;';
+ document.body.appendChild(style);
+ ")
+ sleep(1)
+ driver.save_screenshot("spec/results/#{ctx}/#{title}-#{w}x#{h}.png")
end
img_less = Magick::Image.read("spec/results/less/#{title}-#{w}x#{h}.png").first
img_sass = Magick::Image.read("spec/results/sass/#{title}-#{w}x#{h}.png").first
cols = [img_less.base_columns, img_sass.base_columns].max
@@ -47,7 +58,11 @@
img_diff.destroy!
expect(diff_rate).to be <= TOLERANCE
end
end
end
+ end
+
+ after(:all) do
+ driver.quit
end
end