Skip to content
Browse files

A bit more output and a README

  • Loading branch information...
1 parent f8ad4d3 commit ab5fef2319d6ba1263de1298aa9c4295967bc8c3 @techbelly committed Jun 26, 2012
Showing with 29 additions and 3 deletions.
  1. +16 −0 README.md
  2. +2 −1 lib/web_regression/cli.rb
  3. +11 −2 lib/web_regression/comparator.rb
View
16 README.md
@@ -0,0 +1,16 @@
+A simple tool to compare screenshots of webpages to make css refactoring easier
+===============================================================================
+
+Usage: web-regression [options] URL
+
+ -r, --reference_png PNG_FILE Png screenshot to compare against
+ -f, --fastfail Fail as soon as a difference detected. Implies -n
+ -n, --nodiff Don't create a diff png
+ -o, --opendiff Open a png showing diffs highlighted with red border
+ -h, --help Show this message
+ --version Show version
+
+Example:
+ $ ruby -rubygems bin/web-regression -o http://www.example.org/index.html
+
+Requires chunky_png and poltergeist and their respective dependencies.
View
3 lib/web_regression/cli.rb
@@ -26,13 +26,14 @@ def self.parse_options(program,args)
opts.on("-f", "--fastfail","Fail as soon as a difference detected. Implies -n") do
options.fastfail = true
+ options.nodiff = true
end
opts.on("-n", "--nodiff","Don't create a diff png") do
options.nodiff = true
end
- opts.on("-o", "--opendiff","Open the diff file") do
+ opts.on("-o", "--opendiff","Open a png showing diffs highlighted with red border") do
options.opendiff = true
end
View
13 lib/web_regression/comparator.rb
@@ -63,7 +63,12 @@ def highlight_diffs(new_image,diff)
def compare
ensure_reference_image
- return SUCCESS if checksum_match?(self.reference_file,screenshot)
+ $stdout.puts "Comparing page at #{self.host}/#{self.path} with #{self.reference_file}"
+
+ if checksum_match?(self.reference_file,screenshot)
+ @stdout.puts "No differences found."
+ return SUCCESS
+ end
diff = []
@@ -76,11 +81,15 @@ def compare
end
end
- return SUCCESS if diff.length == 0
+ if diff.length == 0
+ @stdout.puts "No differences found."
+ return SUCCESS
+ end
unless options.nodiff
highlight_diffs(new_image,diff)
end
+ $stderr.puts "#{diff.length} pixels of difference found"
return FAILURE
end

0 comments on commit ab5fef2

Please sign in to comment.
Something went wrong with that request. Please try again.