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.



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

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.



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

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


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

def ast_node_ids
  @ast_node_ids
end

#idObject (readonly)

A unique ID for the PickleStep



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

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



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

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)



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

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... ...>


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

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