aslakhellesoy-cucumber 0.1.16.4 → 0.1.16.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/History.txt +75 -1
  2. data/Manifest.txt +58 -65
  3. data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
  4. data/examples/i18n/Rakefile +3 -3
  5. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -6
  6. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
  7. data/examples/i18n/de/features/addition.feature +6 -6
  8. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -2
  9. data/examples/i18n/en/features/addition.feature +6 -6
  10. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -2
  11. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +1 -1
  12. data/examples/i18n/et/features/liitmine.feature +7 -6
  13. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
  14. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
  15. data/examples/i18n/fi/features/yhteenlasku.feature +2 -2
  16. data/examples/i18n/fr/features/addition.feature +2 -2
  17. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
  18. data/examples/i18n/id/features/addition.feature +6 -6
  19. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -2
  20. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
  21. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -3
  22. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
  23. data/examples/i18n/lt/features/addition.feature +7 -6
  24. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -2
  25. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +7 -7
  26. data/examples/i18n/no/features/summering.feature +1 -0
  27. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
  28. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
  29. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
  30. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
  31. data/examples/jbehave/README.textile +17 -0
  32. data/examples/jbehave/features/support/env.rb +7 -0
  33. data/examples/jbehave/features/trading.feature +24 -0
  34. data/examples/jbehave/pom.xml +48 -0
  35. data/examples/self_test/README.textile +4 -1
  36. data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
  37. data/examples/self_test/features/lots_of_undefined.feature +8 -0
  38. data/examples/self_test/features/outline_sample.feature +8 -5
  39. data/examples/self_test/features/sample.feature +5 -3
  40. data/examples/self_test/features/step_definitions/sample_steps.rb +15 -3
  41. data/features/cucumber_cli.feature +199 -97
  42. data/features/cucumber_cli_outlines.feature +46 -38
  43. data/features/report_called_undefined_steps.feature +31 -0
  44. data/features/step_definitions/cucumber_steps.rb +7 -3
  45. data/features/step_definitions/extra_steps.rb +1 -1
  46. data/features/support/env.rb +1 -1
  47. data/gem_tasks/features.rake +1 -1
  48. data/gem_tasks/flog.rake +1 -1
  49. data/lib/autotest/cucumber_mixin.rb +16 -23
  50. data/lib/cucumber/ast/comment.rb +26 -0
  51. data/lib/cucumber/ast/examples.rb +22 -0
  52. data/lib/cucumber/ast/feature.rb +60 -0
  53. data/lib/cucumber/ast/features.rb +39 -0
  54. data/lib/cucumber/ast/filter.rb +22 -0
  55. data/lib/cucumber/ast/outline_table.rb +49 -0
  56. data/lib/cucumber/ast/py_string.rb +52 -0
  57. data/lib/cucumber/ast/scenario.rb +91 -0
  58. data/lib/cucumber/ast/scenario_outline.rb +83 -0
  59. data/lib/cucumber/ast/step.rb +130 -0
  60. data/lib/cucumber/ast/table.rb +214 -0
  61. data/lib/cucumber/ast/tags.rb +33 -0
  62. data/lib/cucumber/ast/visitor.rb +93 -0
  63. data/lib/cucumber/ast.rb +27 -0
  64. data/lib/cucumber/broadcaster.rb +1 -6
  65. data/lib/cucumber/cli.rb +178 -128
  66. data/lib/cucumber/core_ext/exception.rb +41 -8
  67. data/lib/cucumber/core_ext/instance_exec.rb +54 -0
  68. data/lib/cucumber/core_ext/proc.rb +29 -65
  69. data/lib/cucumber/core_ext/string.rb +19 -0
  70. data/lib/cucumber/{formatters → formatter}/ansicolor.rb +11 -10
  71. data/lib/cucumber/formatter/console.rb +116 -0
  72. data/lib/cucumber/formatter/pretty.rb +158 -0
  73. data/lib/cucumber/formatter/profile.rb +77 -0
  74. data/lib/cucumber/formatter/progress.rb +68 -0
  75. data/lib/cucumber/formatter.rb +1 -0
  76. data/lib/cucumber/formatters/autotest_formatter.rb +0 -2
  77. data/lib/cucumber/formatters/html_formatter.rb +4 -3
  78. data/lib/cucumber/formatters/pretty_formatter.rb +1 -1
  79. data/lib/cucumber/formatters/unicode.rb +3 -3
  80. data/lib/cucumber/jbehave.rb +104 -0
  81. data/lib/cucumber/languages.yml +100 -73
  82. data/lib/cucumber/parser/basic.rb +0 -0
  83. data/lib/cucumber/parser/feature.rb +1694 -0
  84. data/lib/cucumber/parser/feature.tt +206 -0
  85. data/lib/cucumber/parser/file_parser.rb +50 -0
  86. data/lib/cucumber/parser/i18n.tt +26 -0
  87. data/lib/cucumber/parser/treetop_ext.rb +9 -0
  88. data/lib/cucumber/parser.rb +27 -0
  89. data/lib/cucumber/platform.rb +3 -17
  90. data/lib/cucumber/step_definition.rb +83 -0
  91. data/lib/cucumber/step_mother.rb +128 -72
  92. data/lib/cucumber/version.rb +1 -1
  93. data/lib/cucumber.rb +56 -9
  94. data/spec/cucumber/ast/feature_factory.rb +54 -0
  95. data/spec/cucumber/ast/feature_spec.rb +60 -0
  96. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  97. data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
  98. data/spec/cucumber/ast/scenario_spec.rb +82 -0
  99. data/spec/cucumber/ast/step_spec.rb +45 -0
  100. data/spec/cucumber/ast/table_spec.rb +81 -0
  101. data/spec/cucumber/broadcaster_spec.rb +4 -17
  102. data/spec/cucumber/cli_spec.rb +43 -148
  103. data/spec/cucumber/core_ext/proc_spec.rb +27 -35
  104. data/spec/cucumber/core_ext/string_spec.rb +8 -0
  105. data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
  106. data/spec/cucumber/formatter/html/cucumber.css +37 -0
  107. data/spec/cucumber/formatter/html/cucumber.js +11 -0
  108. data/spec/cucumber/formatter/html/index.html +45 -0
  109. data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
  110. data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
  111. data/spec/cucumber/formatters/autotest_formatter_spec.rb +1 -0
  112. data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
  113. data/spec/cucumber/parser/feature_parser_spec.rb +247 -0
  114. data/spec/cucumber/parser/table_parser_spec.rb +48 -0
  115. data/spec/cucumber/step_definition_spec.rb +62 -0
  116. data/spec/cucumber/step_mom_spec.rb +49 -0
  117. data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
  118. data/spec/cucumber/treetop_parser/spaces.feature +3 -1
  119. data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
  120. data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
  121. data/spec/cucumber/world/pending_spec.rb +13 -12
  122. data/spec/spec_helper.rb +1 -1
  123. metadata +59 -67
  124. data/examples/calculator_ruby_features/Rakefile +0 -6
  125. data/examples/calculator_ruby_features/features/addition.rb +0 -39
  126. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
  127. data/gem_tasks/treetop.rake +0 -41
  128. data/lib/cucumber/executor.rb +0 -205
  129. data/lib/cucumber/formatters/profile_formatter.rb +0 -92
  130. data/lib/cucumber/formatters/progress_formatter.rb +0 -61
  131. data/lib/cucumber/formatters.rb +0 -1
  132. data/lib/cucumber/model/table.rb +0 -32
  133. data/lib/cucumber/model.rb +0 -1
  134. data/lib/cucumber/step_methods.rb +0 -49
  135. data/lib/cucumber/tree/feature.rb +0 -105
  136. data/lib/cucumber/tree/features.rb +0 -21
  137. data/lib/cucumber/tree/given_scenario.rb +0 -13
  138. data/lib/cucumber/tree/scenario.rb +0 -240
  139. data/lib/cucumber/tree/step.rb +0 -173
  140. data/lib/cucumber/tree/table.rb +0 -26
  141. data/lib/cucumber/tree/top_down_visitor.rb +0 -23
  142. data/lib/cucumber/tree.rb +0 -16
  143. data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
  144. data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
  145. data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
  146. data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
  147. data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
  148. data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
  149. data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
  150. data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
  151. data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
  152. data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
  153. data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
  154. data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
  155. data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
  156. data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
  157. data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
  158. data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
  159. data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
  160. data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
  161. data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
  162. data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
  163. data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
  164. data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
  165. data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
  166. data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
  167. data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
  168. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
  169. data/lib/cucumber/world/pending.rb +0 -22
  170. data/lib/cucumber/world.rb +0 -1
  171. data/setup.rb +0 -1585
  172. data/spec/cucumber/executor_spec.rb +0 -382
  173. data/spec/cucumber/formatters/html_formatter_spec.rb +0 -104
  174. data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
  175. data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
  176. data/spec/cucumber/model/table_spec.rb +0 -32
  177. data/spec/cucumber/step_mother_spec.rb +0 -74
  178. data/spec/cucumber/tree/feature_spec.rb +0 -122
  179. data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
  180. data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
  181. data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
  182. data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
  183. data/spec/cucumber/tree/scenario_spec.rb +0 -134
  184. data/spec/cucumber/tree/step_outline_spec.rb +0 -17
  185. data/spec/cucumber/tree/step_spec.rb +0 -59
  186. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
@@ -32,7 +32,7 @@ module Cucumber
32
32
  given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
33
33
 
34
34
  cli.parse_options!(%w{--format progress --profile bongo})
35
- cli.options[:formats].should == {'progress' => [STDOUT]}
35
+ cli.options[:formats].should == {'progress' => STDOUT}
36
36
  cli.options[:require].should == ['from/yml']
37
37
  end
38
38
 
@@ -58,7 +58,7 @@ Could not find profile: 'i_do_not_exist'
58
58
  Defined profiles in cucumber.yml:
59
59
  * default
60
60
  * html_report
61
- END_OF_MESSAGE
61
+ END_OF_MESSAGE
62
62
 
63
63
  error.string.should == expected_message
64
64
  end
@@ -121,12 +121,10 @@ Defined profiles in cucumber.yml:
121
121
  end
122
122
 
123
123
  it "should accept --dry-run option" do
124
- cli = CLI.new
124
+ cli = CLI.new(StringIO.new)
125
125
  cli.parse_options!(%w{--dry-run})
126
126
  cli.options[:dry_run].should be_true
127
- mock_executor = mock_executor()
128
- mock_executor.should_receive(:dry_run=).with(true)
129
- cli.execute!(stub('step mother'), mock_executor, mock_features)
127
+ cli.execute!(stub('step mother'))
130
128
  end
131
129
 
132
130
  it "should accept --no-source option" do
@@ -143,12 +141,12 @@ Defined profiles in cucumber.yml:
143
141
  cli.options[:snippets].should be_false
144
142
  end
145
143
 
146
- it "should accept --quiet option" do
144
+ it "should set snippets and source to false with --quiet option" do
147
145
  cli = CLI.new
148
146
  cli.parse_options!(%w{--quiet})
149
147
 
150
- cli.options[:snippets].should be_false
151
- cli.options[:source].should be_false
148
+ cli.options[:snippets].should be_nil
149
+ cli.options[:source].should be_nil
152
150
  end
153
151
 
154
152
  it "should accept --verbose option" do
@@ -165,12 +163,11 @@ Defined profiles in cucumber.yml:
165
163
  cli = CLI.new(StringIO.new)
166
164
  cli.parse_options!(%w{--require /features})
167
165
 
168
- cli.should_receive(:require).twice.with(/treetop_parser/).ordered
169
166
  cli.should_receive(:require).with("/features/support/env.rb").ordered
170
167
  cli.should_receive(:require).with("/features/step_definitions/foo.rb").ordered
171
168
  cli.should_receive(:require).with("spec/expectations/differs/default").ordered
172
169
 
173
- cli.execute!(stub('step mother'), mock_executor, mock_features)
170
+ cli.execute!(stub('step mother'))
174
171
  end
175
172
 
176
173
  describe "verbose mode" do
@@ -179,21 +176,22 @@ Defined profiles in cucumber.yml:
179
176
  @out = StringIO.new
180
177
  @cli = CLI.new(@out)
181
178
  @cli.stub!(:require)
