lib/capybara/screenshot/diff/image_compare.rb in capybara-screenshot-diff-0.9.0 vs lib/capybara/screenshot/diff/image_compare.rb in capybara-screenshot-diff-0.9.1
- old
+ new
@@ -22,10 +22,11 @@
end
def reset
@max_color_distance = @color_distance_limit ? 0 : nil
@left = @top = @right = @bottom = nil
+ @_old_filesize = nil
end
# Compare the two image files and return `true` or `false` as quickly as possible.
# Return falsish if the old file does not exist or the image dimensions do not match.
def quick_equal?
@@ -45,10 +46,15 @@
@left, @top, @right, @bottom = find_top(old_img, new_img)
return true if @top.nil?
+ if @area_size_limit
+ @left, @top, @right, @bottom = find_diff_rectangle(old_img, new_img)
+ return true if size <= @area_size_limit
+ end
+
false
end
# Compare the two images referenced by this object, and return `true` if they are different,
# and `false` if they are the same.
@@ -75,9 +81,11 @@
return not_different if old_img.pixels == new_img.pixels
@left, @top, @right, @bottom = find_diff_rectangle(old_img, new_img)
return not_different if @top.nil?
+
+ return not_different if @area_size_limit && size <= @area_size_limit
annotated_old_img, annotated_new_img = draw_rectangles(images, @bottom, @left, @right, @top)
save_images(@annotated_new_file_name, annotated_new_img,
@annotated_old_file_name, annotated_old_img)