cucumber 1.2.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +14 -6
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -0
  5. data/.yardopts +1 -0
  6. data/CONTRIBUTING.md +2 -2
  7. data/History.md +38 -2
  8. data/bin/cucumber +2 -11
  9. data/cucumber.gemspec +3 -3
  10. data/cucumber.yml +5 -1
  11. data/examples/test_unit/Gemfile +4 -0
  12. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
  13. data/examples/watir/README.textile +2 -2
  14. data/examples/watir/features/support/env.rb +10 -7
  15. data/features/.cucumber/stepdefs.json +747 -1354
  16. data/features/assertions.feature +6 -2
  17. data/features/background.feature +3 -0
  18. data/features/backtraces.feature +3 -3
  19. data/features/before_hook.feature +43 -0
  20. data/features/bootstrap.feature +14 -2
  21. data/features/custom_formatter.feature +1 -1
  22. data/features/drb_server_integration.feature +3 -3
  23. data/features/formatter_callbacks.feature +2 -2
  24. data/features/formatter_step_file_colon_line.feature +1 -1
  25. data/features/html_formatter.feature +52 -1
  26. data/features/json_formatter.feature +93 -7
  27. data/features/load_path.feature +14 -0
  28. data/features/nested_steps.feature +75 -3
  29. data/features/nested_steps_i18n.feature +36 -0
  30. data/features/pretty_formatter.feature +31 -0
  31. data/features/progress_formatter.feature +31 -0
  32. data/features/raketask.feature +51 -0
  33. data/features/rerun_formatter.feature +1 -1
  34. data/features/stats_formatters.feature +17 -14
  35. data/features/step_definitions/cucumber_steps.rb +6 -4
  36. data/features/support/env.rb +31 -4
  37. data/features/support/feature_factory.rb +17 -0
  38. data/features/tagged_hooks.feature +37 -195
  39. data/features/transforms.feature +15 -15
  40. data/gem_tasks/cucumber.rake +2 -0
  41. data/gem_tasks/yard.rake +10 -6
  42. data/legacy_features/README.md +14 -0
  43. data/legacy_features/language_help.feature +3 -1
  44. data/legacy_features/report_called_undefined_steps.feature +1 -0
  45. data/legacy_features/snippets_when_using_star_keyword.feature +1 -0
  46. data/legacy_features/support/env.rb +4 -0
  47. data/lib/cucumber/ast/background.rb +35 -35
  48. data/lib/cucumber/ast/empty_background.rb +33 -0
  49. data/lib/cucumber/ast/examples.rb +5 -2
  50. data/lib/cucumber/ast/feature.rb +24 -35
  51. data/lib/cucumber/ast/features.rb +4 -1
  52. data/lib/cucumber/ast/has_steps.rb +9 -17
  53. data/lib/cucumber/ast/location.rb +41 -0
  54. data/lib/cucumber/ast/scenario.rb +37 -50
  55. data/lib/cucumber/ast/scenario_outline.rb +62 -49
  56. data/lib/cucumber/ast/step.rb +23 -27
  57. data/lib/cucumber/ast/step_collection.rb +16 -0
  58. data/lib/cucumber/ast/step_invocation.rb +4 -1
  59. data/lib/cucumber/ast/tree_walker.rb +7 -0
  60. data/lib/cucumber/cli/configuration.rb +15 -3
  61. data/lib/cucumber/cli/main.rb +24 -11
  62. data/lib/cucumber/cli/options.rb +24 -16
  63. data/lib/cucumber/configuration.rb +4 -0
  64. data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +10 -34
  65. data/lib/cucumber/core_ext/instance_exec.rb +4 -1
  66. data/lib/cucumber/core_ext/proc.rb +2 -0
  67. data/lib/cucumber/feature_file.rb +5 -12
  68. data/lib/cucumber/formatter/console.rb +10 -0
  69. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +4 -4
  70. data/lib/cucumber/formatter/html.rb +7 -42
  71. data/lib/cucumber/formatter/interceptor.rb +4 -0
  72. data/lib/cucumber/formatter/json_pretty.rb +0 -4
  73. data/lib/cucumber/formatter/junit.rb +8 -2
  74. data/lib/cucumber/formatter/pretty.rb +5 -1
  75. data/lib/cucumber/formatter/progress.rb +4 -0
  76. data/lib/cucumber/formatter/unicode.rb +12 -25
  77. data/lib/cucumber/formatter/usage.rb +7 -2
  78. data/lib/cucumber/js_support/js_snippets.rb +1 -1
  79. data/lib/cucumber/load_path.rb +13 -0
  80. data/lib/cucumber/parser/gherkin_builder.rb +237 -81
  81. data/lib/cucumber/platform.rb +1 -1
  82. data/lib/cucumber/py_support/py_language.rb +1 -1
  83. data/lib/cucumber/rake/task.rb +5 -1
  84. data/lib/cucumber/rb_support/rb_language.rb +20 -19
  85. data/lib/cucumber/rb_support/rb_world.rb +63 -21
  86. data/lib/cucumber/rb_support/snippet.rb +108 -0
  87. data/lib/cucumber/runtime.rb +1 -0
  88. data/lib/cucumber/runtime/support_code.rb +2 -2
  89. data/lib/cucumber/unit.rb +11 -0
  90. data/lib/cucumber/wire_support/wire_language.rb +1 -1
  91. data/spec/cucumber/ast/background_spec.rb +13 -6
  92. data/spec/cucumber/ast/feature_factory.rb +20 -10
  93. data/spec/cucumber/ast/features_spec.rb +51 -0
  94. data/spec/cucumber/ast/scenario_outline_spec.rb +13 -7
  95. data/spec/cucumber/ast/step_spec.rb +6 -4
  96. data/spec/cucumber/cli/configuration_spec.rb +34 -1
  97. data/spec/cucumber/cli/main_spec.rb +36 -26
  98. data/spec/cucumber/cli/options_spec.rb +28 -19
  99. data/spec/cucumber/core_ext/proc_spec.rb +13 -1
  100. data/spec/cucumber/formatter/interceptor_spec.rb +8 -0
  101. data/spec/cucumber/formatter/junit_spec.rb +33 -0
  102. data/spec/cucumber/formatter/pretty_spec.rb +391 -0
  103. data/spec/cucumber/rb_support/rb_language_spec.rb +21 -50
  104. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +2 -4
  105. data/spec/cucumber/rb_support/snippet_spec.rb +128 -0
  106. data/spec/cucumber/step_match_spec.rb +2 -6
  107. metadata +62 -113
  108. data/.rvmrc +0 -1
  109. data/features/hooks.feature +0 -59
  110. data/legacy_features/call_steps_from_stepdefs.feature +0 -154
