Class: Cucumber::Messages::Pickle
- Defined in:
- lib/cucumber/messages/pickle.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
-
#ast_node_ids ⇒ Object
readonly
-
Points to the AST node locations of the pickle.
-
-
#id ⇒ Object
readonly
-
A unique id for the pickle.
-
-
#language ⇒ Object
readonly
The language of the pickle.
-
#name ⇒ Object
readonly
The name of the pickle.
-
#steps ⇒ Object
readonly
One or more steps.
-
#tags ⇒ Object
readonly
-
One or more tags.
-
-
#uri ⇒ Object
readonly
The uri of the source file.
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Returns a new Pickle from the given hash.
Instance Method Summary collapse
-
#initialize(id: '', uri: '', name: '', language: '', steps: [], tags: [], ast_node_ids: []) ⇒ Pickle
constructor
A new instance of Pickle.
Methods inherited from Message
camelize, from_json, #to_h, #to_json
Constructor Details
#initialize(id: '', uri: '', name: '', language: '', steps: [], tags: [], ast_node_ids: []) ⇒ Pickle
Returns a new instance of Pickle.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cucumber/messages/pickle.rb', line 66 def initialize( id: '', uri: '', name: '', language: '', steps: [], tags: [], ast_node_ids: [] ) @id = id @uri = uri @name = name @language = language @steps = steps @tags = @ast_node_ids = ast_node_ids super() end |
Instance Attribute Details
#ast_node_ids ⇒ Object (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.
64 65 66 |
# File 'lib/cucumber/messages/pickle.rb', line 64 def ast_node_ids @ast_node_ids end |
#id ⇒ Object (readonly)
*
A unique id for the pickle
29 30 31 |
# File 'lib/cucumber/messages/pickle.rb', line 29 def id @id end |
#language ⇒ Object (readonly)
The language of the pickle
44 45 46 |
# File 'lib/cucumber/messages/pickle.rb', line 44 def language @language end |
#name ⇒ Object (readonly)
The name of the pickle
39 40 41 |
# File 'lib/cucumber/messages/pickle.rb', line 39 def name @name end |
#steps ⇒ Object (readonly)
One or more steps
49 50 51 |
# File 'lib/cucumber/messages/pickle.rb', line 49 def steps @steps end |
#tags ⇒ Object (readonly)
*
One or more tags. If this pickle is constructed from a Gherkin document,
It includes inherited tags from the `Feature` as well.
56 57 58 |
# File 'lib/cucumber/messages/pickle.rb', line 56 def @tags end |
#uri ⇒ Object (readonly)
The uri of the source file
34 35 36 |
# File 'lib/cucumber/messages/pickle.rb', line 34 def uri @uri end |
Class Method Details
.from_h(hash) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cucumber/messages/pickle.rb', line 92 def self.from_h(hash) return nil if hash.nil? 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 |