179
+ @empty_feature = Ast::Feature.new(Ast::Comment.new(''), Ast::Tags.new(2, []), "Feature", [])
182
180
  Dir.stub!(:[])
183
181
  end
184
182
 
185
183
  it "should show ruby files required" do
186
184
  @cli.parse_options!(%w{--verbose --require example.rb})
187
- @cli.execute!(stub('step mother'), mock_executor, mock_features)
185
+ @cli.execute!(stub('step mother'))
188
186
 
189
187
  @out.string.should include('example.rb')
190
188
  end
191
189
 
192
190
  it "should show feature files parsed" do
193
- TreetopParser::FeatureParser.stub!(:new).and_return(mock("feature parser", :parse_feature => nil))
191
+ Parser::FeatureParser.stub!(:new).and_return(mock("feature parser", :parse_file => @empty_feature))
194
192
 
195
193
  @cli.parse_options!(%w{--verbose example.feature})
196
- @cli.execute!(stub('step mother'), mock_executor, mock_features)
194
+ @cli.execute!(stub('step mother'))
197
195
 
198
196
  @out.string.should include('example.feature')
199
197
  end
@@ -201,99 +199,47 @@ Defined profiles in cucumber.yml:
201
199
  end
202
200
 
203
201
  it "should accept --out option" do
204
- cli = CLI.new
205
- File.should_receive(:open).with('jalla.txt', 'w')
202
+ cli = CLI.new(StringIO.new)
206
203
  cli.parse_options!(%w{--out jalla.txt})
204
+ cli.options[:formats]['pretty'].should == 'jalla.txt'
207
205
  end
208
206
 
209
207
  it "should accept multiple --out options" do
210
- cli = CLI.new
211
- mock_file1 = stub(File, :open => nil)
212
- mock_file2 = stub(File, :open => nil)
213
- File.stub!(:open).and_return(mock_file1, mock_file2)
214
-
208
+ cli = CLI.new(StringIO.new)
215
209
  cli.parse_options!(%w{--format progress --out file1 --out file2})
216
- cli.options[:formats].should == {'progress' => [mock_file1, mock_file2]}
210
+ cli.options[:formats].should == {'progress' => 'file2'}
217
211
  end
218
212
 
219
213
  it "should accept multiple --format options" do
220
- cli = CLI.new
214
+ cli = CLI.new(StringIO.new)
221
215
  cli.parse_options!(%w{--format pretty --format progress})
222
216
  cli.options[:formats].should have_key('pretty')
223
217
  cli.options[:formats].should have_key('progress')
224
218
  end
225
219
 
226
220
  it "should associate --out to previous --format" do
227
- cli = CLI.new
228
- mock_file1 = stub(File, :open => nil)
229
- mock_file2 = stub(File, :open => nil)
230
- File.stub!(:open).and_return(mock_file1, mock_file2)
231
-
221
+ cli = CLI.new(StringIO.new)
232
222
  cli.parse_options!(%w{--format progress --out file1 --format profile --out file2})
233
- cli.options[:formats].should == {'progress' => [mock_file1], 'profile' => [mock_file2]}
234
- end
235
-
236
- it "should allow a single formatter to have STDOUT and a file" do
237
- cli = CLI.new
238
- mock_file = stub(File, :open => nil)
239
- File.stub!(:open).and_return(mock_file)
240
-
241
- cli.parse_options!(%w{--format progress --format progress --out file})
242
- cli.options[:formats].should == {'progress' => [STDOUT, mock_file]}
223
+ cli.options[:formats].should == {"profile"=>"file2", "progress"=>"file1"}
243
224
  end
244
225
 
