How to use reset method of Gherkin Package

Best Gherkin-ruby code snippet using Gherkin.reset

pretty_formatter_spec.rb

Source:pretty_formatter_spec.rb Github

copy

Full Screen

...11 describe PrettyFormatter do12 include AnsiEscapes13 def assert_io(s)14 actual = @io.string15 actual.gsub!(/\e\[m/, "\e[0m") # JANSI resets without the 0.16 actual.should == s17 end18 19 def assert_pretty(input, expected_output=input)20 [true, false].each do |force_ruby|21 io = StringIO.new22 pf = Gherkin::Formatter::PrettyFormatter.new(io, true, false)23 parser = Gherkin::Parser::Parser.new(pf, true, "root", force_ruby)24 parser.parse(input, "test.feature", 0)25 output = io.string26 output.should == expected_output27 end28 end29 before do30 @io = StringIO.new31 @f = Gherkin::Formatter::PrettyFormatter.new(@io, false, true)32 end33 it "should print comments when scenario is longer" do34 @f.uri("features/foo.feature")35 @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1, "hello"))36 @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4, "the-scenario"))37 @f.step(Model::Step.new([], "Given ", "some stuff", 5, nil, nil))38 @f.step(Model::Step.new([], "When ", "foo", 6, nil, nil))39 @f.match(Model::Match.new([], "features/step_definitions/bar.rb:56"))40 @f.result(Model::Result.new('passed', 22, nil))41 @f.match(Model::Match.new([], "features/step_definitions/bar.rb:96"))42 @f.result(Model::Result.new('passed', 33, nil))43 assert_io(%{Feature: Hello44 World45 Scenario: The scenario #{comments}# features/foo.feature:4#{reset}46 #{executing}Given #{reset}#{executing}some stuff#{reset} #{comments}# features/step_definitions/bar.rb:56#{reset}47#{up(1)} #{passed}Given #{reset}#{passed}some stuff#{reset} #{comments}# features/step_definitions/bar.rb:56#{reset}48 #{executing}When #{reset}#{executing}foo#{reset} #{comments}# features/step_definitions/bar.rb:96#{reset}49#{up(1)} #{passed}When #{reset}#{passed}foo#{reset} #{comments}# features/step_definitions/bar.rb:96#{reset}50})51 end52 it "should print comments when step is longer" do53 @f.uri("features/foo.feature")54 @f.feature(Model::Feature.new([], [], "Feature", "Hello", "World", 1, "hello"))55 step = Model::Step.new([], "Given ", "some stuff that is longer", 5, nil, nil)56 match = Model::Match.new([], "features/step_definitions/bar.rb:56")57 result = Model::Result.new('passed', 0, nil)58 @f.scenario(Model::Scenario.new([], [], "Scenario", "The scenario", "", 4, "the-scenario"))59 @f.step(step)60 @f.match(match)61 @f.result(result)62 assert_io(%{Feature: Hello63 World64 Scenario: The scenario #{comments}# features/foo.feature:4#{reset}65 #{executing}Given #{reset}#{executing}some stuff that is longer#{reset} #{comments}# features/step_definitions/bar.rb:56#{reset}66#{up(1)} #{passed}Given #{reset}#{passed}some stuff that is longer#{reset} #{comments}# features/step_definitions/bar.rb:56#{reset}67})68 end69 it "should highlight arguments for regular steps" do70 @f.uri("foo.feature")71 @f.scenario(Model::Scenario.new([], [], "Scenario", "Lots of cukes", "", 3, "lots-of-cukes"))72 @f.step(Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3, nil, nil))73 @f.match(Model::Match.new([Gherkin::Formatter::Argument.new(7, '999')], nil))74 @f.result(Model::Result.new('passed', 6, nil))75 assert_io(76 "\n" +77 " Scenario: Lots of cukes \e[90m# foo.feature:3\e[0m\n" +78 " #{executing}Given #{reset}#{executing}I have #{reset}#{executing_arg}999#{reset}#{executing} cukes in my belly#{reset}\n" +79 "#{up(1)} #{passed}Given #{reset}#{passed}I have #{reset}#{passed_arg}999#{reset}#{passed} cukes in my belly#{reset}\n"80 )81 end82 # See https://github.com/cucumber/gherkin/pull/17183 it "should highlight arguments when there are optional arguments" do84 @f.uri("foo.feature")85 @f.scenario(Model::Scenario.new([], [], "Scenario", "Lots of cukes", "", 3, "lots-of-cukes"))86 @f.step(Model::Step.new([], "Given ", "I have 999 cukes in my belly", 3, nil, nil))87 @f.match(Model::Match.new([88 Gherkin::Formatter::Argument.new(nil, nil), # An optional argument89 Gherkin::Formatter::Argument.new(7, '999')90 ], nil))91 @f.result(Model::Result.new('passed', 6, nil))92 assert_io(93 "\n" +94 " Scenario: Lots of cukes \e[90m# foo.feature:3\e[0m\n" +95 " #{executing}Given #{reset}#{executing}I have #{reset}#{executing_arg}999#{reset}#{executing} cukes in my belly#{reset}\n" +96 "#{up(1)} #{passed}Given #{reset}#{passed}I have #{reset}#{passed_arg}999#{reset}#{passed} cukes in my belly#{reset}\n"97 )98 end99 it "should prettify scenario" do100 assert_pretty(%{Feature: Feature Description101 Some preamble102 Scenario: Scenario Description103 description has multiple lines104 Given there is a step105 """106 with107 pystrings108 """109 And there is another step110 | æ | \\|o |...

Full Screen

Full Screen

gherkin.rb

Source:gherkin.rb Github

copy

Full Screen

...43 mixin :has_examples44 end45 state :has_scenarios do46 rule %r((.*?)(:)) do |m|47 reset_stack48 keyword = m[1]49 keyword_tok = if self.class.keywords[:element].include? keyword50 push :description; Keyword::Namespace51 elsif self.class.keywords[:feature].include? keyword52 push :feature_description; Keyword::Declaration53 elsif self.class.keywords[:examples].include? keyword54 push :example_description; Name::Namespace55 else56 Error57 end58 groups keyword_tok, Punctuation59 end60 end61 state :has_examples do62 mixin :has_scenarios63 rule Gherkin.step_regex, Name::Function do64 token Name::Function65 reset_stack; push :step66 end67 end68 state :has_table do69 rule(/(?=[|])/) { push :table_header }70 end71 state :table_header do72 rule /[^|\s]+/, Name::Variable73 rule /\n/ do74 token Text75 goto :table76 end77 mixin :table78 end79 state :table do80 mixin :basic81 rule /\n/, Text, :table_bol82 rule /[|]/, Punctuation83 rule /[^|\s]+/, Name84 end85 state :table_bol do86 rule(/(?=\s*[^\s|])/) { reset_stack }87 rule(//) { pop! }88 end89 state :description do90 mixin :basic91 mixin :has_examples92 rule /\n/, Text93 rule rest_of_line, Text94 end95 state :feature_description do96 mixin :basic97 mixin :has_scenarios98 rule /\n/, Text99 rule rest_of_line, Text100 end...

Full Screen

Full Screen

reset

Using AI Code Generation

copy

Full Screen

1Gherkin::Formatter::PrettyFormatter.run("features")2Gherkin::Formatter::PrettyFormatter.run("features", "pretty")3Gherkin::Formatter::PrettyFormatter.run("features", "pretty", "html")4Gherkin::Formatter::PrettyFormatter.run("features", "pretty", "html", "json")5Gherkin::Formatter::PrettyFormatter.run("features", "pretty", "html", "json", "junit")

Full Screen

Full Screen

reset

Using AI Code Generation

copy

Full Screen

1puts Gherkin.new("Gherkin", "Duckbill").name2puts Gherkin.new("Gherkin", "Duckbill").nme3pus Gerkin.new("Gherkin", "Duckbill").name

Full Screen

Full Screen

reset

Using AI Code Generation

copy

Full Screen

1puts Gherkin.new("Gherkin", "Duckbill").name2puts Gherkin.new("Gherkin", "Duckbill").name3puts Gherkin.new("Gherkin", "Duckbill").name

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