Exception: UnequalAssay
- Inherits:
-
EqualAssay
- Object
- Exception
- Assertion
- LikeAssay
- EqualAssay
- UnequalAssay
- Defined in:
- lib/assay/unequal_assay.rb
Overview
UnequalAssay compares objects with ‘#!=` operator. Yes, as of Ruby 1.9 the `!=` is a redefinable method, and as such, we need a separate assay to cover it.
Constant Summary
Constants inherited from Assertion
Constants included from Assay::Assertable
Class Method Summary collapse
-
.assert_message(subject, criterion) ⇒ Object
Failed assertion message.
-
.pass?(subject, criterion) ⇒ Boolean
Check assertion using ‘#!=` 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
Failed assertion message.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/assay/unequal_assay.rb', line 21 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
Check assertion using ‘#!=` method.
14 15 16 |
# File 'lib/assay/unequal_assay.rb', line 14 def self.pass?(subject, criterion) subject != criterion end |