245
- it "should register --out files with an output broadcaster" do
246
- cli = CLI.new
247
- mock_file = stub(File)
248
- File.stub!(:open).and_return(mock_file)
249
- mock_output_broadcaster = mock_broadcaster
250
- Broadcaster.stub!(:new).and_return(mock_broadcaster, mock_output_broadcaster)
251
-
252
- mock_output_broadcaster.should_receive(:register).with(mock_file)
253
- cli.parse_options!(%w{--out test.file})
254
-
255
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
256
- end
257
-
258
- it "should register --formatters with the formatter broadcaster" do
259
- cli = CLI.new
260
- mock_progress_formatter = stub(Formatters::ProgressFormatter)
261
- Formatters::ProgressFormatter.stub!(:new).and_return(mock_progress_formatter)
262
- mock_formatter_broadcaster = mock_broadcaster
263
- Broadcaster.stub!(:new).and_return(mock_formatter_broadcaster, mock_broadcaster)
264
-
265
- mock_formatter_broadcaster.should_receive(:register).with(mock_progress_formatter)
266
- cli.parse_options!(%w{--format progress})
267
-
268
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
269
- end
270
-
271
- it "should setup the executor with the formatter broadcaster" do
272
- cli = CLI.new
273
- broadcaster = Broadcaster.new
274
- Broadcaster.stub!(:new).and_return(broadcaster)
275
- mock_executor = mock_executor()
276
- mock_executor.should_receive(:formatters=).with(broadcaster)
277
- cli.parse_options!(%w{--format progress})
278
-
279
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
280
- end
281
-
282
226
  describe "--format with class" do
283
227
 
284
228
  describe "in module" do
285
229
 
286
230
  it "should resolve each module until it gets Formatter class" do
287
- cli = CLI.new
231
+ cli = CLI.new(nil)
288
232
  mock_module = mock('module')
289
233
  cli.parse_options!(%w{--format ZooModule::MonkeyFormatterClass})
290
234
  Object.stub!(:const_defined?).and_return(true)
291
235
  mock_module.stub!(:const_defined?).and_return(true)
292
236
 
237
+ f = stub('formatter', :null_object => true)
238
+
293
239
  Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
294
- mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => nil))
240
+ mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
295
241
 
296
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
242
+ cli.execute!(stub('step mother'))
297
243
  end
298
244
 
299
245
  end
@@ -306,7 +252,7 @@ Defined profiles in cucumber.yml:
306
252
  Object.stub!(:const_defined?).with('magical').and_return(true)
307
253
  end
308
254
 
309
- it "should create the formatter" do
255
+ xit "should create the formatter" do
310
256
  cli = CLI.new
311
257
  mock_formatter = mock('magical formatter')
312
258
  cli.parse_options!(%w{--format magical})
@@ -316,7 +262,7 @@ Defined profiles in cucumber.yml:
316
262
  cli.execute!(stub('step mother'), mock_executor, stub('features'))
317
263
  end
318
264
 
319
- it "should register the formatter with broadcaster" do
265
+ xit "should register the formatter with broadcaster" do
320
266
  cli = CLI.new
321
267
  broadcaster = Broadcaster.new
322
268
  mock_formatter = mock('magical formatter')
@@ -346,15 +292,15 @@ Defined profiles in cucumber.yml:
346
292
  @cli.parse_options!(%w{--format exists_but_evil})
347
293
  end
348
294
 
349
- it "should show exception" do
295
+ xit "should show exception" do
350
296
  Kernel.stub!(:exit)
351
297
 
352
- @cli.execute!(stub('step mother'), mock_executor, stub('features'))
298
+ @cli.execute!(stub('step mother'))
353
299
 
354
300
  @error.string.should include("No such method")
355
301
  end
356
302
 
357
- it "should exit" do
303
+ xit "should exit" do
358
304
  Kernel.should_receive(:exit)
359
305
 
360
306
  @cli.execute!(stub('step mother'), mock_executor, stub('features'))
@@ -372,7 +318,7 @@ Defined profiles in cucumber.yml:
372
318
  @cli.parse_options!(%w{--format invalid})
373
319
  end
374
320
 
375
- it "should display a format error" do
321
+ xit "should display a format error" do
376
322
  Kernel.stub!(:exit)
377
323
 
378
324
  @cli.execute!(stub('step mother'), mock_executor, stub('features'))
@@ -380,15 +326,15 @@ Defined profiles in cucumber.yml:
380
326
  @error.string.should include("Invalid format: invalid\n")
381
327
  end
382
328
 
383
- it "should display --help" do
329
+ xit "should display --help" do
384
330
  Kernel.stub!(:exit)
385
331
 
386
- @cli.execute!(stub('step mother'), mock_executor, stub('features'))
332
+ @cli.execute!(stub('step mother'))
387
333
 
