class Cucumber::Messages::Pickle

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`

Attributes

ast_node_ids[R]

*

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.
id[R]

*

A unique id for the pickle. This is a [SHA1](https://en.wikipedia.org/wiki/SHA-1) hash
from the source data and the `locations` of the pickle.
This ID will change if source the file is modified.
language[R]

The language of the pickle

name[R]

The name of the pickle

steps[R]

One or more steps

tags[R]

*

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

The uri of the source file

Public Class Methods

from_h(hash) click to toggle source

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... ...>
# File lib/cucumber/messages.deserializers.rb, line 609
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
new( id: '', uri: '', name: '', language: '', steps: [], tags: [], ast_node_ids: [] ) click to toggle source
# File lib/cucumber/messages.dtos.rb, line 1112
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