Class: Suture::Util::ComparesResults

Inherits:
Object
  • Object
show all
Defined in:
lib/suture/util/compares_results.rb

Instance Method Summary collapse

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.message == actual.value.message
  else
    @comparator.call(expected.value, actual.value)
  end
end