How to use initialize method of Gherkin.Pickles Package

Best Gherkin-ruby code snippet using Gherkin.Pickles.initialize

find_step.rb

Source:find_step.rb Github

copy

Full Screen

...8require 'gherkin/pickles/compiler'9#require 'gherkin'10#require 'gherkin/formatter/json_formatter'11class StepExtractor #< Gherkin::Formatter::JSONFormatter12 # def initialize13 # super(StringIO.new)14 # end15 # returns a Hash describing step at the line or nil if nothing16 # executable found17 def step_at(line)18 @feature_hashes[0]['elements'].each do |element|19 element['steps'].each do |step|20 if step['line'] == line21 if element['examples']22 rows = element['examples'][0]['rows'].each23 header = rows.next['cells']24 examples = []25 loop do26 row = rows.next['cells']27 example = {}28 row.each_with_index do |val, idx|29 example[header[idx]] = val30 end31 examples.push(example)32 end33 step['examples'] = examples34 end35 return step36 end37 end38 end39 nil40 end41end42class Step43 attr_reader :file, :line, :regexp44 def initialize(regexp, file, line)45 @file, @line = file, line46 self.regexp = regexp47 end48 def regexp=(value)49 @regexp =50 case value51 when String52 pieces, regexp = [], value.dup53 regexp.gsub!(/\$\w+/) { |match| pieces << match; "TOKEN" }54 regexp = Regexp.escape(regexp)55 regexp.gsub!(/TOKEN/) { |match| "(.*)" }56 Regexp.new("^#{regexp}$")57 when Regexp58 value59 else60 STDERR.puts "Warning: invalid parameter to Given/When/Then on #{file}:#{line}. Expected Regexp or String, got #{value.class} #{value.inspect}"61 Regexp.new(/^INVALID PARAM$/)62 end63 end64 def match?(text)65 @regexp.match(text)66 end67end68class StepParser69 attr_accessor :steps, :file70 def initialize(file, keywords)71 @file = file72 @steps = []73 @keywords = keywords74 extract_steps(RubyParser.new.parse(File.read(file)))75 end76 def extract_steps(sexp)77 return unless sexp.is_a?(Sexp)78 case sexp.first79 when :block80 sexp[1..-1].each do |child_sexp|81 extract_steps(child_sexp)82 end83 when :iter84 child_sexp = sexp[1]...

Full Screen

Full Screen

gherkin_events.rb

Source:gherkin_events.rb Github

copy

Full Screen

2require 'gherkin/pickles/compiler'3module Gherkin4 module Stream5 class GherkinEvents6 def initialize(options)7 @options = options8 @parser = Gherkin::Parser.new9 @compiler = Gherkin::Pickles::Compiler.new10 end11 def enum(source_event)12 Enumerator.new do |y|13 uri = source_event['uri']14 source = source_event['data']15 begin16 gherkin_document = @parser.parse(source)17 if (@options[:print_source])18 y.yield source_event19 end20 if (@options[:print_ast])...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful