Exception: Assay::SameFailure

Inherits:
CompareFailure show all
Defined in:
lib/assay/assertions/same_failure.rb

Overview

Comparison assertion for the #eql? method.

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Assertion

assert, #assert, assertable_method, #assertion?, #fail?, 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_nameObject



8
9
10
# File 'lib/assay/assertions/same_failure.rb', line 8

def self.assertion_name
  :same
end

.assertion_operatorObject



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

def self.assertion_operator
  :eql?
end

.pass?(exp, act) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


17
18
19
# File 'lib/assay/assertions/same_failure.rb', line 17

def self.pass?(exp, act)
  exp.eql?(act)
end

Instance Method Details

#to_sObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/assay/assertions/same_failure.rb', line 22

def to_s
  return super unless @arguments.size == 2

  exp = @arguments[0].inspect
  act = @arguments[1].inspect

  if @_negated
    "Expected #{act} to NOT be the same as #{exp}"
  else
    "Expected #{act} to be the same as #{exp}"
  end
end