Exception: Assay::TrueFailure

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

Overview

Comparison assertion for TrueClass.

TrueFailure.pass?(true) #=> true
TrueFailure.fail?(true) #=> false
TrueFailure.pass?(1)    #=> false

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



13
14
15
# File 'lib/assay/assertions/true_failure.rb', line 13

def self.assertion_name
  :true
end

.assertion_operatorObject



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

def self.assertion_operator
  :true?
end

.pass?(exp) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


22
23
24
# File 'lib/assay/assertions/true_failure.rb', line 22

def self.pass?(exp)
  TrueClass === exp
end

Instance Method Details

#to_sObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/assay/assertions/true_failure.rb', line 27

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

  exp = @arguments[0].inspect

  if @_negated
    "Expected #{exp} to NOT be true"
  else
    "Expected #{exp} to be true"
  end
end