Class: Assertion::True
Direct Known Subclasses
Class Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *a, &b) ⇒ Object (private)
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/quarry/assertion.rb', line 57 def method_missing( sym, *a, &b ) case sym when :raise?, :raises? begin @delegate.call #yield assert false, "Expected #{a[0]} to be raised" rescue Exception => e assert a[0] === e, "Expected #{a[0]} to be raised, but got #{e.class}" return e end else msg = (@delegate, sym, *a, &b) assert(@delegate.send(sym, *a, &b ), msg) #assert( @delegate.send(sym, *a, &b ), self.class.message(sym)[@delegate, *a] ) end end |
Class Method Details
.message(msg, &block) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/quarry/assertion.rb', line 29 def self.(msg,&block) ||= {} if block [msg] = block else [msg] end end |