Sha256: 71d396967c6a3e6731bd2a35fd2d1ba1fea22d2d2f61a9ce23384cad240995c9
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
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_less.resize_to_fill!(cols, rows) img_sass.resize_to_fill!(cols, rows) img_diff, diff_rate = img_less.compare_channel img_sass, Magick::MeanAbsoluteErrorMetric, Magick::AllChannels img_less.destroy! img_sass.destroy! img_diff.write("tests/failures/#{title}-#{w}x#{h}.png") unless diff_rate <= TOLERANCE img_diff.destroy! expect(diff_rate).to be <= TOLERANCE end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
patternfly-sass-1.2.0 | spec/compare_spec.rb |