Class: Cucumber::Messages::TestStep
- Defined in:
- lib/cucumber/messages/test_step.rb
Overview
Represents the TestStep message in Cucumber's message protocol.
A TestStep is derived from either a PickleStep combined with a StepDefinition, or from a Hook.
When derived from a PickleStep:
- For
UNDEFINEDstepsstepDefinitionIdsandstepMatchArgumentsListswill be empty. - For
AMBIGUOUSsteps, there will be multiple entries instepDefinitionIdsandstepMatchArgumentsLists. The first entry in the stepMatchArgumentsLists holds the list of arguments for the first matching step definition, the second entry for the second, etc
Instance Attribute Summary collapse
-
#hook_id ⇒ Object
readonly
Pointer to the
Hook(if derived from a Hook). -
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pickle_step_id ⇒ Object
readonly
Pointer to the
PickleStep(if derived from aPickleStep). -
#step_definition_ids ⇒ Object
readonly
Pointer to all the matching
StepDefinitions (if derived from aPickleStep). -
#step_match_arguments_lists ⇒ Object
readonly
A list of list of StepMatchArgument (if derived from a
PickleStep).
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Returns a new TestStep from the given hash.
Instance Method Summary collapse
-
#initialize(hook_id: nil, id: '', pickle_step_id: nil, step_definition_ids: nil, step_match_arguments_lists: nil) ⇒ TestStep
constructor
A new instance of TestStep.
Methods inherited from Message
camelize, from_json, #to_h, #to_json, #type
Constructor Details
#initialize(hook_id: nil, id: '', pickle_step_id: nil, step_definition_ids: nil, step_match_arguments_lists: nil) ⇒ TestStep
Returns a new instance of TestStep.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cucumber/messages/test_step.rb', line 43 def initialize( hook_id: nil, id: '', pickle_step_id: nil, step_definition_ids: nil, step_match_arguments_lists: nil ) @hook_id = hook_id @id = id @pickle_step_id = pickle_step_id @step_definition_ids = step_definition_ids @step_match_arguments_lists = step_match_arguments_lists super() end |
Instance Attribute Details
#hook_id ⇒ Object (readonly)
Pointer to the Hook (if derived from a Hook)
20 21 22 |
# File 'lib/cucumber/messages/test_step.rb', line 20 def hook_id @hook_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/cucumber/messages/test_step.rb', line 22 def id @id end |
#pickle_step_id ⇒ Object (readonly)
Pointer to the PickleStep (if derived from a PickleStep)
27 28 29 |
# File 'lib/cucumber/messages/test_step.rb', line 27 def pickle_step_id @pickle_step_id end |
#step_definition_ids ⇒ Object (readonly)
Pointer to all the matching StepDefinitions (if derived from a PickleStep).
Each element represents a matching step definition.
34 35 36 |
# File 'lib/cucumber/messages/test_step.rb', line 34 def step_definition_ids @step_definition_ids end |
#step_match_arguments_lists ⇒ Object (readonly)
A list of list of StepMatchArgument (if derived from a PickleStep).
Each element represents the arguments for a matching step definition.
41 42 43 |
# File 'lib/cucumber/messages/test_step.rb', line 41 def step_match_arguments_lists @step_match_arguments_lists end |
Class Method Details
.from_h(hash) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cucumber/messages/test_step.rb', line 65 def self.from_h(hash) return nil if hash.nil? new( hook_id: hash[:hookId], id: hash[:id], pickle_step_id: hash[:pickleStepId], step_definition_ids: hash[:stepDefinitionIds], step_match_arguments_lists: hash[:stepMatchArgumentsLists]&.map { |item| StepMatchArgumentsList.from_h(item) } ) end |