Module: AE::Assert

Included in:
Object
Defined in:
lib/ae/assert.rb

Overview

Assert

Instance Method Summary collapse

Instance Method Details

#assert(*args, &block) ⇒ Object

Assert a operational relationship.

4.assert == 3

If only a single test argument is given then #assert simple validates that it evalutate to true. An optional message argument can be given in this case which will be used instead of the deafult message.

assert(4==3, "not the same thing")

In block form, #assert ensures the block evalutes truthfully, i.e. not as nil or false.

assert{ 4==3 }


25
26
27
# File 'lib/ae/assert.rb', line 25

def assert(*args, &block)
  Assertor.new(self, :backtrace=>caller).assert(*args, &block)
end

#assert=(cmp) ⇒ Object

Same as ‘object.assert == other’.



30
31
32
# File 'lib/ae/assert.rb', line 30

def assert=(cmp)
  Assertor.new(self, :backtrace=>caller).assert == cmp
end

#refute(*args, &block) ⇒ Object Also known as: assert!

Assert not an operational relationship. Read it as “assert not”.

4.refute == 4  #=> Assertion Error

See #assert.



40
41
42
# File 'lib/ae/assert.rb', line 40

def refute(*args, &block)
  Assertor.new(self, :backtrace=>caller).not.assert(*args, &block)
end

#refute=(cmp) ⇒ Object

Same as ‘object.assert == other’.



45
46
47
# File 'lib/ae/assert.rb', line 45

def refute=(cmp)
  Assertor.new(self, :backtrace=>caller).not.assert == cmp
end