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'
...
# Extend the world object with this module.
World(Macros4Cuke::MacroStepSupport)
Instance Method Summary collapse
-
#add_macro(aPhrase, aTemplate, useTable) ⇒ Object
Add a new macro.
-
#clear_macros ⇒ Object
Clear (remove) all the macro-step definitions.
-
#invoke_macro(aPhraseInstance, rawData = nil) ⇒ Object
Invoke a macro with given phrase and (optionally) a table of values That is, the text between [...] and with zero or more actual values.
Instance Method Details
#add_macro(aPhrase, aTemplate, useTable) ⇒ Object
Add a new macro. Pre-condition: there is no existing macro with the same key. the square brackets [...]. of sub-steps. used to pass actual values.
28 29 30 |
# File 'lib/macros4cuke/macro-step-support.rb', line 28 def add_macro(aPhrase, aTemplate, useTable) MacroCollection.instance.add_macro(aPhrase, aTemplate, useTable) end |
#clear_macros ⇒ Object
Clear (remove) all the macro-step definitions. After this, we are in the same situation when no macro-step was ever defined.
52 53 54 |
# File 'lib/macros4cuke/macro-step-support.rb', line 52 def clear_macros() MacroCollection.instance.clear() end |
#invoke_macro(aPhraseInstance, rawData = nil) ⇒ Object
Invoke a macro with given phrase and (optionally) a table of values That is, the text between [...] and with zero or more actual values. [macro argument name, a value]. Multiple rows with same argument name are acceptable.
39 40 41 42 43 44 45 46 |
# File 'lib/macros4cuke/macro-step-support.rb', line 39 def invoke_macro(aPhraseInstance, rawData = nil) # Generate a text rendition of the step to be executed. collection = MacroCollection.instance() rendered_steps = collection.render_steps(aPhraseInstance, rawData) # Let Cucumber execute the sub-steps steps(rendered_steps) end |