Class: Cucumber::Messages::PickleStep

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/pickle_step.rb

Overview

Represents the PickleStep message in Cucumber’s message protocol.

An executable step

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(argument: nil, ast_node_ids: [], id: '', type: nil, text: '') ⇒ PickleStep

Returns a new instance of PickleStep.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cucumber/messages/pickle_step.rb', line 35

def initialize(
  argument: nil,
  ast_node_ids: [],
  id: '',
  type: nil,
  text: ''
)
  @argument = argument
  @ast_node_ids = ast_node_ids
  @id = id
  @type = type
  @text = text
  super()
end

Instance Attribute Details

#argumentObject (readonly)

Returns the value of attribute argument.



13
14
15
# File 'lib/cucumber/messages/pickle_step.rb', line 13

def argument
  @argument
end

#ast_node_idsObject (readonly)

References the IDs of the source of the step. For Gherkin, this can be the ID of a Step, and possibly also the ID of a TableRow



19
20
21
# File 'lib/cucumber/messages/pickle_step.rb', line 19

def ast_node_ids
  @ast_node_ids
end

#idObject (readonly)

A unique ID for the PickleStep



24
25
26
# File 'lib/cucumber/messages/pickle_step.rb', line 24

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



33
34
35
# File 'lib/cucumber/messages/pickle_step.rb', line 33

def text
  @text
end

#typeObject (readonly)

The context in which the step was specified: context (Given), action (When) or outcome (Then).

Note that the keywords ‘But` and `And` inherit their meaning from prior steps and the `*` ’keyword’ doesn’t have specific meaning (hence Unknown)



31
32
33
# File 'lib/cucumber/messages/pickle_step.rb', line 31

def type
  @type
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new PickleStep from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::PickleStep.from_h(some_hash) # => #<Cucumber::Messages::PickleStep:0x... ...>


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cucumber/messages/pickle_step.rb', line 57

def self.from_h(hash)
  return nil if hash.nil?

  new(
    argument: PickleStepArgument.from_h(hash[:argument]),
    ast_node_ids: hash[:astNodeIds],
    id: hash[:id],
    type: hash[:type],
    text: hash[:text]
  )
end