How to use for method of Gherkin Package

Best Gherkin-ruby code snippet using Gherkin.for

gherkin-2.4.0-java.gemspec

Source:gherkin-2.4.0-java.gemspec Github

copy

Full Screen

23Gem::Specification.new do |s|4 s.name = %q{gherkin}5 s.version = "2.4.0"6 s.platform = %q{java}78 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=9 s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]10 s.date = %q{2011-06-04}11 s.default_executable = %q{gherkin}12 s.description = %q{A fast Gherkin lexer/parser for based on the Ragel State Machine Compiler.}13 s.email = %q{cukes@googlegroups.com}14 s.files = [".gitattributes", ".gitignore", ".gitmodules", ".mailmap", ".rspec", ".rvmrc", ".yardopts", "Gemfile", "History.md", "LICENSE", "README.md", "Rakefile", "build_native_gems.sh", "cucumber.yml", "features/escaped_pipes.feature", "features/feature_parser.feature", "features/json_formatter.feature", "features/json_parser.feature", "features/native_lexer.feature", "features/parser_with_native_lexer.feature", "features/pretty_formatter.feature", "features/step_definitions/eyeball_steps.rb", "features/step_definitions/gherkin_steps.rb", "features/step_definitions/json_formatter_steps.rb", "features/step_definitions/json_parser_steps.rb", "features/step_definitions/pretty_formatter_steps.rb", "features/steps_parser.feature", "features/support/env.rb", "gherkin.gemspec", "ikvm/.gitignore", "java/.gitignore", "java/src/main/java/gherkin/lexer/i18n/.gitignore", "java/src/main/resources/gherkin/.gitignore", "js/.gitignore", "js/.npmignore", "js/lib/gherkin/lexer/.gitignore", "js/lib/gherkin/lexer/.npmignore", "lib/.gitignore", "lib/gherkin.rb", "lib/gherkin/c_lexer.rb", "lib/gherkin/formatter/ansi_escapes.rb", "lib/gherkin/formatter/argument.rb", "lib/gherkin/formatter/escaping.rb", "lib/gherkin/formatter/filter_formatter.rb", "lib/gherkin/formatter/hashable.rb", "lib/gherkin/formatter/json_formatter.rb", "lib/gherkin/formatter/line_filter.rb", "lib/gherkin/formatter/model.rb", "lib/gherkin/formatter/pretty_formatter.rb", "lib/gherkin/formatter/regexp_filter.rb", "lib/gherkin/formatter/step_printer.rb", "lib/gherkin/formatter/tag_count_formatter.rb", "lib/gherkin/formatter/tag_filter.rb", "lib/gherkin/i18n.rb", "lib/gherkin/i18n.yml", "lib/gherkin/js_lexer.rb", "lib/gherkin/json_parser.rb", "lib/gherkin/lexer/i18n_lexer.rb", "lib/gherkin/listener/event.rb", "lib/gherkin/listener/formatter_listener.rb", "lib/gherkin/native.rb", "lib/gherkin/native/ikvm.rb", "lib/gherkin/native/java.rb", "lib/gherkin/native/null.rb", "lib/gherkin/parser/meta.txt", "lib/gherkin/parser/parser.rb", "lib/gherkin/parser/root.txt", "lib/gherkin/parser/steps.txt", "lib/gherkin/rb_lexer.rb", "lib/gherkin/rb_lexer/.gitignore", "lib/gherkin/rb_lexer/README.rdoc", "lib/gherkin/rubify.rb", "lib/gherkin/tag_expression.rb", "ragel/i18n/.gitignore", "ragel/lexer.c.rl.erb", "ragel/lexer.java.rl.erb", "ragel/lexer.js.rl.erb", "ragel/lexer.rb.rl.erb", "ragel/lexer_common.rl.erb", "spec/gherkin/c_lexer_spec.rb", "spec/gherkin/fixtures/1.feature", "spec/gherkin/fixtures/comments_in_table.feature", "spec/gherkin/fixtures/complex.feature", "spec/gherkin/fixtures/complex.json", "spec/gherkin/fixtures/complex_for_filtering.feature", "spec/gherkin/fixtures/complex_with_tags.feature", "spec/gherkin/fixtures/dos_line_endings.feature", "spec/gherkin/fixtures/hantu_pisang.feature", "spec/gherkin/fixtures/i18n_fr.feature", "spec/gherkin/fixtures/i18n_no.feature", "spec/gherkin/fixtures/i18n_zh-CN.feature", "spec/gherkin/fixtures/scenario_outline_with_tags.feature", "spec/gherkin/fixtures/scenario_without_steps.feature", "spec/gherkin/fixtures/simple_with_comments.feature", "spec/gherkin/fixtures/simple_with_tags.feature", "spec/gherkin/fixtures/with_bom.feature", "spec/gherkin/formatter/ansi_escapes_spec.rb", "spec/gherkin/formatter/filter_formatter_spec.rb", "spec/gherkin/formatter/model_spec.rb", "spec/gherkin/formatter/pretty_formatter_spec.rb", "spec/gherkin/formatter/spaces.feature", "spec/gherkin/formatter/step_printer_spec.rb", "spec/gherkin/formatter/tabs.feature", "spec/gherkin/formatter/tag_count_formatter_spec.rb", "spec/gherkin/i18n_spec.rb", "spec/gherkin/java_lexer_spec.rb", "spec/gherkin/java_libs.rb", "spec/gherkin/js_lexer_spec.rb", "spec/gherkin/json_parser_spec.rb", "spec/gherkin/lexer/i18n_lexer_spec.rb", "spec/gherkin/output_stream_string_io.rb", "spec/gherkin/parser/parser_spec.rb", "spec/gherkin/rb_lexer_spec.rb", "spec/gherkin/sexp_recorder.rb", "spec/gherkin/shared/bom_group.rb", "spec/gherkin/shared/doc_string_group.rb", "spec/gherkin/shared/lexer_group.rb", "spec/gherkin/shared/row_group.rb", "spec/gherkin/shared/tags_group.rb", "spec/gherkin/tag_expression_spec.rb", "spec/spec_helper.rb", "tasks/bench.rake", "tasks/bench/feature_builder.rb", "tasks/bench/generated/.gitignore", "tasks/bench/null_listener.rb", "tasks/compile.rake", "tasks/cucumber.rake", "tasks/gems.rake", "tasks/ikvm.rake", "tasks/ragel_task.rb", "tasks/release.rake", "tasks/rspec.rake", "tasks/yard.rake", "tasks/yard/default/layout/html/bubble_32x32.png", "tasks/yard/default/layout/html/bubble_48x48.png", "tasks/yard/default/layout/html/footer.erb", "tasks/yard/default/layout/html/index.erb", "tasks/yard/default/layout/html/layout.erb", "tasks/yard/default/layout/html/logo.erb", "tasks/yard/default/layout/html/setup.rb", "lib/gherkin.jar"]15 s.homepage = %q{http://github.com/cucumber/gherkin}16 s.rdoc_options = ["--charset=UTF-8"]17 s.require_paths = ["lib"]18 s.rubygems_version = %q{1.5.1}19 s.summary = %q{gherkin-2.4.0}20 s.test_files = ["features/escaped_pipes.feature", "features/feature_parser.feature", "features/json_formatter.feature", "features/json_parser.feature", "features/native_lexer.feature", "features/parser_with_native_lexer.feature", "features/pretty_formatter.feature", "features/step_definitions/eyeball_steps.rb", "features/step_definitions/gherkin_steps.rb", "features/step_definitions/json_formatter_steps.rb", "features/step_definitions/json_parser_steps.rb", "features/step_definitions/pretty_formatter_steps.rb", "features/steps_parser.feature", "features/support/env.rb", "spec/gherkin/c_lexer_spec.rb", "spec/gherkin/fixtures/1.feature", "spec/gherkin/fixtures/comments_in_table.feature", "spec/gherkin/fixtures/complex.feature", "spec/gherkin/fixtures/complex.json", "spec/gherkin/fixtures/complex_for_filtering.feature", "spec/gherkin/fixtures/complex_with_tags.feature", "spec/gherkin/fixtures/dos_line_endings.feature", "spec/gherkin/fixtures/hantu_pisang.feature", "spec/gherkin/fixtures/i18n_fr.feature", "spec/gherkin/fixtures/i18n_no.feature", "spec/gherkin/fixtures/i18n_zh-CN.feature", "spec/gherkin/fixtures/scenario_outline_with_tags.feature", "spec/gherkin/fixtures/scenario_without_steps.feature", "spec/gherkin/fixtures/simple_with_comments.feature", "spec/gherkin/fixtures/simple_with_tags.feature", "spec/gherkin/fixtures/with_bom.feature", "spec/gherkin/formatter/ansi_escapes_spec.rb", "spec/gherkin/formatter/filter_formatter_spec.rb", "spec/gherkin/formatter/model_spec.rb", "spec/gherkin/formatter/pretty_formatter_spec.rb", "spec/gherkin/formatter/spaces.feature", "spec/gherkin/formatter/step_printer_spec.rb", "spec/gherkin/formatter/tabs.feature", "spec/gherkin/formatter/tag_count_formatter_spec.rb", "spec/gherkin/i18n_spec.rb", "spec/gherkin/java_lexer_spec.rb", "spec/gherkin/java_libs.rb", "spec/gherkin/js_lexer_spec.rb", "spec/gherkin/json_parser_spec.rb", "spec/gherkin/lexer/i18n_lexer_spec.rb", "spec/gherkin/output_stream_string_io.rb", "spec/gherkin/parser/parser_spec.rb", "spec/gherkin/rb_lexer_spec.rb", "spec/gherkin/sexp_recorder.rb", "spec/gherkin/shared/bom_group.rb", "spec/gherkin/shared/doc_string_group.rb", "spec/gherkin/shared/lexer_group.rb", "spec/gherkin/shared/row_group.rb", "spec/gherkin/shared/tags_group.rb", "spec/gherkin/tag_expression_spec.rb", "spec/spec_helper.rb"]2122 if s.respond_to? :specification_version then23 s.specification_version = 32425 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then26 s.add_runtime_dependency(%q<json>, [">= 1.4.6"])27 s.add_development_dependency(%q<cucumber>, [">= 0.10.3"])28 s.add_development_dependency(%q<rake>, ["= 0.8.7"])29 s.add_development_dependency(%q<bundler>, [">= 1.0.14"])30 s.add_development_dependency(%q<rspec>, [">= 2.6.0"])31 s.add_development_dependency(%q<awesome_print>, [">= 0.4.0"])32 s.add_development_dependency(%q<therubyracer>, [">= 0.9.0.beta7"])33 s.add_development_dependency(%q<yard>, ["= 0.7.1"])34 s.add_development_dependency(%q<rdiscount>, ["= 1.6.8"]) ...

Full Screen

Full Screen

json_expanded_formatter.rb

Source:json_expanded_formatter.rb Github

copy

Full Screen

...18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN20# THE SOFTWARE.21 22require 'cucumber/formatter/gherkin_formatter_adapter'23require 'cucumber/formatter/io'24require 'gherkin/formatter/json_formatter'25 26module Cucumber27 module Formatter28 ##29 # This is similar to the built-in Cucumber JSON formatter except it expands30 # scenario outlines so each row is reported with its result. Thus, scenario31 # outlines appear similar to regular scenarios in the JSON output.32 #33 # This supports regular mode and "--expand" mode. In both cases, scenario34 # outline tables are expanded (however the underlying logic for doing the35 # expansion varies greatly).36 #37 # This produces scenario outline JSON that38 # [cucumber-reporting](https://github.com/masterthought/cucumber-reporting)39 # can consume.40 #41 # The expansion is quite a hack and may not be supported in all versions of42 # Cucumber. Please monitor the following bug for a proper solution to scenario43 # outlines in JSON:44 # https://github.com/cucumber/gherkin/issues/16545 #46 # Notes:47 # * When not in "--expand" mode, duration can't be calculated per step.48 # The duration for the entire feature is appended to the last step.49 # * Scenario Outlines are still called "Scenario Outlines" even though50 # they look more like regular Scenarios in the output.51 # * Argument matches are empty.52 class JsonExpanded < GherkinFormatterAdapter53 include Io54 55 def initialize(runtime, io, options)56 @io = ensure_io(io, "json")57 if Gem.loaded_specs['cucumber'].version >= Gem::Version.new('1.3.17')58 super(Gherkin::Formatter::JSONFormatter.new(@io), false, options)59 else60 super(Gherkin::Formatter::JSONFormatter.new(@io), false)61 end62 end63 64 def before_feature_element(feature_element)65 @outline_table = nil66 if feature_element.is_a?(Ast::ScenarioOutline)67 @outline = true68 @feature_element = feature_element69 else70 super71 end72 end73 74 def before_step(step)75 if @outline_table76 table_row = @outline_table.example_rows[@outline_table_row]77 outline_before_step(step, table_row)78 elsif !@outline79 super80 end81 end82 83 def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)84 if @outline_table85 outline_before_step_result(status, exception)86 elsif !@outline87 super88 end89 end90 91 def before_examples(examples)92 unless @outline93 super94 end95 end96 97 def after_step(*args)98 if !@outline || @outline_table99 super100 end101 end102 103 def before_outline_table(outline_table)104 @outline_table = outline_table105 @outline_table_row = -1106 end107 108 def after_outline_table(outline_table)109 @outline_table = nil110 end111 112 def scenario_name(*args)113 if @outline_table114 # Scenario Name is the only way we know we are moving115 # to a new table row in "--expand" mode.116 @outline_table_row += 1117 outline_before_table_row(@feature_element)118 end119 end120 121 def before_table_row(table_row)122 @table_row_time = Time.now123 end124 125 ##126 # Output a Scenario Outline element for each table row. In JSON127 # this appears more like a scenario than a scenario outline.128 # This is only called when not in "--expand" mode.129 def after_table_row(table_row)130 # XXX: Hack to get step collection131 step_invocations = table_row.instance_variable_get('@step_invocations')132 133 if step_invocations134 # Add a new "scenario" for this row135 outline_before_table_row(@feature_element)136 137 step_invocations.each do |step|138 outline_before_step(step, table_row)139 outline_before_step_result(step.status, step.exception)140 end141 142 # We don't have enough hooks to get duration for each step, so143 # just report the total duration at the end of the execution144 step_finish = (Time.now - @table_row_time)145 @gf.append_duration(step_finish)146 end147 end148 149 private150 151 def outline_before_step(step, table_row)152 @gf.step(step_from_table(step, table_row))153 154 # TODO: We don't actually populate the match.arguments array.155 # Should we try to emulate a step_match?156 # We don't want to use outline_args as we've replaced the157 # placeholders with actual values.158 match = Gherkin::Formatter::Model::Match.new([], nil)159 @gf.match(match)160 161 @step_time = Time.now162 end163 164 def outline_before_step_result(status, exception)165 error_message = exception ? "#{exception.message} (#{exception.class})\n#{exception.backtrace.join("\n")}" : nil166 @gf.result(Gherkin::Formatter::Model::Result.new(status, nil, error_message))167 end168 169 def outline_before_table_row(feature_element)170 @gf.scenario_outline(feature_element.gherkin_statement)171 end172 173 # Replaces table cells in the name of the given step.174 #175 # @return Gherkin::Formatter::Model::Step with176 def step_from_table(step, table_row)177 # XXX: Hack to change the name from:178 # "Given two numbers <number_1> and <number_2>"179 # to:180 # "Given two number 1 and 2"181 # We actually instantiate a separate Gherkin::Formatter::Model::Step182 # to avoid corrupting the original step.183 name = step.gherkin_statement.name.dup...

Full Screen

Full Screen

i18n.rb

Source:i18n.rb Github

copy

Full Screen

...9 KEYWORD_KEYS = FEATURE_ELEMENT_KEYS + STEP_KEYWORD_KEYS10 LANGUAGES = YAML.load_file(File.dirname(__FILE__) + '/i18n.yml')11 class << self12 include Rubify13 # Used by code generators for other lexer tools like pygments lexer and textmate bundle14 def all15 LANGUAGES.keys.sort.map{|iso_code| get(iso_code)}16 end17 def get(iso_code)18 languages[iso_code] ||= new(iso_code)19 end20 # Returns all keyword translations and aliases of +keywords+, escaped and joined with <tt>|</tt>.21 # This method is convenient for editor support and syntax highlighting engines for Gherkin, where22 # there is typically a code generation tool to generate regular expressions for recognising the23 # various I18n translations of Gherkin's keywords.24 #25 # The +keywords+ arguments can be one of <tt>:feature</tt>, <tt>:background</tt>, <tt>:scenario</tt>, 26 # <tt>:scenario_outline</tt>, <tt>:examples</tt>, <tt>:step</tt>.27 def keyword_regexp(*keywords)28 unique_keywords = all.map do |i18n|29 keywords.map do |keyword|30 if keyword.to_s == 'step'31 i18n.step_keywords.to_a32 else33 i18n.keywords(keyword).to_a34 end35 end36 end37 38 unique_keywords.flatten.compact.map{|kw| kw.to_s}.sort.reverse.uniq.join('|').gsub(/\*/, '\*')39 end40 def code_keywords41 rubify(all.map{|i18n| i18n.code_keywords}).flatten.uniq.sort42 end43 def code_keyword_for(gherkin_keyword)44 gherkin_keyword.gsub(/[\s',!]/, '').strip45 end46 def language_table47 require 'stringio'48 require 'gherkin/formatter/pretty_formatter'49 require 'gherkin/formatter/model'50 io = StringIO.new51 pf = Gherkin::Formatter::PrettyFormatter.new(io, false, false)52 table = all.map do |i18n|53 Formatter::Model::Row.new([], [i18n.iso_code, i18n.keywords('name')[0], i18n.keywords('native')[0]], nil)54 end55 pf.table(table)56 io.string57 end58 def unicode_escape(word, prefix="\\u")59 word = word.unpack("U*").map do |c|60 if c > 127 || c == 3261 "#{prefix}%04x" % c62 else63 c.chr64 end65 end.join66 end67 private68 def languages69 @languages ||= {}70 end71 end72 attr_reader :iso_code73 def initialize(iso_code)74 @iso_code = iso_code75 @keywords = LANGUAGES[iso_code]76 raise "Language not supported: #{iso_code.inspect}" if @iso_code.nil?77 @keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')78 end79 def lexer(listener, force_ruby=false)80 begin81 if force_ruby82 rb(listener)83 else84 begin85 c(listener)86 rescue NameError, LoadError => e87 warn("WARNING: #{e.message}. Reverting to Ruby lexer.")88 rb(listener)89 end90 end91 rescue LoadError => e92 raise I18nLexerNotFound, "No lexer was found for #{i18n_language_name} (#{e.message}). Supported languages are listed in gherkin/i18n.yml."93 end94 end95 def c(listener)96 require 'gherkin/c_lexer'97 CLexer[underscored_iso_code].new(listener)98 end99 def rb(listener)100 require 'gherkin/rb_lexer'101 RbLexer[underscored_iso_code].new(listener)102 end103 def js(listener)104 require 'gherkin/js_lexer'105 JsLexer[underscored_iso_code].new(listener)106 end107 def underscored_iso_code108 @iso_code.gsub(/[\s-]/, '_').downcase109 end110 # Keywords that can be used in Gherkin source111 def step_keywords112 STEP_KEYWORD_KEYS.map{|iso_code| keywords(iso_code)}.flatten.uniq113 end114 # Keywords that can be used in code115 def code_keywords116 result = step_keywords.map{|keyword| self.class.code_keyword_for(keyword)}117 result.delete('*')118 result119 end120 def keywords(key)121 key = key.to_s122 raise "No #{key.inspect} in #{@keywords.inspect}" if @keywords[key].nil?123 @keywords[key].split('|').map{|keyword| real_keyword(key, keyword)}124 end125 def keyword_table126 require 'stringio'127 require 'gherkin/formatter/pretty_formatter'128 require 'gherkin/formatter/model'129 io = StringIO.new130 pf = Gherkin::Formatter::PrettyFormatter.new(io, false, false)131 gherkin_keyword_table = KEYWORD_KEYS.map do |key|132 Formatter::Model::Row.new([], [key, keywords(key).map{|keyword| %{"#{keyword}"}}.join(', ')], nil)133 end134 135 code_keyword_table = STEP_KEYWORD_KEYS.map do |key|136 code_keywords = keywords(key).reject{|keyword| keyword == '* '}.map do |keyword|137 %{"#{self.class.code_keyword_for(keyword)}"}138 end.join(', ')139 Formatter::Model::Row.new([], ["#{key} (code)", code_keywords], nil)140 end141 142 pf.table(gherkin_keyword_table + code_keyword_table)143 io.string144 end145 private146 def real_keyword(key, keyword)147 if(STEP_KEYWORD_KEYS.index(key))148 (keyword + ' ').sub(/< $/, '')149 else150 keyword151 end...

Full Screen

Full Screen

parser_spec.rb

Source:parser_spec.rb Github

copy

Full Screen

...10 let(:event_bus) { double }11 let(:gherkin_query) { double }12 let(:parser) { Parser.new(receiver, event_bus, gherkin_query) }13 let(:visitor) { double }14 before do15 allow( event_bus ).to receive(:gherkin_source_parsed)16 allow( event_bus).to receive(:envelope)17 allow( gherkin_query ).to receive(:update)18 end19 def parse20 parser.document(source)21 end22 context "for invalid gherkin" do23 let(:source) { Gherkin::Document.new(path, "\nnot gherkin\n\nFeature: \n") }24 let(:path) { 'path_to/the.feature' }25 it "raises an error" do26 expect { parse }.to raise_error(ParseError) do |error|27 expect( error.message ).to match(/not gherkin/)28 expect( error.message ).to match(/#{path}/)29 end30 end31 end32 context "for valid gherkin" do33 let(:source) { Gherkin::Document.new(path, 'Feature:') }34 let(:path) { 'path_to/the.feature' }35 it "issues a gherkin_source_parsed event" do36 expect( event_bus ).to receive(:gherkin_source_parsed)37 parse38 end39 it "emits an 'envelope' event for every message produced by Gherkin" do40 # Only one message emited, there's no pickles generated41 expect( event_bus ).to receive(:envelope).once42 parse43 end44 end45 context "for empty files" do46 let(:source) { Gherkin::Document.new(path, '') }47 let(:path) { 'path_to/the.feature' }48 it "passes on no pickles" do49 expect( receiver ).not_to receive(:pickle)50 parse51 end52 end53 include Writer54 def self.source(&block)55 let(:source) { gherkin(&block) }56 end57 RSpec::Matchers.define :pickle_with_language do |language|58 match { |actual| actual.language == language }59 end60 context "when the Gherkin has a language header" do61 source do62 feature(language: 'ja', keyword: '機能') do63 scenario(keyword: 'シナリオ')64 end65 end66 it "the pickles have the correct language" do67 expect( receiver ).to receive(:pickle).with(pickle_with_language('ja'))68 parse69 end70 end71 context "when the Gherkin produces one pickle" do72 source do73 feature do74 scenario do75 step 'text'76 end77 end78 end79 it "passes on the pickle" do80 expect( receiver ).to receive(:pickle)81 parse82 end83 it "emits an 'envelope' event containing the pickle" do84 allow( receiver ).to receive(:pickle)85 # Once for the gherkin document, once with the pickle86 expect( event_bus ).to receive(:envelope).twice87 parse88 end89 end90 context "when scenario is inside a rule" do91 source do92 feature do93 rule do94 scenario name: "My scenario"95 end96 end97 end98 it "passes on the pickle" do99 expect( receiver ).to receive(:pickle)...

Full Screen

Full Screen

ikvm.rake

Source:ikvm.rake Github

copy

Full Screen

...14 def mono(args)15 if(`which mono`.strip =~ /mono/)16 sh("mono #{args}")17 else18 raise "[ERROR] You must install Mono and IKVM build gherkin for .NET. See README.md"19 end20 end21 def ikvmc(args)22 begin23 mono("#{IKVMC_EXE} #{args}")24 rescue => e25 if e.message =~ /Cannot open assembly/26 e.message << "\n\n[ERROR] You must install Mono and IKVM build gherkin for .NET. See README.rdoc"27 end28 raise e29 end30 end31 def nuget(args)32 mono("/usr/local/nuget/NuGet.exe #{args}")33 end34 file GHERKIN_EXE => [IKVMC_EXE, 'lib/gherkin.jar'] do35 ikvmc("-target:exe lib/gherkin.jar -out:#{GHERKIN_EXE}")36 end37 file GHERKIN_PKG_DLL => [IKVMC_EXE, 'lib/gherkin.jar'] do38 mkdir_p File.dirname(GHERKIN_PKG_DLL) unless File.directory?(File.dirname(GHERKIN_PKG_DLL))39 ikvmc("-target:library lib/gherkin.jar -out:#{GHERKIN_PKG_DLL} -version:#{GHERKIN_VERSION}")40 end41 file GHERKIN_LIB_DLL => GHERKIN_PKG_DLL do42 cp GHERKIN_PKG_DLL, GHERKIN_LIB_DLL43 end44 file GHERKIN_NUPKG => [GHERKIN_PKG_DLL, GHERKIN_NUSPEC] do45 pkg_dir = File.dirname(GHERKIN_EXE)46 mkdir_p File.dirname(pkg_dir) unless File.directory?(pkg_dir)47 nuget("Pack #{GHERKIN_NUSPEC} -Version #{GHERKIN_VERSION} -OutputDirectory #{pkg_dir}")48 # Now, fix the path inside the file - see https://github.com/cucumber/gherkin/issues/14849 require 'zip/zipfilesystem'50 Zip::ZipFile.open(GHERKIN_NUPKG) do |zipfile|51 begin52 zipfile.file.rename 'lib%2Fgherkin.dll', 'lib/gherkin.dll' 53 rescue => looks_like_nuget_has_been_fixed54 end55 end56 end57 file GHERKIN_NUSPEC do58 mkdir_p File.dirname(GHERKIN_NUSPEC) unless File.directory?(File.dirname(GHERKIN_NUSPEC))59 File.open(GHERKIN_NUSPEC, "w") do |io|60 io.write(<<-EOF)61<?xml version="1.0"?>62<package>63 <metadata>64 <id>gherkin</id>65 <version>#{GHERKIN_VERSION}</version>66 <authors>aslakhellesoy</authors>67 <owners>Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy</owners>68 <projectUrl>https://github.com/cucumber/gherkin</projectUrl>69 <licenseUrl>https://github.com/cucumber/gherkin/blob/master/LICENSE</licenseUrl>70 <iconUrl>https://github.com/cucumber/cukes.info/raw/master/templates/images/gherkin/gherkin_128x128.png</iconUrl>71 <requireLicenseAcceptance>false</requireLicenseAcceptance>72 <description>A fast lexer and parser for the Gherkin language based on Ragel</description>73 <copyright>Copyright (c) 2009-2011 Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy</copyright>74 <dependencies>75 <dependency id="IKVM" version="#{IKVM_VERSION}" />76 </dependencies>77 <tags>gherkin cucumber specflow bdd lexer parser</tags>78 </metadata>79</package>80EOF81 end82 end83 task :nupkg => GHERKIN_NUPKG84 task :check => [GHERKIN_EXE, :copy_ikvm_dlls] do85 puts "************** Pretty printing some features with .NET. **************"86 mono "#{GHERKIN_EXE} features"87 puts "************** DONE Pretty printing some features with .NET. All OK. **************"88 end89 task :copy_ikvm_dlls => IKVMC_EXE do90 exe_dir = File.dirname(GHERKIN_EXE)91 mkdir_p File.dirname(exe_dir) unless File.directory?(exe_dir)92 Dir["#{IKVM_BIN_DIR}/*.dll"].each do |dll|93 cp dll, exe_dir94 end95 end96 task :push => GHERKIN_NUPKG do97 nuget("Push #{GHERKIN_NUPKG}")98 nuget("Publish gherkin #{GHERKIN_VERSION}")99 end100 file IKVMC_EXE do101 sh("wget http://downloads.sourceforge.net/project/ikvm/ikvm/#{IKVM_VERSION}/ikvmbin-#{IKVM_VERSION}.zip -O #{IKVM_ZIP}")102 Dir.chdir('ikvm') do103 sh("unzip ikvmbin-#{IKVM_VERSION}.zip")104 end105 end106end107task :ikvm => ['ikvm:check']...

Full Screen

Full Screen

token_scanner.rb

Source:token_scanner.rb Github

copy

Full Screen

2require 'gherkin/token'3require 'gherkin/gherkin_line'4module Gherkin5 # The scanner reads a gherkin doc (typically read from a .feature file) and6 # creates a token for line. The tokens are passed to the parser, which outputs7 # an AST (Abstract Syntax Tree).8 #9 # If the scanner sees a # language header, it will reconfigure itself dynamically10 # to look for Gherkin keywords for the associated language. The keywords are defined11 # in gherkin-languages.json.12 class TokenScanner13 def initialize(source_or_io)14 @line_number = 015 case(source_or_io)16 when String17 @io = StringIO.new(source_or_io)18 when StringIO, IO19 @io = source_or_io20 else21 fail ArgumentError, "Please a pass String, StringIO or IO. I got a #{source_or_io.class}"22 end23 end24 def read...

Full Screen

Full Screen

steps_parser.rb

Source:steps_parser.rb Github

copy

Full Screen

...10 @builder = builder11 @language = language12 end13 def parse(text)14 dialect = ::Gherkin::Dialect.for(@language)15 token_matcher = ::Gherkin::TokenMatcher.new(@language)16 token_scanner = ::Gherkin::TokenScanner.new(feature_header(dialect) + text)17 parser = ::Gherkin::Parser.new18 gherkin_document = parser.parse(token_scanner, token_matcher)19 @builder.steps(gherkin_document[:feature][:children][0][:steps])20 end21 def feature_header(dialect)22 %(#{dialect.feature_keywords[0]}:23 #{dialect.scenario_keywords[0]}:24 )25 end26 end27 end28end...

Full Screen

Full Screen

data_table_parser.rb

Source:data_table_parser.rb Github

copy

Full Screen

...16 @builder.row(row[:cells].map { |cell| cell[:value] })17 end18 end19 def feature_header20 dialect = ::Gherkin::Dialect.for('en')21 %(#{dialect.feature_keywords[0]}:22 #{dialect.scenario_keywords[0]}:23 #{dialect.given_keywords[0]} x24 )25 end26 end27 end28end

Full Screen

Full Screen

for

Using AI Code Generation

copy

Full Screen

1 def Gherkin.parse(file)2 def Gherkin.parse(file)3 def Gherkin.parse(file)4 def Gherkin.parse(file)5 def Gherkin.parse(file)6 def Gherkin.parse(file)7 def Gherkin.parse(file)8 def Gherkin.parse(file)9 def Gherkin.parse(file)10 def Gherkin.parse(file)11 def Gherkin.parse(file)

Full Screen

Full Screen

for

Using AI Code Generation

copy

Full Screen

1Given(/^I have a Gherkin class$/) do2When(/^I call the method "([^"]*)"$/) do |method|3 @result = @gherkin.send(method)4Then(/^I should get "([^"]*)"$/) do |result|5 expect(@result).to eq(result)6Given(/^I have a Gherkin class$/) do7When(/^I call the method "([^"]*)" with the argument "([^"]*)"$/) do |method, argument|8 @result = @gherkin.send(method, argument)9Then(/^I should get "([^"]*)"$/) do |result|10 expect(@result).to eq(result)11Given(/^I have a Gherkin class$/) do12When(/^I call the method "([^"]*)" with the arguments "([^"]*)" and "([^"]*)"$/) do |method, argument1, argument2|13 @result = @gherkin.send(method, argument1, argument2)14Then(/^I should get "([^"]*)"$/) do |result|15 expect(@result).to eq(result)16Given(/^I have a Gherkin class$/) do17When(/^I call the method "([^"]*)" with the arguments "([^"]*)" and "([^"]*)"$/) do |method, argument1, argument2|18 @result = @gherkin.send(method, argument1, argument2)19Then(/^I should get "([^"]*)"$/) do |result|20 expect(@result).to eq(result)

Full Screen

Full Screen

for

Using AI Code Generation

copy

Full Screen

1Given(/^I have a Gherkin class$/) do2When(/^I call the method "([^"]*)"$/) do |method|3 @result = @gherkin.send(method)4Then(/^I should get "([^"]*)"$/) do |result|5 expect(@result).to eq(result)6Given(/^I have a Gherkin class$/) do7When(/^I call the method "([^"]*)" with the argument "([^"]*)"$/) do |method, argument|8 @result = @gherkin.send(method, argument)9Then(/^I should get "([^"]*)"$/) do |result|10 expect(@result).to eq(result)11Given(/^I have a Gherkin class$/) do12When(/^I call the method "([^"]*)" with the arguments "([^"]*)" and "([^"]*)"$/) do |method, argument1, argument2|13 @result = @gherkin.send(method, argument1, argument2)14Then(/^I should get "([^"]*)"$/) do |result|15 expect(@result).to eq(result)16Given(/^I have a Gherkin class$/) do17When(/^I call the method "([^"]*)" with the arguments "([^"]*)" and "([^"]*)"$/) do |method, argument1, argument2|18 @result = @gherkin.send(method, argument1, argument2)19Then(/^I should get "([^"]*)"$/) do |result|20 expect(@result).to eq(result)

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