Module: Quarry::Grammar::Assert
- Defined in:
- lib/quarry/grammar/assert.rb
Overview
Assert Nomenclature
Some people prefer TDD over BDD so we also provide an assertion-based nomenclature.
Instance Method Summary collapse
-
#assert(test = nil, msg = nil) ⇒ Object
Assert a operational relationship.
-
#assert!(test = nil, msg = nil) ⇒ Object
(also: #refute)
Assert not an operational relationship.
Instance Method Details
#assert(test = nil, msg = nil) ⇒ Object
Assert a operational relationship.
4.assert == 3
16 17 18 19 20 21 22 23 |
# File 'lib/quarry/grammar/assert.rb', line 16 def assert(test=nil, msg=nil) if test msg = "failed assertion (no message given)" unless msg raise Assertion.new(msg, caller) unless test else return Expectation.new(self, :backtrace=>caller) end end |
#assert!(test = nil, msg = nil) ⇒ Object Also known as: refute
Assert not an operational relationship. Read it as “assert not”.
4.assert! == 4
AUHTOR’S NOTE: This method would not be necessary if Ruby would allow != to be define as a method, or at least ! as a unary method.
34 35 36 37 38 39 40 41 |
# File 'lib/quarry/grammar/assert.rb', line 34 def assert!(test=nil, msg=nil) if test msg = "failed assertion (no message given)" unless msg raise Assertion.new(msg, caller) if test else return Expectation.new(self, :negate=>true, :backtrace=>caller) end end |