Module: AE::Assert
- Included in:
- Object
- Defined in:
- lib/ae/assert.rb
Overview
The Assert module is simple a conatiner module for the core extension methods: #assert, #expect, etc.
This module is included directory into the Object class.
Instance Method Summary collapse
-
#assert(*args, &block) ⇒ Assertor
Assert a operational relationship.
-
#assert=(cmp) ⇒ Assertor
Same as ‘object.assert == other’.
-
#flunk(message = nil, backtrace = nil) ⇒ Object
Directly raise an Assertion failure.
-
#refute(*args, &block) ⇒ Assertor
(also: #assert!)
Opposite of assert.
-
#refute=(cmp) ⇒ Assertor
Same as ‘object.refute == other’.
Instance Method Details
#assert(*args, &block) ⇒ Assertor
Assert a operational relationship.
4.assert == 3
If only a single test argument is given then #assert simply 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 }
28 29 30 |
# File 'lib/ae/assert.rb', line 28 def assert(*args, &block) Assertor.new(self, :backtrace=>caller).assert(*args, &block) end |
#assert=(cmp) ⇒ Assertor
Same as ‘object.assert == other’.
35 36 37 |
# File 'lib/ae/assert.rb', line 35 def assert=(cmp) Assertor.new(self, :backtrace=>caller).assert == cmp end |
#flunk(message = nil, backtrace = nil) ⇒ Object
Directly raise an Assertion failure.
75 76 77 78 |
# File 'lib/ae/assert.rb', line 75 def flunk(=nil, backtrace=nil) #Assertor.new(self, :backtrace=>caller).assert(false, message) Assertor.assert(false, , backtrace || caller) end |