Class: Insist
- Inherits:
-
Object
- Object
- Insist
- Includes:
- Assert, Comparators, Enumerables, Nil, Predicates, Raises
- Defined in:
- lib/insist.rb,
lib/insist/namespace.rb
Overview
Insist on correctness.
Example:
data = { "hello" => "world" }
insist { data["hello"] } == "world"
This class aims to work similarly to how rspec’s “should” stuff does, but instead of molesting Object allows you to neatly wrap values with blocks while still checking for expected values.
Direct Known Subclasses
Defined Under Namespace
Modules: Assert, Comparators, Enumerables, Nil, Predicates, Raises Classes: Failure
Constant Summary
Constants included from Predicates
Predicates::PREDICATE_METHOD_RE
Instance Method Summary collapse
-
#initialize(&block) ⇒ Insist
constructor
Create a new insist with a block.
-
#value ⇒ Object
def initialize.
Methods included from Predicates
Methods included from Assert
Methods included from Raises
Methods included from Nil
Methods included from Enumerables
Methods included from Comparators
#!=, #!~, #<, #<=, #==, #=~, #>, #>=
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Insist::Predicates
Instance Method Details
#value ⇒ Object
def initialize
45 46 47 48 49 |
# File 'lib/insist.rb', line 45 def value # TODO(sissel): make caching the value optional @value ||= @callback.call return @value end |