How to use empty method of Gherkin Package

Best Gherkin-ruby code snippet using Gherkin.empty

gherkin_adder_spec.rb

Source:gherkin_adder_spec.rb Github

copy

Full Screen

...35 expect(call.children[:gherkin_text]).to eq("When I say hello world")36 end37 it "adds the correct information in chunks and extra_inlined_arguments to Call" do38 expect(call.chunks).to eq([{value: "I say hello world", is_argument: false}])39 expect(call.extra_inlined_arguments).to be_empty40 end41 it "adds the corresponding :gherkin_annotation to Actionword" do42 expect(actionword.children[:gherkin_annotation]).to eq("When")43 end44 it "adds the corresponding :gherkin_pattern to Actionword" do45 expect(actionword.children[:gherkin_pattern]).to eq("^I say hello world$")46 end47 it "adds the correct informations and extra_inlined_parameters to Actionword" do48 expect(actionword.chunks).to eq([{value: "I say hello world", is_parameter: false}])49 expect(actionword.extra_inlined_parameters).to be_empty50 end51 context "with actionword name containing with regex reserved characters" do52 let(:actionword_name) { "Nom. de. Zeués... [|]\\+*?()$^ Marty!?" }53 it "escapes the characters in the :gherkin_pattern" do54 expect(gherkin_pattern).to eq("^Nom\\. de\\. Zeués\\.\\.\\. \\[\\|\\]\\\\\\+\\*\\?\\(\\)\\$\\^ Marty!\\?$")55 end56 it "adds the correct informations and extra_inlined_parameters to Actionword" do57 expect(actionword.chunks).to eq([58 {59 value: "Nom\\. de\\. Zeués\\.\\.\\. \\[\\|\\]\\\\\\+\\*\\?\\(\\)\\$\\^ Marty!\\?",60 is_parameter: false61 }])62 expect(actionword.extra_inlined_parameters).to be_empty63 end64 end65 context "with actionword name containing with regex reserved characters" do66 let(:actionword_name) { "hello\\world" }67 it "escapes the characters in the :gherkin_pattern" do68 expect(gherkin_pattern).to eq("^hello\\\\world$")69 end70 it "adds the correct informations and extra_inlined_parameters to Actionword" do71 expect(actionword.chunks).to eq([{72 value: "hello\\\\world",73 is_parameter: false74 }])75 expect(actionword.extra_inlined_parameters).to be_empty76 end77 end78 context "with untrimed action words" do79 let(:actionword_name) { " do things and \"stuff\" " }80 it "trims the name in the :gherkin_pattern" do81 expect(gherkin_pattern).to eq("^do things and \"stuff\"$")82 end83 it "trims the name in the :gherkin_text" do84 expect(gherkin_text).to eq("When do things and \"stuff\"")85 end86 it "adds the correct information in chunks and extra_inlined_arguments to Call" do87 expect(call.chunks).to eq([88 {value: " do things and ", is_argument: false},89 {value: "stuff", is_argument: false},90 {value: " ", is_argument: false}91 ])92 expect(call.extra_inlined_arguments).to be_empty93 end94 it "adds the correct informations and extra_inlined_parameters to Actionword" do95 expect(actionword.chunks).to eq([96 {value: " do things and ", is_parameter: false},97 {value: "stuff", is_parameter: false},98 {value: " ", is_parameter: false}99 ])100 expect(actionword.extra_inlined_parameters).to be_empty101 end102 end103 shared_examples "generic gherkin annotations" do104 it "uses 'Given' as default annotation in gherkin code" do105 expect(gherkin_annotation).to eq("Given")106 end107 it "uses '* ' as default annotation in gherkin text" do108 expect(gherkin_text).to eq("* I say hello world")109 end110 end111 context "without annotation on call" do112 let(:call) { make_call(actionword_name) }113 include_examples "generic gherkin annotations"114 end115 context "with empty annotation on call" do116 let(:call) { make_call(actionword_name, annotation: "") }117 include_examples "generic gherkin annotations"118 end119 context "with 1 quote in its name" do120 let(:actionword_name) { "I say \"hello world" }121 it "keeps the quoted text untouched" do122 expect(gherkin_text).to eq("When I say \"hello world")123 expect(gherkin_pattern).to eq("^I say \"hello world$")124 end125 end126 context "with 2 quotes in its name" do127 let(:actionword_name) { "I say \"hello world\"" }128 it "keeps the quoted text untouched" do129 expect(gherkin_text).to eq("When I say \"hello world\"")130 expect(gherkin_pattern).to eq("^I say \"hello world\"$")131 end132 it "adds the correct informations and extra_inlined_parameters to Actionword" do133 expect(actionword.chunks).to eq([134 {value: "I say ", is_parameter: false},135 {value: "hello world", is_parameter: false},136 {value: "", is_parameter: false}137 ])138 expect(actionword.extra_inlined_parameters).to be_empty139 end140 end141 context "but with quoted text, and with a call having a matching argument (which is invalid because actionword has no parameters)" do142 let(:actionword_name) { "I say \"hello\"" }143 let(:call) { make_call(actionword_name, annotation: "when", arguments: [144 make_argument("hello", literal("Guten tag")),145 ])146 }147 it "keeps the quoted text untouched nevertheless" do148 expect(gherkin_text).to eq("When I say \"hello\"")149 expect(gherkin_pattern).to eq("^I say \"hello\"$")150 end151 it "adds the correct information in chunks and extra_inlined_arguments to Call" do152 expect(call.chunks).to eq([153 {value: "I say ", is_argument: false},154 {value: "hello", is_argument: false},155 {value: "", is_argument: false}156 ])157 expect(call.extra_inlined_arguments).to be_empty158 end159 it "adds the correct informations and extra_inlined_parameters to Actionword" do160 expect(actionword.chunks).to eq([161 {value: "I say ", is_parameter: false},162 {value: "hello", is_parameter: false},163 {value: "", is_parameter: false}164 ])165 expect(actionword.extra_inlined_parameters).to be_empty166 end167 end168 end169 context "actionword with one parameter without default value" do170 let(:actionword_name) { "Hello \"name\"" }171 let(:actionword) { make_actionword(actionword_name, parameters: [make_parameter("name")]) }172 it "adds corresponding :gherkin_pattern to Actionword" do173 expect(gherkin_pattern).to eq("^Hello \"(.*)\"$")174 end175 context "called without arguments" do176 let(:call) { make_call(actionword_name, annotation: "and") }177 it "uses empty string as default value for gherkin_text" do178 expect(gherkin_text).to eq("And Hello \"\"")179 end180 it "adds the correct information in chunks and extra_inlined_arguments to Call" do181 expect(call.chunks).to eq([182 {value: "Hello ", is_argument: false},183 {value: "", is_argument: true},184 {value: "", is_argument: false}185 ])186 expect(call.extra_inlined_arguments).to be_empty187 end188 end189 end190 context "actionword with one parameter" do191 let(:actionword) {192 make_actionword(actionword_name, parameters: [193 make_parameter("name", default: literal("World")),194 ])195 }196 context "inlined" do197 let(:actionword_name) { "Hello \"name\"" }198 it "adds corresponding :gherkin_pattern to Actionword" do199 expect(gherkin_pattern).to eq("^Hello \"(.*)\"$")200 end201 it "adds the correct informations and extra_inlined_parameters to Actionword" do202 expect(actionword.chunks).to eq([203 {value: "Hello ", is_parameter: false},204 {value: "(.*)", name: "name", is_parameter: true},205 {value: "", is_parameter: false}206 ])207 expect(actionword.extra_inlined_parameters).to be_empty208 end209 context "called with a string argument" do210 let(:call) {211 make_call(actionword_name, annotation: "given", arguments: [212 make_argument("name", literal("John")),213 ])214 }215 it "adds corresponding :gherkin_text to Call" do216 expect(gherkin_text).to eq("Given Hello \"John\"")217 end218 it "adds the correct information in chunks and extra_inlined_arguments to Call" do219 expect(call.chunks).to eq([220 {value: "Hello ", is_argument: false},221 {value: "John", is_argument: true},222 {value: "", is_argument: false}223 ])224 expect(call.extra_inlined_arguments).to be_empty225 end226 end227 context "called with a variable argument" do228 let(:call) {229 make_call(actionword_name, annotation: "given", arguments: [230 make_argument("name", variable("name")),231 ])232 }233 it "adds the variable name enclosed with chevrons <>" do234 expect(gherkin_text).to eq("Given Hello \"<name>\"")235 end236 it "adds the correct information in chunks and extra_inlined_arguments to Call" do237 expect(call.chunks).to eq([238 {value: "Hello ", is_argument: false},239 {value: "<name>", is_argument: true},240 {value: "", is_argument: false}241 ])242 expect(call.extra_inlined_arguments).to be_empty243 end244 end245 context "called without arguments" do246 let(:call) { make_call(actionword_name, annotation: "given") }247 it "uses the default value of the actionword parameter" do248 expect(gherkin_text).to eq("Given Hello \"World\"")249 end250 it "adds the correct information in chunks and extra_inlined_arguments to Call" do251 expect(call.chunks).to eq([252 {value: "Hello ", is_argument: false},253 {value: "World", is_argument: true},254 {value: "", is_argument: false}255 ])256 expect(call.extra_inlined_arguments).to be_empty257 end258 end259 end260 context "not inlined" do261 let(:actionword_name) { "Hello to all of you" }262 it "adds corresponding :gherkin_pattern to Actionword" do263 expect(gherkin_pattern).to eq("^Hello to all of you \"(.*)\"$")264 end265 it "adds the correct informations and extra_inlined_parameters to Actionword" do266 expect(actionword.chunks).to eq([267 {value: "Hello to all of you", is_parameter: false}268 ])269 expect(actionword.extra_inlined_parameters).to eq([270 {value: "(.*)", name: "name", is_parameter: true}271 ])272 end273 it "adds the correct information in chunks and extra_inlined_arguments to Call" do274 expect(call.chunks).to eq([275 {value: "Hello to all of you", is_argument: false}276 ])277 expect(call.extra_inlined_arguments).to eq([{value: "John", is_argument: true}])278 end279 context "called with an argument" do280 let(:call) {281 make_call(actionword_name, annotation: "given", arguments: [282 make_argument("name", literal("Paul")),283 ])284 }285 it "adds the argument value at the end of the gherkin text" do286 expect(gherkin_text).to eq("Given Hello to all of you \"Paul\"")287 end288 it "adds the correct information in chunks and extra_inlined_arguments to Call" do289 expect(call.chunks).to eq([290 {value: "Hello to all of you", is_argument: false}291 ])292 expect(call.extra_inlined_arguments).to eq([{value: "Paul", is_argument: true}])293 end294 end295 context "called with a variable argument" do296 let(:call) {297 make_call(actionword_name, annotation: "given", arguments: [298 make_argument("name", variable("name")),299 ])300 }301 it "adds the variable name enclosed with chevrons <>" do302 expect(gherkin_text).to eq("Given Hello to all of you \"<name>\"")303 end304 it "adds the correct information in chunks and extra_inlined_arguments to Call" do305 expect(call.chunks).to eq([306 {value: "Hello to all of you", is_argument: false}307 ])308 expect(call.extra_inlined_arguments).to eq([{value: "<name>", is_argument: true}])309 end310 end311 context "called without arguments" do312 let(:call) { make_call(actionword_name, annotation: "given") }313 it "adds the default value at the end of the gherkin text" do314 expect(gherkin_text).to eq("Given Hello to all of you \"World\"")315 end316 it "adds the correct information in chunks and extra_inlined_arguments to Call" do317 expect(call.chunks).to eq([318 {value: "Hello to all of you", is_argument: false}319 ])320 expect(call.extra_inlined_arguments).to eq([{value: "World", is_argument: true}])321 end322 end323 end324 end325 context "actionword with multiple parameters" do326 let(:actionword) {327 make_actionword(actionword_name, parameters: [328 make_parameter("name1", default: literal("Riri")),329 make_parameter("name2", default: literal("Fifi")),330 make_parameter("name3", default: literal("Loulou")),331 ])332 }333 context "inlined" do334 let(:actionword_name) { "Hello \"name1\", \"name2\", \"name3\"" }335 it "adds corresponding :gherkin_pattern to Actionword" do336 expect(gherkin_pattern).to eq("^Hello \"(.*)\", \"(.*)\", \"(.*)\"$")337 end338 it "adds the correct informations and extra_inlined_parameters to Actionword" do339 expect(actionword.chunks).to eq([340 {value: "Hello ", is_parameter: false},341 {value: "(.*)", name: "name1", is_parameter: true},342 {value: ", ", is_parameter: false},343 {value: "(.*)", name: "name2", is_parameter: true},344 {value: ", ", is_parameter: false},345 {value: "(.*)", name: "name3", is_parameter: true},346 {value: "", is_parameter: false},347 ])348 expect(actionword.extra_inlined_parameters).to be_empty349 end350 context "called with no arguments" do351 let(:call) { make_call(actionword_name, annotation: "given") }352 it "adds :gherkin_text to Call using default parameters values" do353 expect(gherkin_text).to eq("Given Hello \"Riri\", \"Fifi\", \"Loulou\"")354 end355 it "adds the correct information in chunks and extra_inlined_arguments to Call" do356 expect(call.chunks).to eq([357 {value: "Hello ", is_argument: false},358 {value: "Riri", is_argument: true},359 {value: ", ", is_argument: false},360 {value: "Fifi", is_argument: true},361 {value: ", ", is_argument: false},362 {value: "Loulou", is_argument: true},363 {value: "", is_argument: false}364 ])365 expect(call.extra_inlined_arguments).to be_empty366 end367 end368 context "called with all arguments filled" do369 let(:call) {370 make_call(actionword_name, annotation: "given", arguments: [371 # unordered, just to see if it works372 make_argument("name2", literal("Paul")),373 make_argument("name3", literal("Jacques")),374 make_argument("name1", literal("Pierre")),375 ])376 }377 it "adds :gherkin_text to Call using call arguments values" do378 expect(gherkin_text).to eq("Given Hello \"Pierre\", \"Paul\", \"Jacques\"")379 end380 it "adds the correct information in chunks and extra_inlined_arguments to Call" do381 expect(call.chunks).to eq([382 {value: "Hello ", is_argument: false},383 {value: "Pierre", is_argument: true},384 {value: ", ", is_argument: false},385 {value: "Paul", is_argument: true},386 {value: ", ", is_argument: false},387 {value: "Jacques", is_argument: true},388 {value: "", is_argument: false}389 ])390 expect(call.extra_inlined_arguments).to be_empty391 end392 end393 end394 context "not inlined" do395 let(:actionword_name) { "Hello to all of you" }396 it "adds corresponding :gherkin_pattern to Actionword" do397 expect(gherkin_pattern).to eq("^Hello to all of you \"(.*)\" \"(.*)\" \"(.*)\"$")398 end399 it "adds the correct informations and extra_inlined_parameters to Actionword" do400 expect(actionword.chunks).to eq([401 {value: "Hello to all of you", is_parameter: false}402 ])403 expect(actionword.extra_inlined_parameters).to eq([404 {value: "(.*)", name: "name1", is_parameter: true},405 {value: "(.*)", name: "name2", is_parameter: true},406 {value: "(.*)", name: "name3", is_parameter: true},407 ])408 end409 context "called with no arguments" do410 let(:call) { make_call(actionword_name, annotation: "given") }411 it "adds :gherkin_text to Call using default parameters values at the end" do412 expect(gherkin_text).to eq("Given Hello to all of you \"Riri\" \"Fifi\" \"Loulou\"")413 end414 it "adds the correct information in chunks and extra_inlined_arguments to Call" do415 expect(call.chunks).to eq([416 {value: "Hello to all of you", is_argument: false}417 ])418 expect(call.extra_inlined_arguments).to eq([419 {value: "Riri", is_argument: true},420 {value: "Fifi", is_argument: true},421 {value: "Loulou", is_argument: true}422 ])423 end424 end425 context "called with all arguments filled" do426 let(:call) {427 make_call(actionword_name, annotation: "given", arguments: [428 # unordered, just to see if it works429 make_argument("name2", literal("Paul")),430 make_argument("name3", literal("Jacques")),431 make_argument("name1", literal("Pierre")),432 ])433 }434 it "adds :gherkin_text to Call and appends call arguments values in the order defined by the actionword" do435 expect(gherkin_text).to eq("Given Hello to all of you \"Pierre\" \"Paul\" \"Jacques\"")436 end437 it "adds the correct information in chunks and extra_inlined_arguments to Call" do438 expect(call.chunks).to eq([439 {value: "Hello to all of you", is_argument: false}440 ])441 expect(call.extra_inlined_arguments).to eq([442 {value: "Pierre", is_argument: true},443 {value: "Paul", is_argument: true},444 {value: "Jacques", is_argument: true}445 ])446 end447 end448 end449 end450 context "actionword with mixed cases" do451 let(:actionword_name) { "good morning \"name\", we are \"day\". Say \"something\"!" }452 let(:actionword) {453 make_actionword(actionword_name, parameters: [454 make_parameter("name", default: literal("Tom")),455 make_parameter("day", default: literal("Monday")),456 make_parameter("temperature", default: literal("25°C")),457 make_parameter("weather", default: literal("Sunny")),458 # "something" is not a parameter459 ])460 }461 let(:call) {462 make_call(actionword_name, arguments: [463 make_argument("weather", literal("rainy")),464 make_argument("name", literal("Captain obvious")),465 make_argument("something", literal("in the way")), # it's a trap !466 ])467 }468 it "produces the expected :gherkin_pattern" do469 expect(gherkin_pattern).to eq("^good morning \"(.*)\", we are \"(.*)\"\\. Say \"something\"! \"(.*)\" \"(.*)\"$")470 end471 it "produces the expected :gherkin_annotation" do472 expect(gherkin_annotation).to eq("Given")473 end474 it "produces the expected :gherkin_text" do475 expect(gherkin_text).to eq("* good morning \"Captain obvious\", we are \"Monday\". Say \"something\"! \"25°C\" \"rainy\"")476 end477 it "adds the correct informations and extra_inlined_parameters to Actionword" do478 expect(actionword.chunks).to eq([479 {value: "good morning ", is_parameter: false},480 {value: "(.*)", name: "name", is_parameter: true},481 {value: ", we are ", is_parameter: false},482 {value: "(.*)", name: "day", is_parameter: true},483 {value: "\\. Say ", is_parameter: false},484 {value: "something", is_parameter: false},485 {value: "!", is_parameter: false}486 ])487 expect(actionword.extra_inlined_parameters).to eq([488 {value: "(.*)", name: "temperature", is_parameter: true},489 {value: "(.*)", name: "weather", is_parameter: true}490 ])491 end492 it "adds the correct information in chunks and extra_inlined_arguments to Call" do493 expect(call.chunks).to eq([494 {value: "good morning ", is_argument: false},495 {value: "Captain obvious", is_argument: true},496 {value: ", we are ", is_argument: false},497 {value: "Monday", is_argument: true},498 {value: ". Say ", is_argument: false},499 {value: "something", is_argument: false},500 {value: "!", is_argument: false}501 ])502 expect(call.extra_inlined_arguments).to eq([503 {value:"25°C", is_argument: true},504 {value:"rainy", is_argument: true}505 ])506 end507 end508 context "using templated parameters and arguments" do # same, but with templates509 let(:actionword_name) { "good morning \"name\", we are \"day\". Say \"something\"!" }510 let(:actionword) {511 make_actionword(actionword_name, parameters: [512 make_parameter("name", default: template_of_literals("Tom")),513 make_parameter("day", default: template_of_literals("Mon", "day")),514 make_parameter("temperature", default: template_of_literals("25°C")),515 make_parameter("weather", default: template_of_literals("Sunny")),516 # "something" is not a parameter517 ])518 }519 let(:call) {520 make_call(actionword_name, arguments: [521 make_argument("weather", template_of_literals("rainy")),522 make_argument("name", template_of_literals("Captain obvious")),523 make_argument("something", template_of_literals("in the way")), # it's a trap !524 ])525 }526 it "produces the expected :gherkin_pattern" do527 expect(gherkin_pattern).to eq("^good morning \"(.*)\", we are \"(.*)\"\\. Say \"something\"! \"(.*)\" \"(.*)\"$")528 end529 it "produces the expected :gherkin_annotation" do530 expect(gherkin_annotation).to eq("Given")531 end532 it "produces the expected :gherkin_text" do533 expect(gherkin_text).to eq("* good morning \"Captain obvious\", we are \"Monday\". Say \"something\"! \"25°C\" \"rainy\"")534 end535 it "adds the correct information in chunks and extra_inlined_arguments to Call" do536 expect(call.chunks).to eq([537 {value: "good morning ", is_argument: false},538 {value: "Captain obvious", is_argument: true},539 {value: ", we are ", is_argument: false},540 {value: "Monday", is_argument: true},541 {value: ". Say ", is_argument: false},542 {value: "something", is_argument: false},543 {value: "!", is_argument: false}544 ])545 expect(call.extra_inlined_arguments).to eq([546 {value:"25°C", is_argument: true},547 {value:"rainy", is_argument: true}548 ])549 end550 end551 context "annotation picking with multiple calls" do552 let(:project) {553 make_project("My project", scenarios: [scenario, other_scenario], actionwords: [actionword_hello, actionword_bonjour])554 }555 let(:scenario) { make_scenario("My scenario") }556 let(:other_scenario) { make_scenario("Other scenario") }557 let(:actionword_hello) { make_actionword("Hello") }558 let(:actionword_bonjour) { make_actionword("Bonjour") }559 context "with And annotation" do560 let(:scenario) {561 make_scenario("My scenario", body: [562 make_call(actionword_hello.children[:name], annotation: "when"),563 make_call(actionword_bonjour.children[:name], annotation: "and"),564 ])565 }566 it "picks the last meaningful annotation" do567 expect(actionword_bonjour.children[:gherkin_annotation]).to eq("When")568 end569 end570 context "with But annotation" do571 let(:scenario) {572 make_scenario("My scenario", body: [573 make_call(actionword_hello.children[:name], annotation: "when"),574 make_call(actionword_bonjour.children[:name], annotation: "but"),575 ])576 }577 it "picks the last meaningful annotation" do578 expect(actionword_bonjour.children[:gherkin_annotation]).to eq("When")579 end580 end581 context "with And annotation as first step" do582 let(:other_scenario) {583 make_scenario("My scenario", body: [584 make_call(actionword_bonjour.children[:name], annotation: "and"),585 ])586 }587 it "uses 'Given' by default" do588 expect(actionword_bonjour.children[:gherkin_annotation]).to eq("Given")589 end590 context "with another scenario using Then defined before" do591 let(:scenario) {592 make_scenario("My scenario", body: [593 make_call(actionword_hello.children[:name], annotation: "then"),594 ])595 }596 it "uses 'Given' by default" do597 expect(actionword_bonjour.children[:gherkin_annotation]).to eq("Given")598 end599 end600 end601 context "with multiple annotations used for the same actionword" do602 let(:scenario) {603 make_scenario("My scenario", body: [604 make_call(actionword_bonjour.children[:name], annotation: "given"),605 make_call(actionword_bonjour.children[:name], annotation: "when"),606 make_call(actionword_bonjour.children[:name], annotation: "then"),607 ])608 }609 let(:other_scenario) {610 make_scenario("Other scenario", body: [611 make_call(actionword_bonjour.children[:name], annotation: "given"),612 make_call(actionword_bonjour.children[:name], annotation: "then"),613 make_call(actionword_bonjour.children[:name], annotation: "and"),614 ])615 }616 it "uses the one used the most" do617 # in this case, it's then, used three times618 expect(actionword_bonjour.children[:gherkin_annotation]).to eq("Then")619 end620 end621 context "with unused actionword" do622 it "has no annotation (nil)" do623 expect(actionword_bonjour.children[:gherkin_annotation]).to be_nil624 end625 end626 end627 context "action word with special parameters" do628 let(:actionword_name) { "I open \"site\" and see:" }629 let(:actionword) {630 make_actionword(actionword_name, parameters: [631 make_parameter("site"),632 make_parameter("__free_text", default: literal(""))633 ])634 }635 let(:call) {636 make_call(actionword_name, arguments: [637 make_argument("site", literal("Google")),638 make_argument("__free_text", literal("I'm feeling lucky"))639 ])640 }641 it 'does not render the __free_text argument in gherkin_text (the template will do it)' do642 expect(gherkin_text).to eq("* I open \"Google\" and see:")643 end644 it 'does not add a capturing group in the gherkin_pattern for the __free_text argument' do645 expect(gherkin_pattern).to eq("^I open \"(.*)\" and see:$")646 end647 it "adds the correct informations and extra_inlined_parameters to Actionword" do648 expect(actionword.chunks).to eq([649 {value: "I open ", is_parameter: false},650 {value: "(.*)", name: "site", is_parameter: true},651 {value: " and see:", is_parameter: false}652 ])653 expect(actionword.extra_inlined_parameters).to be_empty654 end655 it "adds the correct information in chunks and extra_inlined_arguments to Call" do656 expect(call.chunks).to eq([657 {value: "I open ", is_argument: false},658 {value: "Google", is_argument: true},659 {value: " and see:", is_argument: false}660 ])661 expect(call.extra_inlined_arguments).to be_empty662 end663 end664 context "call to unknown actionword" do665 let(:call) { make_call("Hi \"name\"", annotation: "given") }666 it "is not handled and behavior is undefined"667 end668end...

Full Screen

Full Screen

gherkin_formatter_adapter.rb

Source:gherkin_formatter_adapter.rb Github

copy

Full Screen

...4 module Formatter5 # Adapts Cucumber formatter events to Gherkin formatter events6 # This class will disappear when Cucumber is based on Gherkin's model.7 class GherkinFormatterAdapter8 def initialize(gherkin_formatter, print_empty_match)9 @gf = gherkin_formatter10 @print_empty_match = print_empty_match11 end12 def before_feature(feature)13 @gf.uri(feature.file)14 @gf.feature(feature.gherkin_statement)15 end16 def before_background(background)17 @outline = false18 @gf.background(background.gherkin_statement)19 end20 def before_feature_element(feature_element)21 case(feature_element)22 when Ast::Scenario23 @outline = false24 @gf.scenario(feature_element.gherkin_statement)25 when Ast::ScenarioOutline26 @outline = true27 @gf.scenario_outline(feature_element.gherkin_statement)28 else29 raise "Bad type: #{feature_element.class}"30 end31 end32 def before_step(step)33 @gf.step(step.gherkin_statement)34 if @print_empty_match35 if(@outline)36 match = Gherkin::Formatter::Model::Match.new(step.gherkin_statement.outline_args, nil)37 else38 match = Gherkin::Formatter::Model::Match.new([], nil)39 end40 @gf.match(match)41 end42 @step_time = Time.now43 end44 def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)45 arguments = step_match.step_arguments.map{|a| Gherkin::Formatter::Argument.new(a.offset, a.val)}46 location = step_match.file_colon_line47 match = Gherkin::Formatter::Model::Match.new(arguments, location)48 if @print_empty_match49 # Trick the formatter to believe that's what was printed previously so we get arg highlights on #result50 @gf.instance_variable_set('@match', match)51 else52 @gf.match(match)53 end54 error_message = exception ? "#{exception.message} (#{exception.class})\n#{exception.backtrace.join("\n")}" : nil55 unless @outline56 @gf.result(Gherkin::Formatter::Model::Result.new(status, nil, error_message))57 end58 end59 def before_examples(examples)60 @gf.examples(examples.gherkin_statement)61 end62 #used for capturing duration...

Full Screen

Full Screen

empty

Using AI Code Generation

copy

Full Screen

1irb(main):001:0> require '1'2irb(main):002:0> gherkin = Gherkin.new3irb(main):003:0> gherkin.empty4irb(main):004:0> puts gherkin.empty5irb(main):00:> require '2'6irb(main):02:0> gherkin = Gherkin.new7irb(main):003:0> gherkin.empty?8irb(main):004:0> puts gherkin.empty?

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