Class: Cucumber::Messages::Pickle
- Defined in:
- lib/cucumber/messages/pickle.rb
Overview
Represents the Pickle message in Cucumber's message protocol.
A Pickle represents a template for a TestCase. It is typically derived
from another format, such as 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.
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.
-
#location ⇒ Object
readonly
The location of this pickle in source file.
-
#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: '', location: nil, 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, #type
Constructor Details
#initialize(id: '', uri: '', location: nil, name: '', language: '', steps: [], tags: [], ast_node_ids: []) ⇒ Pickle
Returns a new instance of Pickle.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cucumber/messages/pickle.rb', line 65 def initialize( id: '', uri: '', location: nil, name: '', language: '', steps: [], tags: [], ast_node_ids: [] ) @id = id @uri = uri @location = location @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.
63 64 65 |
# File 'lib/cucumber/messages/pickle.rb', line 63 def ast_node_ids @ast_node_ids end |
#id ⇒ Object (readonly)
A unique id for the pickle
25 26 27 |
# File 'lib/cucumber/messages/pickle.rb', line 25 def id @id end |
#language ⇒ Object (readonly)
The language of the pickle
45 46 47 |
# File 'lib/cucumber/messages/pickle.rb', line 45 def language @language end |
#location ⇒ Object (readonly)
The location of this pickle in source file. A pickle constructed from Examples will point to the example row.
35 36 37 |
# File 'lib/cucumber/messages/pickle.rb', line 35 def location @location end |
#name ⇒ Object (readonly)
The name of the pickle
40 41 42 |
# File 'lib/cucumber/messages/pickle.rb', line 40 def name @name end |
#steps ⇒ Object (readonly)
One or more steps
50 51 52 |
# File 'lib/cucumber/messages/pickle.rb', line 50 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
30 31 32 |
# File 'lib/cucumber/messages/pickle.rb', line 30 def uri @uri end |
Class Method Details
.from_h(hash) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/cucumber/messages/pickle.rb', line 93 def self.from_h(hash) return nil if hash.nil? new( id: hash[:id], uri: hash[:uri], location: Location.from_h(hash[:location]), 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 |