How to use get_items method of Gherkin Package

Best Gherkin-ruby code snippet using Gherkin.get_items

ast_builder.rb

Source:ast_builder.rb Github

copy

Full Screen

...87 def get_description(node)88 node.get_single(:Description)89 end90 def get_steps(node)91 node.get_items(:Step)92 end93 def transform_node(node)94 case node.rule_type95 when :Step96 step_line = node.get_token(:StepLine)97 data_table = node.get_single(:DataTable)98 doc_string = node.get_single(:DocString)99 Cucumber::Messages::GherkinDocument::Feature::Step.new(100 location: get_location(step_line, 0),101 keyword: step_line.matched_keyword,102 text: step_line.matched_text,103 data_table: data_table,104 doc_string: doc_string,105 id: @id_generator.new_id106 )107 when :DocString108 separator_token = node.get_tokens(:DocStringSeparator)[0]109 media_type = separator_token.matched_text == '' ? nil : separator_token.matched_text110 line_tokens = node.get_tokens(:Other)111 content = line_tokens.map { |t| t.matched_text }.join("\n")112 Cucumber::Messages::GherkinDocument::Feature::Step::DocString.new(113 location: get_location(separator_token, 0),114 content: content,115 delimiter: separator_token.matched_keyword,116 media_type: media_type,117 )118 when :DataTable119 rows = get_table_rows(node)120 Cucumber::Messages::GherkinDocument::Feature::Step::DataTable.new(121 location: rows[0].location,122 rows: rows,123 )124 when :Background125 background_line = node.get_token(:BackgroundLine)126 description = get_description(node)127 steps = get_steps(node)128 Cucumber::Messages::GherkinDocument::Feature::Background.new(129 id: @id_generator.new_id,130 location: get_location(background_line, 0),131 keyword: background_line.matched_keyword,132 name: background_line.matched_text,133 description: description,134 steps: steps135 )136 when :ScenarioDefinition137 tags = get_tags(node)138 scenario_node = node.get_single(:Scenario)139 scenario_line = scenario_node.get_token(:ScenarioLine)140 description = get_description(scenario_node)141 steps = get_steps(scenario_node)142 examples = scenario_node.get_items(:ExamplesDefinition)143 Cucumber::Messages::GherkinDocument::Feature::Scenario.new(144 id: @id_generator.new_id,145 tags: tags,146 location: get_location(scenario_line, 0),147 keyword: scenario_line.matched_keyword,148 name: scenario_line.matched_text,149 description: description,150 steps: steps,151 examples: examples152 )153 when :ExamplesDefinition154 tags = get_tags(node)155 examples_node = node.get_single(:Examples)156 examples_line = examples_node.get_token(:ExamplesLine)157 description = get_description(examples_node)158 rows = examples_node.get_single(:ExamplesTable)159 table_header = rows.nil? ? nil : rows.first160 table_body = rows.nil? ? nil : rows[1..-1]161 Cucumber::Messages::GherkinDocument::Feature::Scenario::Examples.new(162 id: @id_generator.new_id,163 tags: tags,164 location: get_location(examples_line, 0),165 keyword: examples_line.matched_keyword,166 name: examples_line.matched_text,167 description: description,168 table_header: table_header,169 table_body: table_body,170 )171 when :ExamplesTable172 get_table_rows(node)173 when :Description174 line_tokens = node.get_tokens(:Other)175 # Trim trailing empty lines176 last_non_empty = line_tokens.rindex { |token| !token.line.trimmed_line_text.empty? }177 description = line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")178 return description179 when :Feature180 header = node.get_single(:FeatureHeader)181 return unless header182 tags = get_tags(header)183 feature_line = header.get_token(:FeatureLine)184 return unless feature_line185 children = []186 background = node.get_single(:Background)187 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(background: background)) if background188 node.get_items(:ScenarioDefinition).each do |scenario|189 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(scenario: scenario))190 end191 node.get_items(:Rule).each do |rule|192 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(rule: rule))193 end194 description = get_description(header)195 language = feature_line.matched_gherkin_dialect196 Cucumber::Messages::GherkinDocument::Feature.new(197 tags: tags,198 location: get_location(feature_line, 0),199 language: language,200 keyword: feature_line.matched_keyword,201 name: feature_line.matched_text,202 description: description,203 children: children,204 )205 when :Rule206 header = node.get_single(:RuleHeader)207 return unless header208 rule_line = header.get_token(:RuleLine)209 return unless rule_line210 children = []211 background = node.get_single(:Background)212 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild::RuleChild.new(background: background)) if background213 node.get_items(:ScenarioDefinition).each do |scenario|214 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild::RuleChild.new(scenario: scenario))215 end216 description = get_description(header)217 Cucumber::Messages::GherkinDocument::Feature::FeatureChild::Rule.new(218 id: @id_generator.new_id,219 location: get_location(rule_line, 0),220 keyword: rule_line.matched_keyword,221 name: rule_line.matched_text,222 description: description,223 children: children,224 )225 when :GherkinDocument226 feature = node.get_single(:Feature)227 {...

Full Screen

Full Screen

get_items

Using AI Code Generation

copy

Full Screen

1formatter = Gherkin::Formatter::PrettyFormatter.new(STDOUT)2formatter.uri('features/feature.feature')3gherkin.parse(File.open('features/feature.feature'), formatter, true, 'features/feature.feature')4formatter = Gherkin::Formatter::PrettyFormatter.new(STDOUT)5formatter.uri('features/feature.feature')6gherkin.parse(File.open('features/feature.feature'), formatter, true, 'features/feature.feature')7formatter = Gherkin::Formatter::PrettyFormatter.new(STDOUT)8formatter.uri('features/feature.feature')9gherkin.parse(File.open('features/feature.feature'), formatter, true, 'features/feature.feature')10formatter = Gherkin::Formatter::PrettyFormatter.new(STDOUT)11formatter.uri('features/feature.feature')12gherkin.parse(File.open('features/feature.feature'), formatter,

Full Screen

Full Screen

get_items

Using AI Code Generation

copy

Full Screen

1gherkin.add_item('Burger')2gherkin.add_item('Burger')3gherkin.add_item('Pizza')4gherkin.add_item('Burger')5gherkin.add_item('Pizza')6gherkin.add_item('Biryani')7gherkin.add_item('Salad')

Full Screen

Full Screen

get_items

Using AI Code Generation

copy

Full Screen

1gherkin.add_item('Burger')2gherkin.add_item('Burger')3gherkin.add_item('Pizza')4gherkin.add_item('Burger')5gherkin.add_item('Pizza')6gherkin.add_item('Biryani')7gherkin.add_item('Salad')

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gherkin-ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful