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
-
#candidate ⇒ Object
Returns the value of attribute candidate.
-
#component ⇒ Object
Returns the value of attribute component.
-
#diff ⇒ Object
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
Returns a new instance of Comparator.
12 13 14 15 |
# File 'lib/simulacrum/comparator.rb', line 12 def initialize(component) @component = component @component.render end |
Instance Attribute Details
#candidate ⇒ Object
Returns the value of attribute candidate.
10 11 12 |
# File 'lib/simulacrum/comparator.rb', line 10 def candidate @candidate end |
#component ⇒ Object
Returns the value of attribute component.
10 11 12 |
# File 'lib/simulacrum/comparator.rb', line 10 def component @component end |
#diff ⇒ Object
Returns the value of attribute diff.
10 11 12 |
# File 'lib/simulacrum/comparator.rb', line 10 def diff @diff end |
Instance Method Details
#test ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/simulacrum/comparator.rb', line 17 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 perform_diff ? 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 |