Sha256: 8f3bb931f0a9271b1ad16fcb89b08ed5f732d67bf0c00a52a060f5f5360e7834
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require "json" module Capybara module Screenshot module Diff class Difference < Struct.new(:region, :meta, :comparison, :failed_by) def different? failed? || !(blank? || tolerable?) end def equal? !different? end def failed? !!failed_by end def options comparison.options end def tolerance options[:tolerance] end def skip_area options[:skip_area] end def area_size_limit options[:area_size_limit] end def blank? region.nil? || region_area_size.zero? end def region_area_size region&.size || 0 end def ratio meta[:difference_level] end def to_h {area_size: region_area_size, region: coordinates}.merge!(meta) end def coordinates region&.to_edge_coordinates end def inspect to_h.to_json end def tolerable? !!((area_size_limit && area_size_limit >= region_area_size) || (tolerance && tolerance >= ratio)) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
capybara-screenshot-diff-1.9.2 | lib/capybara/screenshot/diff/difference.rb |
capybara-screenshot-diff-1.9.0 | lib/capybara/screenshot/diff/difference.rb |