Exception: Assay::EqualityFailure
- Inherits:
-
CompareFailure
- Object
- Exception
- Assertion
- CompareFailure
- Assay::EqualityFailure
- Defined in:
- lib/assay/assertions/equality_failure.rb
Constant Summary
Constants inherited from Assertion
Class Method Summary collapse
- .assertion_name ⇒ Object
- .assertion_operator ⇒ Object
-
.fail?(exp, act) ⇒ Boolean
Check negated assertion.
-
.pass?(exp, act) ⇒ Boolean
Check assertion.
Instance Method Summary collapse
Methods inherited from Assertion
assert, #assert, assertable_method, #assertion?, #fail?, #initialize, #negative?, #pass?, refute, #refute, #set_arguments, #set_negative, to_matcher
Constructor Details
This class inherits a constructor from Assay::Assertion
Class Method Details
.assertion_name ⇒ Object
9 10 11 |
# File 'lib/assay/assertions/equality_failure.rb', line 9 def self.assertion_name :equal end |
.assertion_operator ⇒ Object
14 15 16 |
# File 'lib/assay/assertions/equality_failure.rb', line 14 def self.assertion_operator :== end |
.fail?(exp, act) ⇒ Boolean
Check negated assertion.
24 25 26 |
# File 'lib/assay/assertions/equality_failure.rb', line 24 def self.fail?(exp, act) exp != act end |
.pass?(exp, act) ⇒ Boolean
Check assertion.
19 20 21 |
# File 'lib/assay/assertions/equality_failure.rb', line 19 def self.pass?(exp, act) exp == act end |
Instance Method Details
#to_s ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/assay/assertions/equality_failure.rb', line 29 def to_s return super unless @arguments.size == 2 oper = @_negated ? "!=" : "==" iexp = @arguments[0].inspect iact = @arguments[1].inspect if iexp.size > SIZE_LIMIT or iact.size > SIZE_LIMIT diff = ANSI::Diff.new(iact, iexp) "a #{oper} b\na) #{diff.diff1}\nb) #{diff.diff2}" else "#{iact} #{oper} #{iexp}" end end |