jeffrafter-cucumber 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. data/History.txt +262 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +241 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +8 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +6 -0
  8. data/config/hoe.rb +69 -0
  9. data/config/requirements.rb +15 -0
  10. data/cucumber.yml +1 -0
  11. data/examples/calculator_ruby_features/Rakefile +6 -0
  12. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  13. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
  14. data/examples/cs/README.textile +22 -0
  15. data/examples/cs/Rakefile +12 -0
  16. data/examples/cs/features/hello.feature +11 -0
  17. data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
  18. data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
  19. data/examples/cs/features/tree.feature +9 -0
  20. data/examples/cs/src/Hello.cs +18 -0
  21. data/examples/dos_line_endings/Rakefile +6 -0
  22. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  23. data/examples/i18n/README.textile +18 -0
  24. data/examples/i18n/Rakefile +16 -0
  25. data/examples/i18n/ar/Rakefile +6 -0
  26. data/examples/i18n/ar/features/addition.feature +17 -0
  27. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +32 -0
  28. data/examples/i18n/ar/lib/calculator.rb +10 -0
  29. data/examples/i18n/da/Rakefile +6 -0
  30. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
  31. data/examples/i18n/da/features/summering.feature +17 -0
  32. data/examples/i18n/da/lib/kalkulator.rb +11 -0
  33. data/examples/i18n/de/Rakefile +6 -0
  34. data/examples/i18n/de/features/addition.feature +17 -0
  35. data/examples/i18n/de/features/division.feature +10 -0
  36. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +30 -0
  37. data/examples/i18n/de/lib/calculator.rb +14 -0
  38. data/examples/i18n/en/Rakefile +6 -0
  39. data/examples/i18n/en/features/addition.feature +17 -0
  40. data/examples/i18n/en/features/division.feature +10 -0
  41. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
  42. data/examples/i18n/en/lib/calculator.rb +14 -0
  43. data/examples/i18n/es/Rakefile +6 -0
  44. data/examples/i18n/es/features/adicion.feature +17 -0
  45. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
  46. data/examples/i18n/es/lib/calculador.rb +11 -0
  47. data/examples/i18n/et/Rakefile +6 -0
  48. data/examples/i18n/et/features/liitmine.feature +17 -0
  49. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
  50. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  51. data/examples/i18n/fr/Rakefile +6 -0
  52. data/examples/i18n/fr/features/addition.feature +13 -0
  53. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
  54. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  55. data/examples/i18n/id/Rakefile +6 -0
  56. data/examples/i18n/id/features/addition.feature +17 -0
  57. data/examples/i18n/id/features/division.feature +10 -0
  58. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
  59. data/examples/i18n/id/lib/calculator.rb +14 -0
  60. data/examples/i18n/it/Rakefile +6 -0
  61. data/examples/i18n/it/features/somma.feature +10 -0
  62. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
  63. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  64. data/examples/i18n/ja/README.txt +5 -0
  65. data/examples/i18n/ja/Rakefile +6 -0
  66. data/examples/i18n/ja/features/addition.feature +17 -0
  67. data/examples/i18n/ja/features/division.feature +10 -0
  68. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
  69. data/examples/i18n/ja/lib/calculator.rb +14 -0
  70. data/examples/i18n/lt/Rakefile +6 -0
  71. data/examples/i18n/lt/features/addition.feature +17 -0
  72. data/examples/i18n/lt/features/division.feature +10 -0
  73. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +31 -0
  74. data/examples/i18n/lt/lib/calculator.rb +14 -0
  75. data/examples/i18n/no/Rakefile +6 -0
  76. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
  77. data/examples/i18n/no/features/summering.feature +17 -0
  78. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  79. data/examples/i18n/pt/Rakefile +6 -0
  80. data/examples/i18n/pt/features/adicao.feature +10 -0
  81. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
  82. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  83. data/examples/i18n/ro/Rakefile +6 -0
  84. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
  85. data/examples/i18n/ro/features/suma.feature +10 -0
  86. data/examples/i18n/ro/lib/calculator.rb +11 -0
  87. data/examples/i18n/se/Rakefile +6 -0
  88. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
  89. data/examples/i18n/se/features/summering.feature +17 -0
  90. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  91. data/examples/i18n/zh-CN/Rakefile +6 -0
  92. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  93. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
  94. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  95. data/examples/java/README.textile +22 -0
  96. data/examples/java/Rakefile +12 -0
  97. data/examples/java/features/hello.feature +11 -0
  98. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  99. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  100. data/examples/java/features/tree.feature +9 -0
  101. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  102. data/examples/selenium/Rakefile +6 -0
  103. data/examples/selenium/features/search.feature +9 -0
  104. data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
  105. data/examples/test_unit/Rakefile +6 -0
  106. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
  107. data/examples/test_unit/features/test_unit.feature +9 -0
  108. data/examples/tickets/Rakefile +11 -0
  109. data/examples/tickets/cucumber.yml +2 -0
  110. data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
  111. data/examples/tickets/features/tickets.feature +24 -0
  112. data/examples/watir/Rakefile +6 -0
  113. data/examples/watir/features/search.feature +9 -0
  114. data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
  115. data/features/see_features.feature +8 -0
  116. data/features/steps/features_steps.rb +9 -0
  117. data/gem_tasks/deployment.rake +34 -0
  118. data/gem_tasks/environment.rake +7 -0
  119. data/gem_tasks/features.rake +6 -0
  120. data/gem_tasks/fix_cr_lf.rake +10 -0
  121. data/gem_tasks/flog.rake +4 -0
  122. data/gem_tasks/gemspec.rake +6 -0
  123. data/gem_tasks/rspec.rake +35 -0
  124. data/gem_tasks/treetop.rake +41 -0
  125. data/lib/autotest/cucumber.rb +6 -0
  126. data/lib/autotest/cucumber_mixin.rb +109 -0
  127. data/lib/autotest/cucumber_rails.rb +6 -0
  128. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  129. data/lib/autotest/cucumber_rspec.rb +6 -0
  130. data/lib/autotest/discover.rb +9 -0
  131. data/lib/cucumber/broadcaster.rb +20 -0
  132. data/lib/cucumber/cli.rb +303 -0
  133. data/lib/cucumber/core_ext/proc.rb +69 -0
  134. data/lib/cucumber/core_ext/string.rb +28 -0
  135. data/lib/cucumber/executor.rb +190 -0
  136. data/lib/cucumber/formatters/ansicolor.rb +109 -0
  137. data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
  138. data/lib/cucumber/formatters/cucumber.css +132 -0
  139. data/lib/cucumber/formatters/cucumber.js +11 -0
  140. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  141. data/lib/cucumber/formatters/jquery.js +32 -0
  142. data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
  143. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  144. data/lib/cucumber/formatters/progress_formatter.rb +58 -0
  145. data/lib/cucumber/formatters.rb +1 -0
  146. data/lib/cucumber/languages.yml +258 -0
  147. data/lib/cucumber/model/table.rb +28 -0
  148. data/lib/cucumber/model.rb +1 -0
  149. data/lib/cucumber/platform.rb +12 -0
  150. data/lib/cucumber/rails/rspec.rb +12 -0
  151. data/lib/cucumber/rails/world.rb +73 -0
  152. data/lib/cucumber/rake/task.rb +101 -0
  153. data/lib/cucumber/step_methods.rb +49 -0
  154. data/lib/cucumber/step_mother.rb +95 -0
  155. data/lib/cucumber/tree/feature.rb +63 -0
  156. data/lib/cucumber/tree/features.rb +21 -0
  157. data/lib/cucumber/tree/given_scenario.rb +13 -0
  158. data/lib/cucumber/tree/scenario.rb +174 -0
  159. data/lib/cucumber/tree/step.rb +134 -0
  160. data/lib/cucumber/tree/table.rb +26 -0
  161. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  162. data/lib/cucumber/tree.rb +18 -0
  163. data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
  164. data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
  165. data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
  166. data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
  167. data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
  168. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
  169. data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
  170. data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
  171. data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
  172. data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
  173. data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
  174. data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
  175. data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
  176. data/lib/cucumber/treetop_parser/feature_lt.rb +1591 -0
  177. data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
  178. data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
  179. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  180. data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
  181. data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
  182. data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
  183. data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
  184. data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
  185. data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
  186. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
  187. data/lib/cucumber/version.rb +9 -0
  188. data/lib/cucumber.rb +38 -0
  189. data/rails_generators/cucumber/USAGE +11 -0
  190. data/rails_generators/cucumber/cucumber_generator.rb +30 -0
  191. data/rails_generators/cucumber/templates/cucumber +7 -0
  192. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  193. data/rails_generators/cucumber/templates/env.rb +8 -0
  194. data/rails_generators/cucumber/templates/webrat_steps.rb +95 -0
  195. data/rails_generators/feature/USAGE +12 -0
  196. data/rails_generators/feature/feature_generator.rb +16 -0
  197. data/rails_generators/feature/templates/feature.erb +28 -0
  198. data/rails_generators/feature/templates/steps.erb +22 -0
  199. data/script/console +10 -0
  200. data/script/console.cmd +1 -0
  201. data/script/destroy +14 -0
  202. data/script/destroy.cmd +1 -0
  203. data/script/generate +14 -0
  204. data/script/generate.cmd +1 -0
  205. data/script/txt2html +74 -0
  206. data/script/txt2html.cmd +1 -0
  207. data/setup.rb +1585 -0
  208. data/spec/cucumber/broadcaster_spec.rb +27 -0
  209. data/spec/cucumber/cli_spec.rb +412 -0
  210. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  211. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  212. data/spec/cucumber/executor_spec.rb +298 -0
  213. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  214. data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
  215. data/spec/cucumber/formatters/features.html +269 -0
  216. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  217. data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
  218. data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
  219. data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
  220. data/spec/cucumber/model/table_spec.rb +20 -0
  221. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  222. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  223. data/spec/cucumber/rails/world_spec.rb +11 -0
  224. data/spec/cucumber/sell_cucumbers.feature +19 -0
  225. data/spec/cucumber/step_mother_spec.rb +74 -0
  226. data/spec/cucumber/tree/feature_spec.rb +43 -0
  227. data/spec/cucumber/tree/row_scenario_spec.rb +55 -0
  228. data/spec/cucumber/tree/scenario_spec.rb +76 -0
  229. data/spec/cucumber/tree/step_spec.rb +50 -0
  230. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  231. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  232. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
  233. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  234. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  235. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  236. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  237. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  238. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  239. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  240. data/spec/spec.opts +2 -0
  241. data/spec/spec_helper.rb +20 -0
  242. metadata +335 -0
