How to use get_description method of Gherkin Package

Best Gherkin-ruby code snippet using Gherkin.get_description

ast_builder.rb

Source:ast_builder.rb Github

copy

Full Screen

...84 value: cell_item.text85 )86 end87 end88 def get_description(node)89 node.get_single(:Description)90 end91 def get_steps(node)92 node.get_items(:Step)93 end94 def transform_node(node)95 case node.rule_type96 when :Step97 step_line = node.get_token(:StepLine)98 data_table = node.get_single(:DataTable)99 doc_string = node.get_single(:DocString)100 Cucumber::Messages::GherkinDocument::Feature::Step.new(101 location: get_location(step_line, 0),102 keyword: step_line.matched_keyword,103 text: step_line.matched_text,104 data_table: data_table,105 doc_string: doc_string,106 id: @id_generator.new_id107 )108 when :DocString109 separator_token = node.get_tokens(:DocStringSeparator)[0]110 content_type = separator_token.matched_text == '' ? nil : separator_token.matched_text111 line_tokens = node.get_tokens(:Other)112 content = line_tokens.map { |t| t.matched_text }.join("\n")113 Cucumber::Messages::GherkinDocument::Feature::Step::DocString.new(114 location: get_location(separator_token, 0),115 content: content,116 delimiter: separator_token.matched_keyword,117 content_type: content_type,118 )119 when :DataTable120 rows = get_table_rows(node)121 Cucumber::Messages::GherkinDocument::Feature::Step::DataTable.new(122 location: rows[0].location,123 rows: rows,124 )125 when :Background126 background_line = node.get_token(:BackgroundLine)127 description = get_description(node)128 steps = get_steps(node)129 Cucumber::Messages::GherkinDocument::Feature::Background.new(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 tags: tags,163 location: get_location(examples_line, 0),164 keyword: examples_line.matched_keyword,165 name: examples_line.matched_text,166 description: description,167 table_header: table_header,168 table_body: table_body,169 )170 when :ExamplesTable171 get_table_rows(node)172 when :Description173 line_tokens = node.get_tokens(:Other)174 # Trim trailing empty lines175 last_non_empty = line_tokens.rindex { |token| !token.line.trimmed_line_text.empty? }176 description = line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")177 return description178 when :Feature179 header = node.get_single(:FeatureHeader)180 return unless header181 tags = get_tags(header)182 feature_line = header.get_token(:FeatureLine)183 return unless feature_line184 children = []185 background = node.get_single(:Background)186 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(background: background)) if background187 node.get_items(:ScenarioDefinition).each do |scenario|188 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(scenario: scenario))189 end190 node.get_items(:Rule).each do |rule|191 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild.new(rule: rule))192 end193 description = get_description(header)194 language = feature_line.matched_gherkin_dialect195 Cucumber::Messages::GherkinDocument::Feature.new(196 tags: tags,197 location: get_location(feature_line, 0),198 language: language,199 keyword: feature_line.matched_keyword,200 name: feature_line.matched_text,201 description: description,202 children: children,203 )204 when :Rule205 header = node.get_single(:RuleHeader)206 return unless header207 rule_line = header.get_token(:RuleLine)208 return unless rule_line209 children = []210 background = node.get_single(:Background)211 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild::RuleChild.new(background: background)) if background212 node.get_items(:ScenarioDefinition).each do |scenario|213 children.push(Cucumber::Messages::GherkinDocument::Feature::FeatureChild::RuleChild.new(scenario: scenario))214 end215 description = get_description(header)216 Cucumber::Messages::GherkinDocument::Feature::FeatureChild::Rule.new(217 location: get_location(rule_line, 0),218 keyword: rule_line.matched_keyword,219 name: rule_line.matched_text,220 description: description,221 children: children,222 )223 when :GherkinDocument224 feature = node.get_single(:Feature)225 {226 feature: feature,227 comments: @comments228 }229 else...

Full Screen

Full Screen

get_description

Using AI Code Generation

copy

Full Screen

1gherkin = Gherkin.new(feature_file)2 def initialize(file_path)3 file = File.open(@file_path)4 return line.split('Feature:')[1].strip

Full Screen

Full Screen

get_description

Using AI Code Generation

copy

Full Screen

1puts gherkin.get_description('gherkin.txt')2puts gherkin.get_description('gherkin2.txt')3puts gherkin.get_description('gherkin3.txt')4puts gherkin.get_description('gherkin4.txt')5puts gherkin.get_description('gherkin5.txt')6puts gherkin.get_description('gherkin6.txt')7puts gherkin.get_description('gherkin7.txt')8puts gherkin.get_description('gherkin8.txt')9puts gherkin.get_description('gherkin9.txt')10puts gherkin.get_description('gherkin10.txt')11puts gherkin.get_description('gherkin11.txt')12puts gherkin.get_description('gherkin12.txt')13puts gherkin.get_description('gherkin13.txt')14puts gherkin.get_description('gherkin14.txt')15puts gherkin.get_description('gherkin15.txt')16puts gherkin.get_description('gherkin16.txt')17puts gherkin.get_description('gherkin17.txt')18puts gherkin.get_description('gherkin18.txt')19puts gherkin.get_description('gherkin19.txt')20puts gherkin.get_description('gherkin20

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