Class: Turnip::StepDefinition
- Inherits:
-
Object
- Object
- Turnip::StepDefinition
- Defined in:
- lib/turnip/step_definition.rb
Defined Under Namespace
Classes: Match
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#called_from ⇒ Object
readonly
Returns the value of attribute called_from.
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
-
#initialize(expression, method_name = nil, called_from = nil, &block) ⇒ StepDefinition
constructor
A new instance of StepDefinition.
- #match(description) ⇒ Object
- #regexp ⇒ Object
Constructor Details
#initialize(expression, method_name = nil, called_from = nil, &block) ⇒ StepDefinition
Returns a new instance of StepDefinition.
15 16 17 18 19 20 |
# File 'lib/turnip/step_definition.rb', line 15 def initialize(expression, method_name=nil, called_from=nil, &block) @expression = expression @method_name = method_name || expression @called_from = called_from @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
13 14 15 |
# File 'lib/turnip/step_definition.rb', line 13 def block @block end |
#called_from ⇒ Object (readonly)
Returns the value of attribute called_from.
13 14 15 |
# File 'lib/turnip/step_definition.rb', line 13 def called_from @called_from end |
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
13 14 15 |
# File 'lib/turnip/step_definition.rb', line 13 def expression @expression end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
13 14 15 |
# File 'lib/turnip/step_definition.rb', line 13 def method_name @method_name end |
Instance Method Details
#match(description) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/turnip/step_definition.rb', line 26 def match(description) result = description.match(regexp) if result params = result.captures @placeholder_names.each_with_index do |name, index| params[index] = Turnip::Placeholder.apply(name.to_sym, params[index]) end Match.new(self, params, block) end end |
#regexp ⇒ Object
22 23 24 |
# File 'lib/turnip/step_definition.rb', line 22 def regexp @regexp ||= compile_regexp end |