Class: Speck
- Inherits:
-
Object
- Object
- Speck
- Defined in:
- lib/speck.rb,
lib/speck/check.rb,
lib/speck/core_ext/check_mixins.rb
Overview
All library files are required at the bottom, because in this unique case we
need Speck defined before we can use it to Speck anything.
Defined Under Namespace
Modules: Mixins Classes: Check, Exception
Constant Summary collapse
- Version =
0
Class Attribute Summary collapse
-
.specks ⇒ Object
All defined Specks.
-
.stack ⇒ Object
The current stack of nested
Specks.
Instance Attribute Summary collapse
-
#checks ⇒ Object
The checks involved in the current
Speck. -
#children ⇒ Object
Child
Specks. -
#parent ⇒ Object
Parent
Speck. -
#speck ⇒ Object
The block to be executed.
Class Method Summary collapse
-
.current ⇒ Object
Returns the currently active
Speck.
Instance Method Summary collapse
-
#execute ⇒ Object
Executes the
Speck. -
#initialize(*targets, &speck) ⇒ Speck
constructor
Creates a new
Speck.
Constructor Details
#initialize(*targets, &speck) ⇒ Speck
Creates a new Speck.
51 52 53 54 55 56 57 |
# File 'lib/speck.rb', line 51 def initialize *targets, &speck @speck = speck @parent = Speck.current @parent.children << self if @parent Speck.specks << self end |
Class Attribute Details
.specks ⇒ Object
All defined Specks.
11 12 13 |
# File 'lib/speck.rb', line 11 def specks @specks end |
.stack ⇒ Object
The current stack of nested Specks.
18 19 20 |
# File 'lib/speck.rb', line 18 def stack @stack end |
Instance Attribute Details
#checks ⇒ Object
The checks involved in the current Speck.
46 47 48 |
# File 'lib/speck.rb', line 46 def checks @checks end |
#children ⇒ Object
Child Specks
37 38 39 |
# File 'lib/speck.rb', line 37 def children @children end |
#parent ⇒ Object
Parent Speck
42 43 44 |
# File 'lib/speck.rb', line 42 def parent @parent end |
#speck ⇒ Object
The block to be executed
33 34 35 |
# File 'lib/speck.rb', line 33 def speck @speck end |
Class Method Details
.current ⇒ Object
Returns the currently active Speck.
When your Specks are being run, there is a stack of Speck objects,
consisting of the current nesting list of Specks being run.
26 27 28 |
# File 'lib/speck.rb', line 26 def current stack.last end |
Instance Method Details
#execute ⇒ Object
Executes the Speck.
61 62 63 64 65 66 67 |
# File 'lib/speck.rb', line 61 def execute Speck::Mixins::mixin! Speck.stack << self speck.call Speck.stack.pop end |