You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pretty_spec.rb 26 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. require 'cucumber/formatter/spec_helper'
  4. require 'cucumber/formatter/pretty'
  5. require 'cucumber/cli/options'
  6. module Cucumber
  7. module Formatter
  8. describe Pretty do
  9. extend SpecHelperDsl
  10. include SpecHelper
  11. context 'With no options' do
  12. before(:each) do
  13. Cucumber::Term::ANSIColor.coloring = false
  14. @out = StringIO.new
  15. @formatter = Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: false))
  16. end
  17. describe 'given a single feature' do
  18. before(:each) do
  19. run_defined_feature
  20. end
  21. describe 'with a scenario' do
  22. define_feature <<-FEATURE
  23. Feature: Banana party
  24. Scenario: Monkey eats banana
  25. Given there are bananas
  26. FEATURE
  27. it 'outputs the scenario name' do
  28. expect(@out.string).to include 'Scenario: Monkey eats banana'
  29. end
  30. it 'outputs the step' do
  31. expect(@out.string).to include 'Given there are bananas'
  32. end
  33. end
  34. describe 'with a background' do
  35. define_feature <<-FEATURE
  36. Feature: Banana party
  37. Background:
  38. Given a tree
  39. Scenario: Monkey eats banana
  40. Given there are bananas
  41. FEATURE
  42. it 'outputs the gherkin' do
  43. expect(@out.string).to include(self.class.feature_content)
  44. end
  45. it 'outputs the scenario name' do
  46. expect(@out.string).to include 'Scenario: Monkey eats banana'
  47. end
  48. it 'outputs the step' do
  49. expect(@out.string).to include 'Given there are bananas'
  50. end
  51. end
  52. describe 'with a scenario outline' do
  53. define_feature <<-FEATURE
  54. Feature: Fud Pyramid
  55. Scenario Outline: Monkey eats a balanced diet
  56. Given there are <Things>
  57. Examples: Fruit
  58. | Things |
  59. | apples |
  60. | bananas |
  61. Examples: Vegetables
  62. | Things |
  63. | broccoli |
  64. | carrots |
  65. FEATURE
  66. it 'outputs the scenario outline' do
  67. lines = <<-OUTPUT
  68. Examples: Fruit
  69. | Things |
  70. | apples |
  71. | bananas |
  72. Examples: Vegetables
  73. | Things |
  74. | broccoli |
  75. | carrots |
  76. OUTPUT
  77. lines.split("\n").each do |line|
  78. expect(@out.string).to include line.strip
  79. end
  80. end
  81. it 'has 4 undefined scenarios' do
  82. expect(@out.string).to include '4 scenarios (4 undefined)'
  83. end
  84. it 'has 4 undefined steps' do
  85. expect(@out.string).to include '4 steps (4 undefined)'
  86. end
  87. context 'when the examples table header is wider than the rows' do
  88. define_feature <<-FEATURE
  89. Feature: Monkey Business
  90. Scenario Outline: Types of monkey
  91. Given there are <Types of monkey>
  92. Examples:
  93. | Types of monkey |
  94. | Hominidae |
  95. FEATURE
  96. it 'outputs the scenario outline' do
  97. lines = <<-OUTPUT
  98. Examples:
  99. | Types of monkey |
  100. | Hominidae |
  101. OUTPUT
  102. lines.split("\n").each do |line|
  103. expect(@out.string).to include line.strip
  104. end
  105. end
  106. end
  107. end
  108. # To ensure https://rspec.lighthouseapp.com/projects/16211/tickets/475 remains fixed.
  109. describe 'with a scenario outline with a pystring' do
  110. define_feature <<-FEATURE
  111. Feature:
  112. Scenario Outline: Monkey eats a balanced diet
  113. Given a multiline string:
  114. """
  115. Monkeys eat <things>
  116. """
  117. Examples:
  118. | things |
  119. | apples |
  120. FEATURE
  121. it 'outputs the scenario outline' do
  122. lines = <<-OUTPUT
  123. Given a multiline string:
  124. """
  125. Monkeys eat <things>
  126. """
  127. Examples:
  128. | things |
  129. | apples |
  130. OUTPUT
  131. lines.split("\n").each do |line|
  132. expect(@out.string).to include line.strip
  133. end
  134. end
  135. end
  136. describe 'with a step with a py string' do
  137. define_feature <<-FEATURE
  138. Feature: Traveling circus
  139. Scenario: Monkey goes to town
  140. Given there is a monkey called:
  141. """
  142. foo
  143. """
  144. FEATURE
  145. it 'displays the pystring nested' do
  146. expect(@out.string).to include <<OUTPUT
  147. """
  148. foo
  149. """
  150. OUTPUT
  151. end
  152. end
  153. describe 'with a multiline step arg' do
  154. define_feature <<-FEATURE
  155. Feature: Traveling circus
  156. Scenario: Monkey goes to town
  157. Given there are monkeys:
  158. | name |
  159. | foo |
  160. | bar |
  161. FEATURE
  162. it 'displays the multiline string' do
  163. expect(@out.string).to include <<OUTPUT
  164. Given there are monkeys:
  165. | name |
  166. | foo |
  167. | bar |
  168. OUTPUT
  169. end
  170. end
  171. describe 'with a table in the background and the scenario' do
  172. define_feature <<-FEATURE
  173. Feature: accountant monkey
  174. Background:
  175. Given table:
  176. | a | b |
  177. | c | d |
  178. Scenario:
  179. Given another table:
  180. | e | f |
  181. | g | h |
  182. FEATURE
  183. it 'displays the table for the background' do
  184. expect(@out.string).to include <<OUTPUT
  185. Given table:
  186. | a | b |
  187. | c | d |
  188. OUTPUT
  189. end
  190. it 'displays the table for the scenario' do
  191. expect(@out.string).to include <<OUTPUT
  192. Given another table:
  193. | e | f |
  194. | g | h |
  195. OUTPUT
  196. end
  197. end
  198. describe 'with a py string in the background and the scenario' do
  199. define_feature <<-FEATURE
  200. Feature: py strings
  201. Background:
  202. Given stuff:
  203. """
  204. foo
  205. """
  206. Scenario:
  207. Given more stuff:
  208. """
  209. bar
  210. """
  211. FEATURE
  212. it 'displays the background py string' do
  213. expect(@out.string).to include <<OUTPUT
  214. Given stuff:
  215. """
  216. foo
  217. """
  218. OUTPUT
  219. end
  220. it 'displays the scenario py string' do
  221. expect(@out.string).to include <<OUTPUT
  222. Given more stuff:
  223. """
  224. bar
  225. """
  226. OUTPUT
  227. end
  228. end
  229. describe 'with output from hooks' do
  230. define_feature <<-FEATURE
  231. Feature:
  232. Scenario:
  233. Given this step passes
  234. Scenario Outline:
  235. Given this step <status>
  236. Examples:
  237. | status |
  238. | passes |
  239. FEATURE
  240. define_steps do
  241. Before do
  242. log 'Before hook'
  243. end
  244. AfterStep do
  245. log 'AfterStep hook'
  246. end
  247. After do
  248. log 'After hook'
  249. end
  250. Given('this step passes') {}
  251. end
  252. it 'displays hook output appropriately ' do
  253. expect(@out.string).to include <<OUTPUT
  254. Feature:
  255. Scenario:
  256. Before hook
  257. Given this step passes
  258. AfterStep hook
  259. After hook
  260. Scenario Outline:
  261. Given this step <status>
  262. Examples:
  263. | status |
  264. | passes | Before hook, AfterStep hook, After hook
  265. 2 scenarios (2 passed)
  266. 2 steps (2 passed)
  267. OUTPUT
  268. end
  269. end
  270. describe 'with background and output from hooks' do
  271. define_feature <<-FEATURE
  272. Feature:
  273. Background:
  274. Given this step passes
  275. Scenario:
  276. Given this step passes
  277. FEATURE
  278. define_steps do
  279. Before do
  280. log 'Before hook'
  281. end
  282. AfterStep do
  283. log 'AfterStep hook'
  284. end
  285. After do
  286. log 'After hook'
  287. end
  288. Given('this step passes') {}
  289. end
  290. it 'displays hook output appropriately ' do
  291. expect(@out.string).to include <<OUTPUT
  292. Feature:
  293. Background:
  294. Before hook
  295. Given this step passes
  296. AfterStep hook
  297. Scenario:
  298. Given this step passes
  299. AfterStep hook
  300. After hook
  301. 1 scenario (1 passed)
  302. 2 steps (2 passed)
  303. OUTPUT
  304. end
  305. end
  306. describe 'with tags on all levels' do
  307. define_feature <<-FEATURE
  308. @tag1
  309. Feature:
  310. @tag2
  311. Scenario:
  312. Given this step passes
  313. @tag3
  314. Scenario Outline:
  315. Given this step passes
  316. @tag4
  317. Examples:
  318. | dummy |
  319. | dummy |
  320. FEATURE
  321. it 'includes the tags in the output ' do
  322. expect(@out.string).to include <<OUTPUT
  323. @tag1
  324. Feature:
  325. @tag2
  326. Scenario:
  327. Given this step passes
  328. @tag3
  329. Scenario Outline:
  330. Given this step passes
  331. @tag4
  332. Examples:
  333. | dummy |
  334. | dummy |
  335. OUTPUT
  336. end
  337. end
  338. describe 'with comments on all levels' do
  339. define_feature <<-FEATURE
  340. #comment1
  341. Feature:
  342. #comment2
  343. Background:
  344. #comment3
  345. Given this step passes
  346. #comment4
  347. Scenario:
  348. #comment5
  349. Given this step passes
  350. #comment6
  351. | dummy |
  352. #comment7
  353. Scenario Outline:
  354. #comment8
  355. Given this step passes
  356. #comment9
  357. Examples:
  358. #comment10
  359. | dummy |
  360. #comment11
  361. | dummy |
  362. #comment12
  363. FEATURE
  364. it 'includes the all comments in the output' do
  365. expect(@out.string).to include <<OUTPUT
  366. #comment1
  367. Feature:
  368. #comment2
  369. Background:
  370. #comment3
  371. Given this step passes
  372. #comment4
  373. Scenario:
  374. #comment5
  375. Given this step passes
  376. #comment6
  377. | dummy |
  378. #comment7
  379. Scenario Outline:
  380. #comment8
  381. Given this step passes
  382. #comment9
  383. Examples:
  384. #comment10
  385. | dummy |
  386. #comment11
  387. | dummy |
  388. #comment12
  389. OUTPUT
  390. end
  391. end
  392. describe 'with the rule keyword' do
  393. define_feature <<-FEATURE
  394. Feature: Some rules
  395. Background: FB
  396. Given fb
  397. Rule: A
  398. The rule A description
  399. Background: AB
  400. Given ab
  401. Example: Example A
  402. Given a
  403. Rule: B
  404. The rule B description
  405. Example: Example B
  406. Given b
  407. FEATURE
  408. it 'ignores the rule keyword' do
  409. expect(@out.string).to include <<OUTPUT
  410. Feature: Some rules
  411. Background: FB
  412. Given fb
  413. Given ab
  414. Example: Example A
  415. Given a
  416. Example: Example B
  417. Given b
  418. OUTPUT
  419. end
  420. end
  421. end
  422. end
  423. context 'With --no-multiline passed as an option' do
  424. before(:each) do
  425. Cucumber::Term::ANSIColor.coloring = false
  426. @out = StringIO.new
  427. @formatter = Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: false, no_multiline: true))
  428. end
  429. describe 'given a single feature' do
  430. before(:each) do
  431. run_defined_feature
  432. end
  433. describe 'with a scenario' do
  434. define_feature <<-FEATURE
  435. Feature: Banana party
  436. Scenario: Monkey eats banana
  437. Given there are bananas
  438. FEATURE
  439. it 'outputs the scenario name' do
  440. expect(@out.string).to include 'Scenario: Monkey eats banana'
  441. end
  442. it 'outputs the step' do
  443. expect(@out.string).to include 'Given there are bananas'
  444. end
  445. end
  446. describe 'with a scenario outline' do
  447. define_feature <<-FEATURE
  448. Feature: Fud Pyramid
  449. Scenario Outline: Monkey eats a balanced diet
  450. Given there are <Things>
  451. Examples: Fruit
  452. | Things |
  453. | apples |
  454. | bananas |
  455. Examples: Vegetables
  456. | Things |
  457. | broccoli |
  458. | carrots |
  459. FEATURE
  460. it 'outputs the scenario outline' do
  461. lines = <<-OUTPUT
  462. Examples: Fruit
  463. | Things |
  464. | apples |
  465. | bananas |
  466. Examples: Vegetables
  467. | Things |
  468. | broccoli |
  469. | carrots |
  470. OUTPUT
  471. lines.split("\n").each do |line|
  472. expect(@out.string).to include line.strip
  473. end
  474. end
  475. it 'has 4 undefined scenarios' do
  476. expect(@out.string).to include '4 scenarios (4 undefined)'
  477. end
  478. it 'has 4 undefined steps' do
  479. expect(@out.string).to include '4 steps (4 undefined)'
  480. end
  481. end
  482. describe 'with a step with a py string' do
  483. define_feature <<-FEATURE
  484. Feature: Traveling circus
  485. Scenario: Monkey goes to town
  486. Given there is a monkey called:
  487. """
  488. foo
  489. """
  490. FEATURE
  491. it 'does not display the pystring' do
  492. expect(@out.string).not_to include <<OUTPUT
  493. """
  494. foo
  495. """
  496. OUTPUT
  497. end
  498. end
  499. describe 'with a multiline step arg' do
  500. define_feature <<-FEATURE
  501. Feature: Traveling circus
  502. Scenario: Monkey goes to town
  503. Given there are monkeys:
  504. | name |
  505. | foo |
  506. | bar |
  507. FEATURE
  508. it 'does not display the multiline string' do
  509. expect(@out.string).not_to include <<OUTPUT
  510. | name |
  511. | foo |
  512. | bar |
  513. OUTPUT
  514. end
  515. end
  516. describe 'with a table in the background and the scenario' do
  517. define_feature <<-FEATURE
  518. Feature: accountant monkey
  519. Background:
  520. Given table:
  521. | a | b |
  522. | c | d |
  523. Scenario:
  524. Given another table:
  525. | e | f |
  526. | g | h |
  527. FEATURE
  528. it 'does not display the table for the background' do
  529. expect(@out.string).not_to include <<OUTPUT
  530. | a | b |
  531. | c | d |
  532. OUTPUT
  533. end
  534. it 'does not display the table for the scenario' do
  535. expect(@out.string).not_to include <<OUTPUT
  536. | e | f |
  537. | g | h |
  538. OUTPUT
  539. end
  540. end
  541. describe 'with a py string in the background and the scenario' do
  542. define_feature <<-FEATURE
  543. Feature: py strings
  544. Background:
  545. Given stuff:
  546. """
  547. foo
  548. """
  549. Scenario:
  550. Given more stuff:
  551. """
  552. bar
  553. """
  554. FEATURE
  555. it 'does not display the background py string' do
  556. expect(@out.string).not_to include <<OUTPUT
  557. """
  558. foo
  559. """
  560. OUTPUT
  561. end
  562. it 'does not display the scenario py string' do
  563. expect(@out.string).not_to include <<OUTPUT
  564. """
  565. bar
  566. """
  567. OUTPUT
  568. end
  569. end
  570. end
  571. end
  572. context 'In --expand mode' do
  573. let(:options) { { expand: true } }
  574. before(:each) do
  575. Cucumber::Term::ANSIColor.coloring = false
  576. @out = StringIO.new
  577. @formatter = Pretty.new(actual_runtime.configuration.with_options(out_stream: @out))
  578. end
  579. describe 'given a single feature' do
  580. before(:each) do
  581. run_defined_feature
  582. end
  583. describe 'with a scenario outline' do
  584. define_feature <<-FEATURE
  585. Feature: Fud Pyramid
  586. Scenario Outline: Monkey eats a balanced diet
  587. Given there are <Things>
  588. Examples: Fruit
  589. | Things |
  590. | apples |
  591. | bananas |
  592. Examples: Vegetables
  593. | Things |
  594. | broccoli |
  595. | carrots |
  596. FEATURE
  597. it 'outputs the instantiated scenarios' do
  598. lines = <<-OUTPUT
  599. Examples: Fruit
  600. Example: | apples |
  601. Given there are apples
  602. Example: | bananas |
  603. Given there are bananas
  604. Examples: Vegetables
  605. Example: | broccoli |
  606. Given there are broccoli
  607. Example: | carrots |
  608. Given there are carrots
  609. OUTPUT
  610. lines.split("\n").each do |line|
  611. expect(@out.string).to include line.strip
  612. end
  613. end
  614. end
  615. describe 'with a scenario outline in en-lol' do
  616. define_feature <<-FEATURE
  617. # language: en-lol
  618. OH HAI: STUFFING
  619. MISHUN SRSLY: CUCUMBR
  620. I CAN HAZ IN TEH BEGINNIN <BEGINNIN> CUCUMBRZ
  621. WEN I EAT <EAT> CUCUMBRZ
  622. DEN I HAS <EAT> CUCUMBERZ IN MAH BELLY
  623. AN IN TEH END <KTHXBAI> CUCUMBRZ KTHXBAI
  624. EXAMPLZ:
  625. | BEGINNIN | EAT | KTHXBAI |
  626. | 3 | 2 | 1 |
  627. FEATURE
  628. it 'outputs localized text' do
  629. lines = <<-OUTPUT
  630. OH HAI: STUFFING
  631. MISHUN SRSLY: CUCUMBR
  632. I CAN HAZ IN TEH BEGINNIN <BEGINNIN> CUCUMBRZ
  633. WEN I EAT <EAT> CUCUMBRZ
  634. DEN I HAS <EAT> CUCUMBERZ IN MAH BELLY
  635. AN IN TEH END <KTHXBAI> CUCUMBRZ KTHXBAI
  636. EXAMPLZ:
  637. MISHUN: | 3 | 2 | 1 |
  638. I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ
  639. WEN I EAT 2 CUCUMBRZ
  640. DEN I HAS 2 CUCUMBERZ IN MAH BELLY
  641. AN IN TEH END 1 CUCUMBRZ KTHXBAI
  642. OUTPUT
  643. lines.split("\n").each do |line|
  644. expect(@out.string).to include line.strip
  645. end
  646. end
  647. end
  648. end
  649. end
  650. context 'In --expand mode with --source as an option' do
  651. let(:options) { { expand: true } }
  652. before(:each) do
  653. Cucumber::Term::ANSIColor.coloring = false
  654. @out = StringIO.new
  655. @formatter = Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: true))
  656. end
  657. describe 'given a single feature' do
  658. before(:each) do
  659. run_defined_feature
  660. end
  661. describe 'with a scenario outline' do
  662. define_feature <<-FEATURE
  663. Feature: Fud Pyramid
  664. Scenario Outline: Monkey eats a balanced diet
  665. Given there are <Things>
  666. Examples: Fruit
  667. | Things |
  668. | apples |
  669. | bananas |
  670. Examples: Vegetables
  671. | Things |
  672. | broccoli |
  673. | carrots |
  674. FEATURE
  675. it 'includes the source in the output' do
  676. lines = <<-OUTPUT
  677. Scenario Outline: Monkey eats a balanced diet # spec.feature:3
  678. Given there are <Things> # spec.feature:4
  679. Examples: Fruit
  680. Example: | apples | # spec.feature:8
  681. Given there are apples # spec.feature:8
  682. Example: | bananas | # spec.feature:9
  683. Given there are bananas # spec.feature:9
  684. Examples: Vegetables
  685. Example: | broccoli | # spec.feature:12
  686. Given there are broccoli # spec.feature:12
  687. Example: | carrots | # spec.feature:13
  688. Given there are carrots # spec.feature:13
  689. OUTPUT
  690. lines.split("\n").each do |line|
  691. expect(@out.string).to include line.strip
  692. end
  693. end
  694. context 'With very wide cells' do
  695. define_feature <<-FEATURE
  696. Feature: Monkey Business
  697. Scenario Outline: Types of monkey
  698. Given there are <Types of monkey>
  699. Examples:
  700. | Types of monkey | Extra |
  701. | Hominidae | Very long cell content |
  702. FEATURE
  703. it 'the scenario line controls the source indentation' do
  704. lines = <<-OUTPUT
  705. Examples:
  706. Example: | Hominidae | Very long cell content | # spec.feature:8
  707. Given there are Hominidae # spec.feature:8
  708. OUTPUT
  709. lines.split("\n").each do |line|
  710. expect(@out.string).to include line.strip
  711. end
  712. end
  713. end
  714. end
  715. end
  716. end
  717. context 'snippets contain relevant keyword replacements' do
  718. before(:each) do
  719. Cucumber::Term::ANSIColor.coloring = false
  720. @out = StringIO.new
  721. @formatter = Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, snippets: true))
  722. run_defined_feature
  723. end
  724. describe 'With a scenario that has undefined steps' do
  725. define_feature <<-FEATURE
  726. Feature: Banana party
  727. Scenario: many monkeys eat many things
  728. Given there are bananas and apples
  729. And other monkeys are around
  730. When one monkey eats a banana
  731. And the other monkeys eat all the apples
  732. Then bananas remain
  733. But there are no apples left
  734. FEATURE
  735. it "containes snippets with 'And' or 'But' replaced by previous step name" do
  736. expect(@out.string).to include("Given('there are bananas and apples')")
  737. expect(@out.string).to include("Given('other monkeys are around')")
  738. expect(@out.string).to include("When('one monkey eats a banana')")
  739. expect(@out.string).to include("When('the other monkeys eat all the apples')")
  740. expect(@out.string).to include("Then('bananas remain')")
  741. expect(@out.string).to include("Then('there are no apples left')")
  742. end
  743. end
  744. describe "With a scenario that uses * and 'But'" do
  745. define_feature <<-FEATURE
  746. Feature: Banana party
  747. Scenario: many monkeys eat many things
  748. * there are bananas and apples
  749. * other monkeys are around
  750. When one monkey eats a banana
  751. * the other monkeys eat all the apples
  752. Then bananas remain
  753. * there are no apples left
  754. FEATURE
  755. it "replaces the first step with 'Given'" do
  756. expect(@out.string).to include("Given('there are bananas and apples')")
  757. end
  758. it "uses actual keywords as the 'previous' keyword for future replacements" do
  759. expect(@out.string).to include("Given('other monkeys are around')")
  760. expect(@out.string).to include("When('the other monkeys eat all the apples')")
  761. expect(@out.string).to include("Then('there are no apples left')")
  762. end
  763. end
  764. describe "With a scenario where the only undefined step uses 'And'" do
  765. define_feature <<-FEATURE
  766. Feature:
  767. Scenario:
  768. Given this step passes
  769. Then this step passes
  770. And this step is undefined
  771. FEATURE
  772. define_steps do
  773. Given('this step passes') {}
  774. end
  775. it 'uses actual keyword of the previous passing step for the undefined step' do
  776. expect(@out.string).to include("Then('this step is undefined')")
  777. end
  778. end
  779. describe "With scenarios where the first step is undefined and uses '*'" do
  780. define_feature <<-FEATURE
  781. Feature:
  782. Scenario:
  783. * this step is undefined
  784. Then this step passes
  785. Scenario:
  786. * this step is also undefined
  787. Then this step passes
  788. FEATURE
  789. define_steps do
  790. Given('this step passes') {}
  791. end
  792. it "uses 'Given' as actual keyword the step in each scenario" do
  793. expect(@out.string).to include("Given('this step is undefined')")
  794. expect(@out.string).to include("Given('this step is also undefined')")
  795. end
  796. end
  797. describe 'with a scenario in en-lol' do
  798. define_feature <<-FEATURE
  799. # language: en-lol
  800. OH HAI: STUFFING
  801. MISHUN: CUCUMBR
  802. I CAN HAZ IN TEH BEGINNIN CUCUMBRZ
  803. AN I EAT CUCUMBRZ
  804. FEATURE
  805. it 'uses actual keyword of the previous passing step for the undefined step' do
  806. expect(@out.string).to include("ICANHAZ('I EAT CUCUMBRZ')")
  807. end
  808. end
  809. end
  810. end
  811. end
  812. end

No Description

Contributors (1)