@@ -0,0 +1,298 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'stringio'
3
+
4
+ module Cucumber
5
+ describe Executor do
6
+
7
+ def mock_scenario(stubs = {})
8
+ @scenario ||= stub("scenario", {
9
+ :row? => false,
10
+ :name => 'test',
11
+ :accept => nil,
12
+ :steps => [],
13
+ :pending? => true
14
+ }.merge(stubs))
15
+ end
16
+
17
+ before do # TODO: Way more setup and duplication of lib code. Use lib code!
18
+ @io = StringIO.new
19
+ @step_mother = StepMother.new
20
+ @executor = Executor.new(@step_mother)
21
+ @formatters = Broadcaster.new [Formatters::ProgressFormatter.new(@io)]
22
+ @executor.formatters = @formatters
23
+ @feature_file = File.dirname(__FILE__) + '/sell_cucumbers.feature'
24
+ @parser = TreetopParser::FeatureParser.new
25
+ @features = Tree::Features.new
26
+ @feature = @parser.parse_feature(@feature_file)
27
+ @features << @feature
28
+ end
29
+
30
+ it "should pass when blocks are ok" do
31
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) { |n| @n = n.to_i }
32
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) { |n| @n -= n.to_i }
33
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) { |n| @n.should == -n.to_i }
34
+ @executor.visit_features(@features)
35
+ @formatters.dump
36
+
37
+ @io.string.should =~ (/\.+\n+/)
38
+ end
39
+
40
+ it "should print filtered backtrace with feature line" do
41
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) { |n| @n = n }
42
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) { |n| @n = n }
43
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) { |n| raise "dang" }
44
+ @executor.visit_features(@features)
45
+ @io.string.should include(%{Failed:
46
+
47
+ 1)
48
+ dang
49
+ #{__FILE__}:43:in `Then /I should owe (\\d*) cucumbers/'
50
+ #{@feature_file}:9:in `Then I should owe 7 cucumbers'
51
+ })
52
+ end
53
+
54
+ describe "creating a world" do
55
+ module DoitExtension
56
+ def doit
57
+ "dunit"
58
+ end
59
+ end
60
+
61
+ module BeatitExtension
62
+ def beatit
63
+ "beatenit"
64
+ end
65
+ end
66
+
67
+ it "should yield an Object to the world proc" do
68
+ @executor.register_world_proc do |world|
69
+ world.extend(DoitExtension)
70
+ end
71
+ @executor.register_world_proc do |world|
72
+ world.extend(BeatitExtension)
73
+ end
74
+ world = @executor.create_world
75
+ world.doit.should == "dunit"
76
+ world.beatit.should == "beatenit"
77
+ end
78
+ end
79
+
80
+ describe "visiting feature" do
81
+
82
+ it "should set the feature file being visited" do
83
+ mock_feature = mock('feature', :file => 'womble.feature', :scenarios => [])
84
+ @executor.visit_feature(mock_feature)
85
+
86
+ @executor.instance_variable_get('@feature_file').should == 'womble.feature'
87
+ end
88
+
89
+ end
90
+
91
+ describe "visiting steps" do
92
+ def make_regex(a,b,c)
93
+ exp = "#{a}.*#{b}.*#{c}"
94
+ Regexp.compile(exp)
95
+ end
96
+
97
+ it "should report multiple definitions as an error" do
98
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {|n|}
99
+ @step_mother.register_step_proc(/there (.*) (\d*) cucumbers/) {|n|}
100
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n|}
101
+ @executor.visit_features(@features)
102
+ @io.string.should =~ make_regex('F','_','P')
103
+ end
104
+
105
+ it "should report subsequent multiple definitions as an skipped" do
106
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {|n|}
107
+ @step_mother.register_step_proc(/there (.*) (\d*) cucumbers/) {|n|}
108
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n|}
109
+ @step_mother.register_step_proc(/I sell (\d*) (.*)/) {|n|}
110
+ @executor.visit_features(@features)
111
+ @io.string.should =~ make_regex('F','_','P')
112
+ end
113
+
114
+ it "should report pending steps after failures" do
115
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {|n|}
116
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n| raise "oops"}
117
+ @executor.visit_features(@features)
118
+ @io.string.should =~ make_regex('\.','F','P')
119
+ end
120
+
121
+ it "should skip passing steps after failures" do
122
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {|n|}
123
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n| raise "oops"}
124
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) {|n|}
125
+ @executor.visit_features(@features)
126
+ @io.string.should =~ make_regex('\.','F','_')
127
+ end
128
+
129
+ it "should skip failing steps after failures" do
130
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {|n|}
131
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n| raise "oops"}
132
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) {|n| raise "oops again"}
133
+ @executor.visit_features(@features)
134
+ @io.string.should =~ make_regex('\.','F','_')
135
+ end
136
+
137
+
138
+ it "should report pending steps after pending" do
139
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n|}
140
+ @executor.visit_features(@features)
141
+ @io.string.should =~ make_regex('P','_','P')
142
+ end
143
+
144
+ it "should skip passing steps after pending" do
145
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n|}
146
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) {|n|}
147
+ @executor.visit_features(@features)
148
+ @io.string.should =~ make_regex('P','_','_')
149
+ end
150
+
151
+ it "should skip failing steps after pending" do
152
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) {|n| raise "oops"}
153
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) {|n| raise "oops again"}
154
+ @executor.visit_features(@features)
155
+ @io.string.should =~ make_regex('P','_','_')
156
+ end
157
+
158
+ it "should report an ArityMismatchError" do
159
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) {}
160
+ @executor.visit_features(@features)
161
+ @io.string.should =~ /expected 0 block argument\(s\), got 1/m
162
+ end
163
+
164
+ end
165
+
166
+ describe "visiting row scenarios" do
167
+
168
+ def mock_row_scenario(stubs = {})
169
+ @row_scenario ||= stub("row scenario", {
170
+ :row? => true,
171
+ :name => 'test',
172
+ :update_table_column_widths => nil,
173
+ :steps => [],
174
+ :pending? => true
175
+ }.merge(stubs))
176
+ end
177
+
178
+ describe "without having first run the matching regular scenario" do
179
+
180
+ before(:each) do
181
+ @regular_scenario = Tree::Scenario.new(nil, 'test', 1)
182
+ @executor.lines_for_features = Hash.new([5])
183
+ @executor.visit_regular_scenario(@regular_scenario)
184
+ end
185
+
186
+ it "should run the regular scenario before the row scenario" do
187
+ @regular_scenario.should_receive(:accept)
188
+ row_scenario = mock_row_scenario(:name => 'test', :at_line? => true)
189
+ row_scenario.should_receive(:accept)
190
+ @executor.visit_row_scenario(row_scenario)
191
+ end
192
+
193
+ it "should run the row scenario after running the regular scenario" do
194
+ row_scenario = mock_row_scenario(:at_line? => true)
195
+ row_scenario.should_receive(:accept)
196
+ @executor.visit_row_scenario(row_scenario)
197
+ end
198
+
199
+ end
200
+
201
+ describe "having run matching regular scenario" do
202
+
203
+ it "should not run the regular scenario if it has already run" do
204
+ scenario = Tree::Scenario.new(nil, 'test', 1)
205
+ @executor.visit_regular_scenario(scenario)
206
+
207
+ scenario.should_not_receive(:accept)
208
+
209
+ @executor.visit_row_scenario(mock_row_scenario(:name => 'test', :at_line? => true, :accept => nil))
210
+ end
211
+
212
+ end
213
+ end
214
+
215
+ describe "visiting scenarios" do
216
+
217
+ it "should check if a scenario is at the specified line number" do
218
+ mock_scenario = mock('scenario', :null_object => true)
219
+ @executor.lines_for_features = Hash.new([1])
220
+
221
+ mock_scenario.should_receive(:at_line?).with(1)
222
+
223
+ @executor.visit_scenario(mock_scenario)
224
+ end
225
+
226
+ describe "with specific features and lines" do
227
+
228
+ it "should check if a scenario is at the specified feature line number" do
229
+ @executor.instance_variable_set('@feature_file', 'sell_cucumbers.feature')
230
+ @executor.lines_for_features = {'sell_cucumbers.feature' => [11]}
231
+
232
+ mock_scenario.should_receive(:at_line?).with(11).and_return(false)
233
+
234
+ @executor.visit_scenario(mock_scenario)
235
+ end
236
+
237
+ it "should not check feature line numbers if --line is already set" do
238
+ @executor.instance_variable_set('@feature_file', 'sell_cucumbers.feature')
239
+ @executor.lines_for_features = {'sell_cucumbers.feature' => [11]}
240
+ @executor.lines_for_features = Hash.new([5])
241
+
242
+ mock_scenario.should_not_receive(:at_line?).with(11).and_return(false)
243
+
244
+ @executor.visit_scenario(mock_scenario)
245
+ end
246
+
247
+ it "should not check feature line numbers if the current feature file does not have lines specified" do
248
+ @executor.instance_variable_set('@feature_file', 'beetlejuice.feature')
249
+ @executor.lines_for_features = {'sell_cucumbers.feature' => [11]}
250
+
251
+ mock_scenario.should_not_receive(:at_line?).with(11).and_return(false)
252
+
253
+ @executor.visit_scenario(mock_scenario)
254
+ end
255
+
256
+ end
257
+
258
+ end
259
+
260
+ describe "caching visited scenarios" do
261
+
262
+ it "should reset cache after each feature visit" do
263
+ Tree::Scenario.stub!(:new).and_return(mock_scenario)
264
+
265
+ feature = Tree::Feature.new(nil)
266
+ feature.add_scenario(nil, nil)
267
+
268
+ @executor.visit_feature(feature)
269
+
270
+ @executor.instance_variable_get("@regular_scenario_cache").should == {}
271
+ @executor.instance_variable_get("@executed_scenarios").should == {}
272
+ end
273
+
274
+ end
275
+
276
+ describe "with specified scenarios" do
277
+ it "should only visit the specified scenarios" do
278
+ $amounts_sold = []
279
+
280
+ @step_mother.register_step_proc(/there are (\d*) cucumbers/) { |n| }
281
+ @step_mother.register_step_proc(/I should owe (\d*) cucumbers/) { |n| }
282
+ @step_mother.register_step_proc(/I sell (\d*) cucumbers/) { |n| $amounts_sold << n.to_i }
283
+
284
+ @executor.scenario_names = ["Sell a dozen", "Sell fifty"]
285
+ @executor.visit_features(@features)
286
+
287
+ $amounts_sold.should == [12, 50]
288
+ end
289
+
290
+ it "should only visit features with specified scenarios" do
291
+ @executor.scenario_names = ["Jump up and down"]
292
+ @feature.should_not_receive(:accept).with(@executor)
293
+ @executor.visit_features(@features)
294
+ end
295
+ end
296
+
297
+ end
298
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'cucumber/formatters/ansicolor'
3
+
4
+ module Cucumber
5
+ module Formatters
6
+ describe ANSIColor do
7
+ include ANSIColor
8
+
9
+ before do
10
+ ::Term::ANSIColor.coloring = true
11
+ end
12
+
13
+ after do
14
+ ::Term::ANSIColor.coloring = false
15
+ end
16
+
17
+ it "should wrap string in bold green for #passed with string arg" do
18
+ passed("foo").should == "\e[0m\e[1m\e[32mfoo\e[0m\e[0m"
19
+ end
20
+
21
+ it "should return bold green without wrapping for #passed without arg" do
22
+ passed.should == "\e[0m\e[1m\e[32m"
23
+ end
24
+
25
+ it "should return grey for #comment" do
26
+ comment("foo").should == "\e[0m\e[90mfoo\e[0m"
27
+ end
28
+
29
+ it "should not generate ansi codes when colors are disabled" do
30
+ ::Term::ANSIColor.coloring = false
31
+ passed("foo").should == "foo"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ module Cucumber::Formatters
4
+ describe AutotestFormatter do
5
+ before(:each) do
6
+ @io = StringIO.new
7
+ @formatter = AutotestFormatter.new @io
8
+ @scenario = mock('scenario', :name => "Doing tricky things")
9
+ @step = mock('step', :scenario => @scenario)
10
+ end
11
+
12
+ %w{failed skipped pending}.each do |didnt_pass|
13
+ it "should print a scenario's name when it has a #{didnt_pass} step" do
14
+ @formatter.send("step_#{didnt_pass}".to_sym, @step, mock('regexp'), mock('args'))
15
+ @io.string.should == "Doing tricky things\n"
16
+ end
17
+ end
18
+
19
+ it "should not print the same scenario's name twice" do
20
+ another_step = mock('another step', :scenario => @scenario)
21
+ @formatter.send("step_failed".to_sym, @step, mock('regexp'), mock('args'))
22
+ @formatter.send("step_skipped".to_sym, another_step, mock('regexp'), mock('args'))
23
+ @io.string.should == "Doing tricky things\n"
24
+ end
25
+ end
26
+ end