388
334
  @out.string.should include("Usage: cucumber")
389
335
  end
390
336
 
391
- it "should exit" do
337
+ xit "should exit" do
392
338
  Kernel.should_receive(:exit)
393
339
 
394
340
  @cli.execute!(stub('step mother'), mock_executor, stub('features'))
@@ -405,7 +351,7 @@ Defined profiles in cucumber.yml:
405
351
  cli.options[:scenario_names].should include("User signs up")
406
352
  end
407
353
 
408
- it "should register --scenario options with the executor" do
354
+ xit "should register --scenario options with the executor" do
409
355
  cli = CLI.new
410
356
  cli.parse_options!(['--scenario', "User logs in", '--scenario', "User signs up"])
411
357
  executor = mock_executor
@@ -414,35 +360,15 @@ Defined profiles in cucumber.yml:
414
360
  end
415
361
 
416
362
  it "should accept --color option" do
417
- cli = CLI.new
418
- cli.parse_options!(['--color'])
419
- cli.options[:color].should == true
363
+ cli = CLI.new(StringIO.new)
420
364
  Term::ANSIColor.should_receive(:coloring=).with(true)
421
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
365
+ cli.parse_options!(['--color'])
422
366
  end
423
367
 
424
368
  it "should accept --no-color option" do
425
- cli = CLI.new
426
- cli.parse_options!(['--no-color'])
427
- cli.options[:color].should == false
428
- Term::ANSIColor.should_receive(:coloring=).with(false)
429
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
430
- end
431
-
432
- it "should accept --color and --no-color and use the last one" do
433
- cli = CLI.new
434
- cli.parse_options!(['--color', '--no-color'])
435
- cli.options[:color].should == false
369
+ cli = CLI.new(StringIO.new)
436
370
  Term::ANSIColor.should_receive(:coloring=).with(false)
437
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
438
- end
439
-
440
- it "should use a default color setting if no option is given" do
441
- cli = CLI.new
442
- cli.parse_options!(['--'])
443
- cli.options[:color].should == nil
444
- Term::ANSIColor.should_not_receive(:coloring=)
445
- cli.execute!(stub('step mother'), mock_executor, stub('features'))
371
+ cli.parse_options!(['--no-color'])
446
372
  end
447
373
 
448
374
  describe "--backtrace" do
@@ -456,17 +382,17 @@ Defined profiles in cucumber.yml:
456
382
  begin
457
383
  "x".should == "y"
458
384
  rescue => e
459
- e.cucumber_backtrace[0].should_not == "#{__FILE__}:#{__LINE__ - 2}"
385
+ e.backtrace[0].should_not == "#{__FILE__}:#{__LINE__ - 2}"
460
386
  end
461
387
  end
462
388
 
463
- it "should strip gems when --backtrace is absent" do
389
+ xit "should strip gems when --backtrace is absent" do
464
390
  cli = CLI.new
465
391
  cli.parse_options!(['--'])
466
392
  begin
467
393
  "x".should == "y"
468
394
  rescue => e
469
- e.cucumber_backtrace[0].should == "#{__FILE__}:#{__LINE__ - 2}"
395
+ e.backtrace[0].should == "#{__FILE__}:#{__LINE__ - 2}"
470
396
  end
471
397
  end
472
398
 
@@ -475,46 +401,15 @@ Defined profiles in cucumber.yml:
475
401
  end
476
402
  end
477
403
 
478
- describe "example.feature:line file arguments" do
479
-
480
- it "should extract line numbers" do
481
- cli = CLI.new
482
- cli.parse_options!(%w{example.feature:10})
483
-
484
- cli.options[:lines_for_features]['example.feature'].should == [10]
485
- end
486
-
487
- it "should remove line numbers" do
488
- cli = CLI.new
489
- cli.parse_options!(%w{example.feature:10})
490
-
491
- cli.paths.should == ["example.feature"]
492
- end
493
-
494
- it "should support multiple feature:line numbers" do
495
- cli = CLI.new
496
- cli.parse_options!(%w{example.feature:11 another_example.feature:12})
497
-
498
- cli.options[:lines_for_features].should == {'another_example.feature' => [12], 'example.feature' => [11]}
499
- end
500
-
501
- it "should accept multiple line numbers for a single feature" do
502
- cli = CLI.new
503
- cli.parse_options!(%w{example.feature:11:12})
504
-
505
- cli.options[:lines_for_features].should == {'example.feature' => [11, 12]}
506
- end
507
- end
508
-
509
404
  it "should search for all features in the specified directory" do