@@ -1,10 +1,22 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
  require 'cucumber/core_ext/proc'
3
4
 
4
5
  describe Proc do
5
6
  it "should remove extraneous path info for file" do
6
7
  proc = lambda {|a,b|}
7
- proc.file_colon_line.should =~ /^spec\/cucumber\/core_ext\/proc_spec\.rb:6/
8
+ proc.file_colon_line.should =~ /^spec\/cucumber\/core_ext\/proc_spec\.rb:7/
9
+ end
10
+
11
+ unless Cucumber::RUBY_1_8_7
12
+ it "should work with non-English path" do
13
+ proc = lambda {|a,b|}
14
+ def proc.to_s
15
+ "#<Proc:0x00000003c04740@#{Dir.pwd}/å/spec/cucumber/core_ext/proc_spec.rb:12 (lambda)>".force_encoding('ASCII-8BIT')
16
+ end
17
+
18
+ proc.file_colon_line.force_encoding('UTF-8').should =~ /^å\/spec\/cucumber\/core_ext\/proc_spec\.rb:12/
19
+ end
8
20
  end
9
21
 
10
22
  it "should raise ArityMismatchError for too many args (expecting 0)" do
@@ -117,5 +117,13 @@ module Cucumber::Formatter
117
117
  pi.tty?.should be true
118
118
  end
119
119
  end
120
+
121
+ describe '#respond_to' do
122
+ let(:pi) { Interceptor::Pipe.wrap(:stderr) }
123
+
124
+ it 'should respond to all methods $stderr has' do
125
+ $stderr.methods.each { |m| pi.respond_to?(m).should be true }
126
+ end
127
+ end
120
128
  end
