Class: Simulacrum::Comparator
- Inherits:
-
Object
- Object
- Simulacrum::Comparator
- Includes:
- RSpec::Core::Pending
- Defined in:
- lib/simulacrum/comparator.rb
Overview
The Comparator class is responsible for comparing and handling processing of screenshots and candidates
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#diff ⇒ Object
readonly
Returns the value of attribute diff.
Instance Method Summary collapse
-
#initialize(component) ⇒ Comparator
constructor
A new instance of Comparator.
- #test ⇒ Object
Constructor Details
#initialize(component) ⇒ Comparator
13 14 15 16 |
# File 'lib/simulacrum/comparator.rb', line 13 def initialize(component) @component = component component.render end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
11 12 13 |
# File 'lib/simulacrum/comparator.rb', line 11 def component @component end |
#diff ⇒ Object (readonly)
Returns the value of attribute diff.
11 12 13 |
# File 'lib/simulacrum/comparator.rb', line 11 def diff @diff end |
Instance Method Details
#test ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/simulacrum/comparator.rb', line 18 def test # 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 (pass?) ? pass : fail # Otherwise we should just write the captured candidate to disk, and mark # the spec as being pending until the user works out if the candidate is # OK by renaming candidate.png to reference.png else skip end end |