510
- cli = CLI.new
405
+ cli = CLI.new(StringIO.new)
511
406
 
512
407
  cli.parse_options!(%w{feature_directory/})
513
408
  File.stub!(:directory?).and_return(true)
514
409
 
515
410
  Dir.should_receive(:[]).with("feature_directory/**/*.feature").any_number_of_times.and_return([])
516
411
 
517
- cli.execute!(stub('step mother'), mock_executor, mock_features)
412
+ cli.execute!(stub('step mother'))
518
413
  end
519
414
 
520
415
  end
@@ -1,45 +1,37 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'cucumber/core_ext/instance_exec'
2
3
 
3
- module Cucumber
4
- module CoreExt
5
- describe "proc extended with CallIn" do
6
- it "should raise ArityMismatchError for too many args (expecting 0)" do
7
- proc = lambda {}
8
- proc.extend CallIn
9
- lambda {
10
- proc.call_in(Object.new, 1)
11
- }.should raise_error(Cucumber::ArityMismatchError, "expected 0 block argument(s), got 1")
4
+ describe Proc do
5
+ it "should raise ArityMismatchError for too many args (expecting 0)" do
6
+ lambda {
7
+ Object.new.cucumber_instance_exec(true, 'foo', 1) do
12
8
  end
9
+ }.should raise_error(Cucumber::ArityMismatchError, "expected 0 block argument(s), got 1")
10
+ end
13
11
 
14
- it "should raise ArityMismatchError for too many args (expecting 1)" do
15
- proc = lambda {|a|}
16
- proc.extend CallIn
17
- lambda {
18
- proc.call_in(Object.new, 1, 2)
19
- }.should raise_error(Cucumber::ArityMismatchError, "expected 1 block argument(s), got 2")
12
+ it "should raise ArityMismatchError for too many args (expecting 1)" do
13
+ lambda {
14
+ Object.new.cucumber_instance_exec(true, 'foo', 1,2) do |a|
20
15
  end
16
+ }.should raise_error(Cucumber::ArityMismatchError, "expected 1 block argument(s), got 2")
17
+ end
21
18
 
22
- it "should raise ArityMismatchError for too few args (expecting 1)" do
23
- proc = lambda {|a|}
24
- proc.extend CallIn
25
- lambda {
26
- proc.call_in(Object.new)
27
- }.should raise_error(Cucumber::ArityMismatchError, "expected 1 block argument(s), got 0")
19
+ it "should raise ArityMismatchError for too few args (expecting 1)" do
20
+ lambda {
21
+ Object.new.cucumber_instance_exec(true, 'foo') do |a|
28
22
  end
23
+ }.should raise_error(Cucumber::ArityMismatchError, "expected 1 block argument(s), got 0")
24
+ end
29
25
 
30
- it "should raise ArityMismatchError for too few args (expecting 2)" do
31
- proc = lambda {|a,b|}
32
- proc.extend CallIn
33
- lambda {
34
- proc.call_in(Object.new, 1)
35
- }.should raise_error(Cucumber::ArityMismatchError, "expected 2 block argument(s), got 1")
26
+ it "should raise ArityMismatchError for too few args (expecting 2)" do
27
+ lambda {
28
+ Object.new.cucumber_instance_exec(true, 'foo', 1) do |a,b|
36
29
  end
37
-
38
- it "should remove extraneous path info for file" do
39
- proc = lambda {|a,b|}
40
- proc.extend CallIn
41
- proc.file_colon_line.should == "spec/cucumber/core_ext/proc_spec.rb:39"
42
- end
43
- end
30
+ }.should raise_error(Cucumber::ArityMismatchError, "expected 2 block argument(s), got 1")
31
+ end
32
+
33
+ it "should remove extraneous path info for file" do
34
+ proc = lambda {|a,b|}
35
+ proc.file_colon_line.should == "spec/cucumber/core_ext/proc_spec.rb:34"
44
36
  end
