Exception: UnequalAssay

Inherits:
EqualAssay show all
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

Assertion::SIZE_LIMIT

Constants included from Assay::Assertable

Assay::Assertable::SIZE_LIMIT

Class Method Summary collapse

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.assert_message(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.

Returns:

  • (Boolean)


14
15
16
# File 'lib/assay/unequal_assay.rb', line 14

def self.pass?(subject, criterion)
  subject != criterion
end