Class: Cucumber::Gherkin::DataTableParser
- Inherits:
-
Object
- Object
- Cucumber::Gherkin::DataTableParser
- Defined in:
- lib/cucumber/gherkin/data_table_parser.rb
Instance Method Summary collapse
- #feature_header ⇒ Object
- #gherkin_options ⇒ Object
-
#initialize(builder) ⇒ DataTableParser
constructor
A new instance of DataTableParser.
- #parse(text) ⇒ Object
Constructor Details
#initialize(builder) ⇒ DataTableParser
Returns a new instance of DataTableParser.
9 10 11 |
# File 'lib/cucumber/gherkin/data_table_parser.rb', line 9 def initialize(builder) @builder = builder end |
Instance Method Details
#feature_header ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cucumber/gherkin/data_table_parser.rb', line 36 def feature_header dialect = ::Gherkin::Dialect.for('en') %(#{dialect.feature_keywords[0]}: #{dialect.scenario_keywords[0]}: #{dialect.given_keywords[0]} x ) end |
#gherkin_options ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/cucumber/gherkin/data_table_parser.rb', line 28 def { include_source: false, include_gherkin_document: true, include_pickles: false } end |
#parse(text) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cucumber/gherkin/data_table_parser.rb', line 13 def parse(text) gherkin_document = nil = ::Gherkin.from_source('dummy', feature_header + text, ) .each do || gherkin_document = .gherkin_document.to_h unless .gherkin_document.nil? end return if gherkin_document.nil? gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row| @builder.row(row[:cells].map { |cell| cell[:value] }) end end |