Sha256: e01310098f7ea4faf6de46aaf42ac3e6a845d800ce4381f4ee1d76fda944c185
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
module Quarry module Grammar # = Assert Nomenclature # # Some people prefer TDD over BDD so we also provide an # assertion-based nomenclature. # module Assert # Assert a operational relationship. # # 4.assert == 3 # 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 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. # 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 # Same as #assert!. # # 4.refute == 4 #=> Assertion Error # alias_method :refute, :assert! end end class ::Object #:nodoc: include Grammar::Assert end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quarry-0.5.2 | lib/quarry/grammar/assert.rb |