lib/scientist/observation.rb
# Is this observation equivalent to another?
#
# other      - the other Observation in question
# comparator - an optional comparison block. This observation's value and the
#              other observation's value are yielded to this to determine
#              their equivalency. Block should return true/false.
#
# Returns true if:
#
# * The values of the observation are equal (using `==`)
# * The values of the observations are equal according to a comparison
#   block, if given
# * Both observations raised an exception with the same class and message.
#
# Returns false otherwise.


Returns true if.

The values of the observation are equal (using `==`)
The values of the observations are equal according to a comparison
block, if given
Both observations raised an exception with the same class and message.

Returns false otherwise.
Returns true if . The values of the observation are equal ( using ` == ` ) The values of the observations are equal according to a comparison block if given Both observations raised an exception with the same class and message . Returns false otherwise .
def equivalent_to?(other, &comparator)
    return false unless other.is_a?(Scientist::Observation)
    if raised? || other.raised?
      return other.exception.class == exception.class &&
        other.exception.message == exception.message
    end
    if comparator
      comparator.call(value, other.value)
    else
      value == other.value
    end
  end
def equivalent_to? ( other , & comparator ) return false unless other . is_a? ( Scientist :: Observation ) if raised? || other . raised? return other . exception . class == exception . class && other . exception . message == exception . message end if comparator comparator . call ( value , other . value ) else value == other . value end end
Is this observation equivalent to another?
Is this observation equivalent to another?
other
comparator