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.

progress_spec.rb 4.4 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. require 'cucumber/formatter/spec_helper'
  4. require 'cucumber/formatter/progress'
  5. require 'cucumber/cli/options'
  6. module Cucumber
  7. module Formatter
  8. describe Progress do
  9. extend SpecHelperDsl
  10. include SpecHelper
  11. before(:each) do
  12. Cucumber::Term::ANSIColor.coloring = false
  13. @out = StringIO.new
  14. @formatter = Progress.new(actual_runtime.configuration.with_options(out_stream: @out))
  15. end
  16. describe 'given a single feature' do
  17. before(:each) do
  18. run_defined_feature
  19. end
  20. describe 'with a scenario' do
  21. define_feature <<-FEATURE
  22. Feature: Banana party
  23. Scenario: Monkey eats banana
  24. Given there are bananas
  25. FEATURE
  26. it 'outputs the undefined step' do
  27. expect(@out.string).to include "U\n"
  28. end
  29. end
  30. describe 'with a background' do
  31. define_feature <<-FEATURE
  32. Feature: Banana party
  33. Background:
  34. Given a tree
  35. Scenario: Monkey eats banana
  36. Given there are bananas
  37. FEATURE
  38. it 'outputs the two undefined steps' do
  39. expect(@out.string).to include "UU\n"
  40. end
  41. end
  42. describe 'with a scenario outline' do
  43. define_feature <<-FEATURE
  44. Feature: Fud Pyramid
  45. Scenario Outline: Monkey eats a balanced diet
  46. Given there are <Things>
  47. Examples: Fruit
  48. | Things |
  49. | apples |
  50. | bananas |
  51. Examples: Vegetables
  52. | Things |
  53. | broccoli |
  54. | carrots |
  55. FEATURE
  56. it 'outputs each undefined step' do
  57. expect(@out.string).to include "UUUU\n"
  58. end
  59. it 'has 4 undefined scenarios' do
  60. expect(@out.string).to include '4 scenarios (4 undefined)'
  61. end
  62. it 'has 4 undefined steps' do
  63. expect(@out.string).to include '4 steps (4 undefined)'
  64. end
  65. end
  66. describe 'with hooks' do
  67. describe 'all hook passes' do
  68. define_feature <<-FEATURE
  69. Feature:
  70. Scenario:
  71. Given this step passes
  72. FEATURE
  73. define_steps do
  74. Before do
  75. end
  76. AfterStep do
  77. end
  78. After do
  79. end
  80. Given(/^this step passes$/) {}
  81. end
  82. it 'only steps generate output' do
  83. lines = <<-OUTPUT
  84. .
  85. 1 scenario (1 passed)
  86. 1 step (1 passed)
  87. OUTPUT
  88. lines.split("\n").each do |line|
  89. expect(@out.string).to include line.strip
  90. end
  91. end
  92. end
  93. describe 'with a failing before hook' do
  94. define_feature <<-FEATURE
  95. Feature:
  96. Scenario:
  97. Given this step passes
  98. FEATURE
  99. define_steps do
  100. Before do
  101. raise 'hook failed'
  102. end
  103. Given(/^this step passes$/) {}
  104. end
  105. it 'the failing hook generate output' do
  106. lines = <<-OUTPUT
  107. F-
  108. 1 scenario (1 failed)
  109. 1 step (1 skipped)
  110. OUTPUT
  111. lines.split("\n").each do |line|
  112. expect(@out.string).to include line.strip
  113. end
  114. end
  115. end
  116. describe 'with a failing after hook' do
  117. define_feature <<-FEATURE
  118. Feature:
  119. Scenario:
  120. Given this step passes
  121. FEATURE
  122. define_steps do
  123. After do
  124. raise 'hook failed'
  125. end
  126. Given(/^this step passes$/) {}
  127. end
  128. it 'the failing hook generate output' do
  129. lines = <<-OUTPUT
  130. .F
  131. 1 scenario (1 failed)
  132. 1 step (1 passed)
  133. OUTPUT
  134. lines.split("\n").each do |line|
  135. expect(@out.string).to include line.strip
  136. end
  137. end
  138. end
  139. end
  140. end
  141. end
  142. end
  143. end

No Description

Contributors (1)