lib/simulacrum/comparator.rb in simulacrum-0.0.2 vs lib/simulacrum/comparator.rb in simulacrum-0.0.3
- old
+ new
@@ -1,6 +1,6 @@
-require_relative 'diff/rmagick'
+require_relative './diff/rmagick'
module Simulacrum
# The Comparator class is responsible for comparing and handling
# processing of screenshots and candidates
class Comparator
@@ -8,15 +8,14 @@
attr_accessor :component, :candidate, :diff
def initialize(component)
@component = component
+ @component.render
end
def test
- @candidate = @component.capture_candidate
-
# If the component has a reference then we should diff the candidate
# image against the reference
if @component.reference?
# If there is a diff between the candidate and the reference then we
# should save both the candidate and diff images and fail the test
@@ -32,10 +31,11 @@
private
def pass
@component.remove_candidate
+ @component.remove_diff
true
end
def fail
@diff.save(@component.diff_path)
@@ -46,14 +46,14 @@
nil
end
def perform_diff()
@diff = Simulacrum::RmagicDiff.new(@component.reference_path,
- @component.candidate_path)
+ @component.candidate_path)
diff_delta_percent_is_acceptable
end
def diff_delta_percent_is_acceptable
- (@diff.delta * 1000) < @component.acceptable_delta
+ @diff.delta_percent < @component.acceptable_delta
end
end
end