Class: Nanotest::Spec
Overview
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” –Antoine de Saint Exupéry
Instance Method Summary collapse
-
#initialize(obj, positive = true) ⇒ Spec
constructor
A new instance of Spec.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(obj, positive = true) ⇒ Spec
Returns a new instance of Spec.
7 8 9 |
# File 'lib/nanotest/spec.rb', line 7 def initialize(obj, positive=true) @obj, @positive = obj, positive end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/nanotest/spec.rb', line 11 def method_missing(method, *args, &block) file, line = caller.first.split(':')[0..1] bool = @obj.__send__(method, *args, &block) bool = !bool unless @positive Nanotest.assert(nil, file, line) { bool } @obj end |