121
129
  end
@@ -23,6 +23,39 @@ module Cucumber::Formatter
23
23
  @formatter = TestDoubleJunitFormatter.new(step_mother, '', {})
24
24
  end
25
25
 
26
+ describe "should be able to strip control chars from cdata" do
27
+ before(:each) do
28
+ run_defined_feature
29
+ @doc = Nokogiri.XML(@formatter.written_files.values.first)
30
+ end
31
+ define_feature "
32
+ Feature: One passing scenario, one failing scenario
33
+
34
+ Scenario: Passing
35
+ Given a passing ctrl scenario
36
+ "
37
+ class Junit
38
+ def before_step(step)
39
+ if step.name.match("a passing ctrl scenario")
40
+ Interceptor::Pipe.unwrap! :stdout
41
+ @fake_io = $stdout = StringIO.new
42
+ $stdout.sync = true
43
+ @interceptedout = Interceptor::Pipe.wrap(:stdout)
44
+ end
45
+ end
46
+
47
+ def after_step(step)
48
+ if step.name.match("a passing ctrl scenario")
49
+ @interceptedout.write("boo\b\cx\e\a\f boo ")
50
+ $stdout = STDOUT
51
+ @fake_io.close
52
+ end
53
+ end
54
+ end
55
+
56
+ it { @doc.xpath('//testsuite/system-out').first.content.should match(/\s+boo boo\s+/) }
57
+ end
58
+
26
59
  describe "a feature with no name" do
27
60
  define_feature <<-FEATURE
28
61
  Feature:
