Class: Cucumber::Messages::Pickle

Inherits:
Message show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.deserializers.rb

Overview

Represents the Pickle message in Cucumber’s message protocol.

//// Pickles

*

A `Pickle` represents a template for a `TestCase`. It is typically derived
from another format, such as [GherkinDocument](#io.cucumber.messages.GherkinDocument).
In the future a `Pickle` may be derived from other formats such as Markdown or
Excel files.

By making `Pickle` the main data structure Cucumber uses for execution, the
implementation of Cucumber itself becomes simpler, as it doesn't have to deal
with the complex structure of a [GherkinDocument](#io.cucumber.messages.GherkinDocument).

Each `PickleStep` of a `Pickle` is matched with a `StepDefinition` to create a `TestCase`

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Message::Utils

included

Methods included from Message::Serialization

#to_h, #to_json

Methods included from Message::Deserialization

included

Constructor Details

#initialize(id: '', uri: '', name: '', language: '', steps: [], tags: [], ast_node_ids: []) ⇒ Pickle

Returns a new instance of Pickle.



1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1114

def initialize(
  id: '',
  uri: '',
  name: '',
  language: '',
  steps: [],
  tags: [],
  ast_node_ids: []
)
  @id = id
  @uri = uri
  @name = name
  @language = language
  @steps = steps
  @tags = tags
  @ast_node_ids = ast_node_ids
end

Instance Attribute Details

#ast_node_idsObject (readonly)

*

Points to the AST node locations of the pickle. The last one represents the unique
id of the pickle. A pickle constructed from `Examples` will have the first
id originating from the `Scenario` AST node, and the second from the `TableRow` AST node.


1112
1113
1114
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1112

def ast_node_ids
  @ast_node_ids
end

#idObject (readonly)

*

A unique id for the pickle


1077
1078
1079
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1077

def id
  @id
end

#languageObject (readonly)

The language of the pickle



1092
1093
1094
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1092

def language
  @language
end

#nameObject (readonly)

The name of the pickle



1087
1088
1089
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1087

def name
  @name
end

#stepsObject (readonly)

One or more steps



1097
1098
1099
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1097

def steps
  @steps
end

#tagsObject (readonly)

*

One or more tags. If this pickle is constructed from a Gherkin document,
It includes inherited tags from the `Feature` as well.


1104
1105
1106
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1104

def tags
  @tags
end

#uriObject (readonly)

The uri of the source file



1082
1083
1084
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1082

def uri
  @uri
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.deserializers.rb', line 610

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

  self.new(
    id: hash[:id],
    uri: hash[:uri],
    name: hash[:name],
    language: hash[:language],
    steps: hash[:steps]&.map { |item| PickleStep.from_h(item) },
    tags: hash[:tags]&.map { |item| PickleTag.from_h(item) },
    ast_node_ids: hash[:astNodeIds],
  )
end