Class: Suture::Util::ComparesResults
- Inherits:
-
Object
- Object
- Suture::Util::ComparesResults
- Defined in:
- lib/suture/util/compares_results.rb
Instance Method Summary collapse
- #compare(expected, actual) ⇒ Object
-
#initialize(comparator) ⇒ ComparesResults
constructor
A new instance of ComparesResults.
Constructor Details
#initialize(comparator) ⇒ ComparesResults
Returns a new instance of ComparesResults.
3 4 5 |
# File 'lib/suture/util/compares_results.rb', line 3 def initialize(comparator) @comparator = comparator end |
Instance Method Details
#compare(expected, actual) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/suture/util/compares_results.rb', line 7 def compare(expected, actual) if expected.errored? != actual.errored? false elsif expected.errored? actual.value.kind_of?(expected.value.class) && expected.value. == actual.value. else @comparator.call(expected.value, actual.value) end end |