@@ -0,0 +1,391 @@
1
+ require 'spec_helper'
2
+ require 'cucumber/formatter/spec_helper'
3
+ require 'cucumber/formatter/pretty'
4
+ require 'cucumber/cli/options'
5
+
6
+ module Cucumber
7
+ module Formatter
8
+ describe Pretty do
9
+ extend SpecHelperDsl
10
+ include SpecHelper
11
+
12
+ context "With no options" do
13
+ before(:each) do
14
+ Cucumber::Term::ANSIColor.coloring = false
15
+ @out = StringIO.new
16
+ @formatter = Pretty.new(step_mother, @out, {})
17
+ end
18
+
19
+ describe "given a single feature" do
20
+ before(:each) do
21
+ run_defined_feature
22
+ end
23
+
24
+ describe "basic feature" do
25
+ define_feature <<-FEATURE
26
+ Feature: Bananas
27
+ In order to find my inner monkey
28
+ As a human
29
+ I must eat bananas
30
+ FEATURE
31
+
32
+ it "prints out the feature description" do
33
+ @out.string.should include "Feature: Bananas"
34
+ @out.string.should include "I must eat bananas"
35
+ end
36
+
37
+ end
38
+
39
+ describe "with a scenario" do
40
+ define_feature <<-FEATURE
41
+ Feature: Banana party
42
+
43
+ Scenario: Monkey eats banana
44
+ Given there are bananas
45
+ FEATURE
46
+
47
+ it "outputs the scenario name" do
48
+ @out.string.should include "Scenario: Monkey eats banana"
49
+ end
50
+ it "outputs the step" do
51
+ @out.string.should include "Given there are bananas"
52
+ end
53
+ end
54
+
55
+ describe "with a scenario outline" do
56
+ define_feature <<-FEATURE
57
+ Feature: Fud Pyramid
58
+
59
+ Scenario Outline: Monkey eats a balanced diet
60
+ Given there are <Things>
61
+
62
+ Examples: Fruit
63
+ | Things |
64
+ | apples |
65
+ | bananas |
66
+ Examples: Vegetables
67
+ | Things |
68
+ | broccoli |
69
+ | carrots |
70
+ FEATURE
71
+
72
+ it "outputs the scenario outline" do
73
+ lines = <<-OUTPUT
74
+ Examples: Fruit
75
+ | Things |
76
+ | apples |
77
+ | bananas |
78
+ Examples: Vegetables
79
+ | Things |
80
+ | broccoli |
81
+ | carrots |
82
+ OUTPUT
83
+ lines.split("\n").each do |line|
84
+ @out.string.should include line.strip
85
+ end
86
+ end
87
+ it "has 4 undefined scenarios" do
88
+ @out.string.should include "4 scenarios (4 undefined)"
89
+ end
90
+ it "has 4 undefined steps" do
91
+ @out.string.should include "4 steps (4 undefined)"
92
+ end
93
+
94
+ end
95
+
96
+ describe "with a step with a py string" do
97
+ define_feature <<-FEATURE
98
+ Feature: Traveling circus
99
+
100
+ Scenario: Monkey goes to town
101
+ Given there is a monkey called:
102
+ """
103
+ foo
104
+ """
105
+ FEATURE
106
+
107
+ it "displays the pystring nested" do
108
+ @out.string.should include <<OUTPUT
109
+ """
110
+ foo
111
+ """
112
+ OUTPUT
113
+ end
114
+ end
115
+
116
+ describe "with a multiline step arg" do
117
+ define_feature <<-FEATURE
118
+ Feature: Traveling circus
119
+
120
+ Scenario: Monkey goes to town
121
+ Given there are monkeys:
122
+ | name |
123
+ | foo |
124
+ | bar |
125
+ FEATURE
126
+
127
+ it "displays the multiline string" do
128
+ @out.string.should include <<OUTPUT
129
+ Given there are monkeys:
130
+ | name |
131
+ | foo |
132
+ | bar |
133
+ OUTPUT
134
+ end
135
+ end
136
+
137
+ describe "with a table in the background and the scenario" do
138
+ define_feature <<-FEATURE
139
+ Feature: accountant monkey
140
+
141
+ Background:
142
+ Given table:
143
+ | a | b |
144
+ | c | d |
145
+ Scenario:
146
+ Given another table:
147
+ | e | f |
148
+ | g | h |
149
+ FEATURE
150
+
151
+ it "displays the table for the background" do
152
+ @out.string.should include <<OUTPUT
153
+ Given table:
154
+ | a | b |
155
+ | c | d |
156
+ OUTPUT
157
+ end
158
+ it "displays the table for the scenario" do
159
+ @out.string.should include <<OUTPUT
160
+ Given another table:
161
+ | e | f |
162
+ | g | h |
163
+ OUTPUT
164
+ end
165
+ end
166
+
167
+ describe "with a py string in the background and the scenario" do
168
+ define_feature <<-FEATURE
169
+ Feature: py strings
170
+
171
+ Background:
172
+ Given stuff:
173
+ """
174
+ foo
175
+ """
176
+ Scenario:
177
+ Given more stuff:
178
+ """
179
+ bar
180
+ """
181
+ FEATURE
182
+
183
+ it "displays the background py string" do
184
+ @out.string.should include <<OUTPUT
185
+ Given stuff:
186
+ """
187
+ foo
188
+ """
189
+ OUTPUT
190
+ end
191
+ it "displays the scenario py string" do
192
+ @out.string.should include <<OUTPUT
193
+ Given more stuff:
194
+ """
195
+ bar
196
+ """
197
+ OUTPUT
198
+ end
199
+ end
200
+ end
201
+ end
202
+
203
+ context "With --no-multiline passed as an option" do
204
+ before(:each) do
205
+ Cucumber::Term::ANSIColor.coloring = false
206
+ @out = StringIO.new
207
+ @formatter = Pretty.new(step_mother, @out, {:no_multiline => true})
208
+ end
209
+
210
+ describe "given a single feature" do
211
+ before(:each) do
212
+ run_defined_feature
213
+ end
214
+
215
+ describe "basic feature" do
216
+ define_feature <<-FEATURE
217
+ Feature: Bananas
218
+ In order to find my inner monkey
219
+ As a human
220
+ I must eat bananas
221
+ FEATURE
222
+
223
+ it "prints out the feature description" do
224
+ @out.string.should include "Feature: Bananas"
225
+ @out.string.should include "I must eat bananas"
226
+ end
227
+
228
+ end
229
+
230
+ describe "with a scenario" do
231
+ define_feature <<-FEATURE
232
+ Feature: Banana party
233
+
234
+ Scenario: Monkey eats banana
235
+ Given there are bananas
236
+ FEATURE
237
+
238
+ it "outputs the scenario name" do
239
+ @out.string.should include "Scenario: Monkey eats banana"
240
+ end
241
+ it "outputs the step" do
242
+ @out.string.should include "Given there are bananas"
243
+ end
244
+ end
245
+
246
+ describe "with a scenario outline" do
247
+ define_feature <<-FEATURE
248
+ Feature: Fud Pyramid
249
+
250
+ Scenario Outline: Monkey eats a balanced diet
251
+ Given there are <Things>
252
+
253
+ Examples: Fruit
254
+ | Things |
255
+ | apples |
256
+ | bananas |
257
+ Examples: Vegetables
258
+ | Things |
259
+ | broccoli |
260
+ | carrots |
261
+ FEATURE
262
+
263
+ it "outputs the scenario outline" do
264
+ lines = <<-OUTPUT
265
+ Examples: Fruit
266
+ | Things |
267
+ | apples |
268
+ | bananas |
269
+ Examples: Vegetables
270
+ | Things |
271
+ | broccoli |
272
+ | carrots |
273
+ OUTPUT
274
+ lines.split("\n").each do |line|
275
+ @out.string.should include line.strip
276
+ end
277
+ end
278
+ it "has 4 undefined scenarios" do
279
+ @out.string.should include "4 scenarios (4 undefined)"
280
+ end
281
+ it "has 4 undefined steps" do
282
+ @out.string.should include "4 steps (4 undefined)"
283
+ end
284
+
285
+ end
286
+
287
+ describe "with a step with a py string" do
288
+ define_feature <<-FEATURE
289
+ Feature: Traveling circus
290
+
291
+ Scenario: Monkey goes to town
292
+ Given there is a monkey called:
293
+ """
294
+ foo
295
+ """
296
+ FEATURE
297
+
298
+ it "does not display the pystring" do
299
+ @out.string.should_not include <<OUTPUT
300
+ """
301
+ foo
302
+ """
303
+ OUTPUT
304
+ end
305
+ end
306
+
307
+ describe "with a multiline step arg" do
308
+ define_feature <<-FEATURE
309
+ Feature: Traveling circus
310
+
311
+ Scenario: Monkey goes to town
312
+ Given there are monkeys:
313
+ | name |
314
+ | foo |
315
+ | bar |
316
+ FEATURE
317
+
318
+ it "does not display the multiline string" do
319
+ @out.string.should_not include <<OUTPUT
320
+ | name |
321
+ | foo |
322
+ | bar |
323
+ OUTPUT
324
+ end
325
+ end
326
+
327
+ describe "with a table in the background and the scenario" do
328
+ define_feature <<-FEATURE
329
+ Feature: accountant monkey
330
+
331
+ Background:
332
+ Given table:
333
+ | a | b |
334
+ | c | d |
335
+ Scenario:
336
+ Given another table:
337
+ | e | f |
338
+ | g | h |
339
+ FEATURE
340
+
341
+ it "does not display the table for the background" do
342
+ @out.string.should_not include <<OUTPUT
343
+ | a | b |
344
+ | c | d |
345
+ OUTPUT
346
+ end
347
+ it "does not display the table for the scenario" do
348
+ @out.string.should_not include <<OUTPUT
349
+ | e | f |
350
+ | g | h |
351
+ OUTPUT
352
+ end
353
+ end
354
+
355
+ describe "with a py string in the background and the scenario" do
356
+ define_feature <<-FEATURE
357
+ Feature: py strings
358
+
359
+ Background:
360
+ Given stuff:
361
+ """
362
+ foo
363
+ """
364
+ Scenario:
365
+ Given more stuff:
366
+ """
367
+ bar
368
+ """
369
+ FEATURE
370
+
371
+ it "does not display the background py string" do
372
+ @out.string.should_not include <<OUTPUT
373
+ """
374
+ foo
375
+ """
376
+ OUTPUT
377
+ end
378
+ it "does not display the scenario py string" do
379
+ @out.string.should_not include <<OUTPUT
380
+ """
381
+ bar
382
+ """
383
+ OUTPUT
384
+ end
385
+ end
386
+ end
387
+ end
388
+
389
+ end
390
+ end
391
+ end