45
- end
37
+ end
@@ -17,6 +17,14 @@ describe String, "#gzub" do
17
17
  end
18
18
  f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
19
19
  end
20
+
21
+ it "should format groups with proc object" do
22
+ proc = lambda do |m|
23
+ "<span>#{m}</span>"
24
+ end
25
+ f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, proc)
26
+ f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
27
+ end
20
28
 
21
29
  it "should format groups with block with not all placeholders having a value" do
22
30
  f = "another member named Bob joins the group".gzub(/(a|another) (user|member) named ([^ ]+)( who is not logged in)?/) do |m|
@@ -1,8 +1,8 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
- require 'cucumber/formatters/ansicolor'
2
+ require 'cucumber/formatter/ansicolor'
3
3
 
4
4
  module Cucumber
5
- module Formatters
5
+ module Formatter
6
6
  describe ANSIColor do
7
7
  include ANSIColor
8
8
 
@@ -0,0 +1,37 @@
1
+ body {
2
+ background: #000000;
3
+ color: #FFFFFF;
4
+ }
5
+
6
+ table {
7
+ border-collapse: collapse;
8
+ border-spacing: 10px;
9
+ }
10
+
11
+ td
12
+ {
13
+ border-color: #FFFFFF;
14
+ border-width: 0 0.15em 0 0.15em;
15
+ border-style: solid;
16
+ padding: 0 0.5em 0 0.5em;
17
+ }
18
+
19
+ .multiline_table {
20
+ padding-left: 4em;
21
+ }
22
+
23
+ .missing {
24
+ color: yellow;
25
+ }
26
+
27
+ .pending {
28
+ color: yellow;
29
+ }
30
+
31
+ .passed {
32
+ color: green;
33
+ }
34
+
35
+ .failed {
36
+ color: red;
37
+ }
@@ -0,0 +1,11 @@
1
+ jQuery.fn.status = function(s) {
2
+ this.removeClass('idle').addClass(s);
3
+ this.next('span.multiline').addClass(s);
4
+ this.parent().addClass(s);
5
+ this.parent().parent().children('span.feature').addClass(s);
6
+ }
7
+
8
+ jQuery.fn.failed = function(message, backtrace) {
9
+ this.status('failed');
10
+ this.append("\n<span>" + message.replace(/^/gm, ' ') + "</span>").append("\n<span>" + backtrace.replace(/^/gm, ' ') + "</span>");
11
+ }
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>Cucumber results</title>
8
+ <link rel="stylesheet" href="cucumber.css" type="text/css" charset="utf-8" />
9
+ <script type="text/javascript" src="jquery-1.3.min.js"></script>
10
+ <script type="text/javascript" src="jquery.uitableedit.js"></script>
11
+ <script type="text/javascript" src="cucumber.js"></script>
12
+ </head>
13
+
14
+ <body>
15
+ <pre>
16
+ <span><span class="feature">Feature: Sample</span>
17
+
18
+ <span class="scenario"> Scenario: Missing
19
+ <span id="step_1"> Given missing</span></span>
20
+
21
+ <span class="scenario"> Scenario: Passing
22
+ <span id="step_2"> Given passing</span><div class="multiline_table"><table>
23
+ <tr>
24
+ <td class="passed">1</td>
25
+ <td class="passed">22</td>
26
+ </tr>
27
+ <tr>
28
+ <td class="failed">4444</td>
29
+ <td class="failed">333</td>
30
+ </tr>
31
+ </table></div></span>
32
+ <span class="scenario"> Scenario: Failing
33
+ <span id="step_3"> Given failing</span>
34
+ <span class="multiline"> """
35
+ Aslak
36
+ Hellesøy
37
+ """</span></span></span>
38
+ </pre>
39
+
40
+ <script type="text/javascript">$('#step_1').failed('error message', "line1\nline2\nline3")</script>
41
+ <script type="text/javascript">$('#step_2').status('pending')</script>
42
+ <script type="text/javascript">$('#step_3').status('passed')</script>
43
+
44
+ </body>
45
+ </html>