Exception: EqualAssay

Inherits:
LikeAssay show all
Defined in:
lib/assay/equal_assay.rb

Overview

EqualAssay coers the assertion comparing two objects with ‘#==` operator.

Direct Known Subclasses

EqualityAssay, UnequalAssay

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Constants included from Assay::Assertable

Assay::Assertable::SIZE_LIMIT

Class Method Summary collapse

Methods inherited from Assertion

by_name, by_operator, inherited, register, subclasses

Methods included from Assay::Assertable

#[], #assert!, #assert_message, #assertive_name, #assertor, #fail?, #operator, #pass?, #refute!, #refute_message

Class Method Details

.assert_message(subject, criterion) ⇒ Object

Error message for equal assertion.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/assay/equal_assay.rb', line 19

def self.assert_message(subject, criterion)
  a = subject.inspect
  b = criterion.inspect

  if a.size > SIZE_LIMIT or b.size > SIZE_LIMIT
    if $ansi
      d = ANSI::Diff.new(a, b)
      a, b = d.diff1, d.diff2  # *d.to_a
    end
    "a == b\na) #{a}\nb) #{b}"
  else
    "#{a} == #{b}"
  end
end

.pass?(subject, criterion) ⇒ Boolean

Test assertion of ‘#==` method.

Returns:

  • (Boolean)


12
13
14
# File 'lib/assay/equal_assay.rb', line 12

def self.pass?(subject, criterion)
  subject == criterion
end