Exception: EqualAssay
- Defined in:
- lib/assay/equal_assay.rb
Overview
EqualAssay coers the assertion comparing two objects with ‘#==` operator.
Direct Known Subclasses
Constant Summary
Constants inherited from Assertion
Constants included from Assay::Assertable
Class Method Summary collapse
-
.assert_message(subject, criterion) ⇒ Object
Error message for equal assertion.
-
.pass?(subject, criterion) ⇒ Boolean
Test assertion of ‘#==` method.
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.(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.
12 13 14 |
# File 'lib/assay/equal_assay.rb', line 12 def self.pass?(subject, criterion) subject == criterion end |