Exception: CompareAssay
- Defined in:
- lib/assay/compare_assay.rb
Overview
Compare assertion serves primarily as a base class for other more specific comparison assertions.
In itself it can be used to test a comparision made by #<=>.
Direct Known Subclasses
CloseAssay, LessAssay, LessEqualAssay, MoreAssay, MoreEqualAssay, WithinAssay
Constant Summary
Constants inherited from Assertion
Constants included from Assay::Assertable
Class Method Summary collapse
-
.assert_message(subject, criterion, result = 0) ⇒ Object
Error message for campare assertion.
-
.pass?(subject, criterion, result = 0) ⇒ Boolean
Check assertion using ‘<=>`.
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, result = 0) ⇒ Object
Error message for campare assertion.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/assay/compare_assay.rb', line 25 def self.(subject, criterion, result=0) a = subject.inspect b = criterion.inspect r = result.inspect if a.size > SIZE_LIMIT or b.size > SIZE_LIMIT "a <=> b == #{r}\na) #{a}\nb) #{b}" else "#{a} <=> #{b} == #{r}" end end |
.pass?(subject, criterion, result = 0) ⇒ Boolean
Check assertion using ‘<=>`.
18 19 20 |
# File 'lib/assay/compare_assay.rb', line 18 def self.pass?(subject, criterion, result=0) (subject <=> criterion) == result end |