Module: Macros4Cuke::MacroStepSupport
- Defined in:
- lib/macros4cuke/macro-step-support.rb
Overview
Mix-in module that should be extending World objects in Cucumber. Synopsis (in env.rb): require ‘macros4cuke’ … World(Macros4Cuke::MacroStepSupport) # Extend the world object with this module.
Class Method Summary collapse
-
.extended(world) ⇒ Object
Callback invoked when a World object is extend(ed) with this module.
Instance Method Summary collapse
-
#add_macro(aPhrase, aTemplate, useTable) ⇒ Object
Add a new macro.
-
#invoke_macro(aPhrase, rawData = nil) ⇒ Object
Invoke a macro with given phrase and (optionally) a table of values [aPhrase] an instance of the macro phrase.
Class Method Details
.extended(world) ⇒ Object
Callback invoked when a World object is extend(ed) with this module.
17 18 19 20 |
# File 'lib/macros4cuke/macro-step-support.rb', line 17 def self.extended(world) # Add & initialize an instance variable for macro support. MacroCollection::instance.init() end |
Instance Method Details
#add_macro(aPhrase, aTemplate, useTable) ⇒ Object
Add a new macro. Pre-condition: there is no existing macro with the same key.
- aPhrase
-
The text that is enclosed between the square brackets.
- aTemplate
-
A text that consists of a sequence of Cucumber steps.
- useTable
-
A boolean that indicates whether a table should be used to pass actual values.
30 31 32 |
# File 'lib/macros4cuke/macro-step-support.rb', line 30 def add_macro(aPhrase, aTemplate, useTable) MacroCollection::instance.add_macro(aPhrase, aTemplate, useTable) end |
#invoke_macro(aPhrase, rawData = nil) ⇒ Object
Invoke a macro with given phrase and (optionally) a table of values
- aPhrase
-
an instance of the macro phrase.
- rawData
-
An Array of couples.
Each couple is of the form: argument name, a value. Multiple rows with same argument name are acceptable.
40 41 42 43 44 45 46 |
# File 'lib/macros4cuke/macro-step-support.rb', line 40 def invoke_macro(aPhrase, rawData = nil) # Generate a text rendition of the step to be executed. rendered_steps = MacroCollection::instance.render_steps(aPhrase, rawData) # Execute the steps steps(rendered_steps) end |