Best Gherkin-ruby code snippet using Gherkin.current_node
ast_builder.rb
Source:ast_builder.rb
...15 @stack.push AstNode.new(rule_type)16 end17 def end_rule(rule_type)18 node = @stack.pop19 current_node.add(node.rule_type, transform_node(node))20 end21 def build(token)22 if token.matched_type == :Comment23 @comments.push(Cucumber::Messages::GherkinDocument::Comment.new(24 location: get_location(token, 0),25 text: token.matched_text26 ))27 else28 current_node.add(token.matched_type, token)29 end30 end31 def get_result32 current_node.get_single(:GherkinDocument)33 end34 def current_node35 @stack.last36 end37 def get_location(token, column)38 column = column == 0 ? token.location[:column] : column39 Cucumber::Messages::Location.new(40 line: token.location[:line],41 column: column42 )43 end44 def get_tags(node)45 tags = []46 tags_node = node.get_single(:Tags)47 return tags unless tags_node48 tags_node.get_tokens(:TagLine).each do |token|...
steps_parser.rb
Source:steps_parser.rb
...19 )20 parser = ::Gherkin::Parser.new(ast_builder)21 parser.start_rule(context, :ScenarioDefinition)22 parser.start_rule(context, :Scenario)23 scenario = ast_builder.current_node24 state = 1225 token = nil26 begin27 token = parser.read_token(context)28 state = parser.match_token(state, token, context)29 end until(token.eof?)30 raise CompositeParserException.new(context.errors) if context.errors.any?31 @builder.steps(ast_builder.get_steps(scenario))32 end33 end34 end35end...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!