cucumber 0.3.101 → 0.3.102

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 (62) hide show
  1. data/History.txt +31 -2
  2. data/Manifest.txt +7 -4
  3. data/config/hoe.rb +2 -2
  4. data/examples/pure_java/README.textile +2 -2
  5. data/examples/self_test/features/step_definitions/sample_steps.rb +0 -12
  6. data/examples/self_test/features/support/env.rb +0 -6
  7. data/features/cucumber_cli.feature +11 -24
  8. data/features/custom_formatter.feature +38 -3
  9. data/features/default_snippets.feature +42 -0
  10. data/features/html_formatter/a.html +1 -1
  11. data/features/negative_tagged_hooks.feature +61 -0
  12. data/features/step_definitions/cucumber_steps.rb +1 -1
  13. data/features/support/env.rb +1 -1
  14. data/features/transform.feature +88 -12
  15. data/features/usage.feature +0 -6
  16. data/lib/cucumber/ast/feature.rb +4 -0
  17. data/lib/cucumber/ast/feature_element.rb +49 -42
  18. data/lib/cucumber/ast/step_invocation.rb +1 -1
  19. data/lib/cucumber/ast/tags.rb +25 -3
  20. data/lib/cucumber/cli/drb_client.rb +7 -1
  21. data/lib/cucumber/cli/main.rb +5 -3
  22. data/lib/cucumber/cli/options.rb +15 -24
  23. data/lib/cucumber/constantize.rb +8 -2
  24. data/lib/cucumber/core_ext/instance_exec.rb +2 -1
  25. data/lib/cucumber/core_ext/string.rb +12 -22
  26. data/lib/cucumber/filter.rb +2 -12
  27. data/lib/cucumber/formatter/console.rb +21 -21
  28. data/lib/cucumber/formatter/html.rb +1 -1
  29. data/lib/cucumber/formatter/pdf.rb +1 -1
  30. data/lib/cucumber/formatter/pretty.rb +1 -1
  31. data/lib/cucumber/language_support/language_methods.rb +19 -2
  32. data/lib/cucumber/language_support/step_definition_methods.rb +2 -25
  33. data/lib/cucumber/parser/feature.rb +13 -50
  34. data/lib/cucumber/parser/feature.tt +13 -47
  35. data/lib/cucumber/parser/natural_language.rb +1 -1
  36. data/lib/cucumber/rails/action_controller.rb +33 -0
  37. data/lib/cucumber/rails/active_record.rb +27 -0
  38. data/lib/cucumber/rails/rspec.rb +1 -1
  39. data/lib/cucumber/rails/test_unit.rb +9 -0
  40. data/lib/cucumber/rails/world.rb +7 -78
  41. data/lib/cucumber/rb_support/rb_dsl.rb +6 -4
  42. data/lib/cucumber/rb_support/rb_group.rb +11 -0
  43. data/lib/cucumber/rb_support/rb_language.rb +8 -2
  44. data/lib/cucumber/rb_support/rb_step_definition.rb +23 -8
  45. data/lib/cucumber/rb_support/rb_transform.rb +35 -0
  46. data/lib/cucumber/rb_support/rb_world.rb +7 -1
  47. data/lib/cucumber/step_match.rb +25 -6
  48. data/lib/cucumber/step_mother.rb +9 -32
  49. data/lib/cucumber/version.rb +1 -1
  50. data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
  51. data/rails_generators/cucumber/templates/env.rb +1 -8
  52. data/spec/cucumber/ast/feature_element_spec.rb +24 -23
  53. data/spec/cucumber/ast/scenario_outline_spec.rb +1 -1
  54. data/spec/cucumber/cli/options_spec.rb +5 -14
  55. data/spec/cucumber/core_ext/string_spec.rb +11 -13
  56. data/spec/cucumber/parser/feature_parser_spec.rb +6 -6
  57. data/spec/cucumber/step_mother_spec.rb +41 -38
  58. metadata +11 -8
  59. data/examples/self_test/features/transform_sample.feature +0 -10
  60. data/spec/cucumber/rails/stubs/mini_rails.rb +0 -18
  61. data/spec/cucumber/rails/stubs/test_help.rb +0 -1
  62. data/spec/cucumber/rails/world_spec.rb +0 -16
@@ -1,19 +1,24 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../../lib/cucumber/core_ext/string'
2
+ require 'cucumber/core_ext/string'
3
+ require 'cucumber/rb_support/rb_group'
3
4
 
4
5
  describe String, "#gzub" do
6
+ def groups(a)
7
+ a.map{|c| Cucumber::RbSupport::RbGroup.new(c[0], c[1])}
8
+ end
9
+
5
10
  it "should format groups with format string" do
6
- "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, "<span>%s</span>").should ==
11
+ "I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]]), "<span>%s</span>").should ==
7
12
  "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
8
13
  end
9
14
 
10
15
  it "should format groups with format string when there are dupes" do
11
- "I bob 1 bo this bobs".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, "<span>%s</span>").should ==
16
+ "I bob 1 bo this bobs".gzub(groups([['bob', 2], ['1', 6], ['bo', 8], ['bobs', 16]]), "<span>%s</span>").should ==
12
17
  "I <span>bob</span> <span>1</span> <span>bo</span> this <span>bobs</span>"
13
18
  end
14
19
 
15
20
  it "should format groups with block" do
16
- f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/) do |m|
21
+ f = "I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]])) do |m|
17
22
  "<span>#{m}</span>"
18
23
  end
19
24
  f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
@@ -23,21 +28,14 @@ describe String, "#gzub" do
23
28
  proc = lambda do |m|
24
29
  "<span>#{m}</span>"
25
30
  end
26
- f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/, proc)
31
+ f = "I ate 1 egg this morning".gzub(groups([['ate', 2], ['1', 6], ['egg', 8], ['morning', 17]]), proc)
27
32
  f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
28
33
  end
29
34
 
30
35
  it "should format groups with block with not all placeholders having a value" do
31
- f = "another member named Bob joins the group".gzub(/(a|another) (user|member) named ([^ ]+)( who is not logged in)?/) do |m|
36
+ f = "another member named Bob joins the group".gzub(groups([['another', 0], ['member', 8], ['Bob', 21]])) do |m|
32
37
  "<span>#{m}</span>"
33
38
  end
34
39
  f.should == "<span>another</span> <span>member</span> named <span>Bob</span> joins the group"
35
40
  end
36
-
37
- it "should format match groups in a textile table row" do
38
- f = "I ate 1 egg this morning".gzub(/I (\w+) (\d+) (\w+) this (\w+)/) do |m|
39
- "<span>#{m}</span>"
40
- end
41
- f.should == "I <span>ate</span> <span>1</span> <span>egg</span> this <span>morning</span>"
42
- end
43
41
  end
@@ -68,8 +68,8 @@ Feature: hi
68
68
  parse("# My comment\n@hello @world Feature: hi\n").to_sexp.should ==
69
69
  [:feature, nil, "Feature: hi",
70
70
  [:comment, "# My comment\n"],
71
- [:tag, "hello"],
72
- [:tag, "world"]]
71
+ [:tag, "@hello"],
72
+ [:tag, "@world"]]
73
73
  end
74
74
 
75
75
  it "should not take the tags as part of a multiline name feature element" do
@@ -77,7 +77,7 @@ Feature: hi
77
77
  [:feature, nil, "Feature: hi",
78
78
  [:scenario, 2, "Scenario:", "test"],
79
79
  [:scenario, 4, "Scenario:", "another",
80
- [:tag, "hello"]]]
80
+ [:tag, "@hello"]]]
81
81
  end
82
82
 
83
83
  it "should parse a file with tags on a scenario" do
@@ -94,13 +94,13 @@ Feature: hi
94
94
  Scenario: Second}).to_sexp.should ==
95
95
  [:feature, nil, "Feature: hi",
96
96
  [:comment, "# FC\n "],
97
- [:tag, "ft"],
97
+ [:tag, "@ft"],
98
98
  [:scenario, 6, 'Scenario:', 'First',
99
- [:tag, "st1"], [:tag, "st2"],
99
+ [:tag, "@st1"], [:tag, "@st2"],
100
100
  [:step_invocation, 7, "Given", "Pepper"]
101
101
  ],
102
102
  [:scenario, 11, 'Scenario:', 'Second',
103
- [:tag, "st3"], [:tag, "st4"], [:tag, "ST5"], [:tag, "#^%&ST6**!"]]]
103
+ [:tag, "@st3"], [:tag, "@st4"], [:tag, "@ST5"], [:tag, "@#^%&ST6**!"]]]
104
104
  end
105
105
  end
106
106
 
@@ -186,96 +186,99 @@ or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
186
186
  end
187
187
 
188
188
  describe StepMother, "step argument transformations" do
189
- after(:each) do
190
- # generally transforms are global, but state should be
191
- # cleared when testing them here at the unit level
192
- class StepMother; @@transforms = [] end
189
+ before do
190
+ @dsl = Object.new
191
+ @dsl.extend(RbSupport::RbDsl)
192
+
193
+ @step_mother = StepMother.new
194
+ @step_mother.load_natural_language('en')
195
+ @rb = @step_mother.load_programming_language('rb')
193
196
  end
194
197
 
195
198
  describe "without capture groups" do
196
199
  it "complains when registering with a with no transform block" do
197
200
  lambda do
198
- StepMother.register_transform('^abc$')
199
- end.should raise_error(Cucumber::ArityMismatchError)
201
+ @dsl.Transform('^abc$')
202
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
200
203
  end
201
204
 
202
205
  it "complains when registering with a zero-arg transform block" do
203
206
  lambda do
204
- StepMother.register_transform('^abc$') {42}
205
- end.should raise_error(Cucumber::ArityMismatchError)
207
+ @dsl.Transform('^abc$') {42}
208
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
206
209
  end
207
210
 
208
211
  it "complains when registering with a splat-arg transform block" do
209
212
  lambda do
210
- StepMother.register_transform('^abc$') {|*splat| 42 }
211
- end.should raise_error(Cucumber::ArityMismatchError)
213
+ @dsl.Transform('^abc$') {|*splat| 42 }
214
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
212
215
  end
213
216
 
214
217
  it "complains when transforming with an arity mismatch" do
215
218
  lambda do
216
- StepMother.register_transform('^abc$') {|one, two| 42 }
217
- StepMother.transform_arguments(['abc'])
219
+ @dsl.Transform('^abc$') {|one, two| 42 }
220
+ @rb.execute_transforms(['abc'])
218
221
  end.should raise_error(Cucumber::ArityMismatchError)
219
222
  end
220
223
 
221
224
  it "allows registering a regexp pattern that yields the step_arg matched" do
222
- StepMother.register_transform(/^ab*c$/) {|arg| 42}
223
- StepMother.transform_arguments(['ab']).should == ['ab']
224
- StepMother.transform_arguments(['ac']).should == [42]
225
- StepMother.transform_arguments(['abc']).should == [42]
226
- StepMother.transform_arguments(['abbc']).should == [42]
225
+ @dsl.Transform(/^ab*c$/) {|arg| 42}
226
+ @rb.execute_transforms(['ab']).should == ['ab']
227
+ @rb.execute_transforms(['ac']).should == [42]
228
+ @rb.execute_transforms(['abc']).should == [42]
229
+ @rb.execute_transforms(['abbc']).should == [42]
227
230
  end
228
231
  end
229
232
 
230
233
  describe "with capture groups" do
231
234
  it "complains when registering with a with no transform block" do
232
235
  lambda do
233
- StepMother.register_transform('^a(.)c$')
234
- end.should raise_error(Cucumber::ArityMismatchError)
236
+ @dsl.Transform('^a(.)c$')
237
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
235
238
  end
236
239
 
237
240
  it "complains when registering with a zero-arg transform block" do
238
241
  lambda do
239
- StepMother.register_transform('^a(.)c$') { 42 }
240
- end.should raise_error(Cucumber::ArityMismatchError)
242
+ @dsl.Transform('^a(.)c$') { 42 }
243
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
241
244
  end
242
245
 
243
246
  it "complains when registering with a splat-arg transform block" do
244
247
  lambda do
245
- StepMother.register_transform('^a(.)c$') {|*splat| 42 }
246
- end.should raise_error(Cucumber::ArityMismatchError)
248
+ @dsl.Transform('^a(.)c$') {|*splat| 42 }
249
+ end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
247
250
  end
248
251
 
249
252
  it "complains when transforming with an arity mismatch" do
250
253
  lambda do
251
- StepMother.register_transform('^a(.)c$') {|one, two| 42 }
252
- StepMother.transform_arguments(['abc'])
254
+ @dsl.Transform('^a(.)c$') {|one, two| 42 }
255
+ @rb.execute_transforms(['abc'])
253
256
  end.should raise_error(Cucumber::ArityMismatchError)
254
257
  end
255
258
 
256
259
  it "allows registering a regexp pattern that yields capture groups" do
257
- StepMother.register_transform(/^shape: (.+), color: (.+)$/) do |shape, color|
260
+ @dsl.Transform(/^shape: (.+), color: (.+)$/) do |shape, color|
258
261
  {shape.to_sym => color.to_sym}
259
262
  end
260
- StepMother.transform_arguments(['shape: circle, color: blue']).should == [{:circle => :blue}]
261
- StepMother.transform_arguments(['shape: square, color: red']).should == [{:square => :red}]
262
- StepMother.transform_arguments(['not shape: square, not color: red']).should == ['not shape: square, not color: red']
263
+ @rb.execute_transforms(['shape: circle, color: blue']).should == [{:circle => :blue}]
264
+ @rb.execute_transforms(['shape: square, color: red']).should == [{:square => :red}]
265
+ @rb.execute_transforms(['not shape: square, not color: red']).should == ['not shape: square, not color: red']
263
266
  end
264
267
  end
265
268
 
266
269
  it "allows registering a string pattern" do
267
- StepMother.register_transform('^ab*c$') {|arg| 42}
268
- StepMother.transform_arguments(['ab']).should == ['ab']
269
- StepMother.transform_arguments(['ac']).should == [42]
270
- StepMother.transform_arguments(['abc']).should == [42]
271
- StepMother.transform_arguments(['abbc']).should == [42]
270
+ @dsl.Transform('^ab*c$') {|arg| 42}
271
+ @rb.execute_transforms(['ab']).should == ['ab']
272
+ @rb.execute_transforms(['ac']).should == [42]
273
+ @rb.execute_transforms(['abc']).should == [42]
274
+ @rb.execute_transforms(['abbc']).should == [42]
272
275
  end
273
276
 
274
277
  it "gives match priority to transforms defined last" do
275
- StepMother.register_transform(/^transform_me$/) {|arg| :foo }
276
- StepMother.register_transform(/^transform_me$/) {|arg| :bar }
277
- StepMother.register_transform(/^transform_me$/) {|arg| :baz }
278
- StepMother.transform_arguments(['transform_me']).should == [:baz]
278
+ @dsl.Transform(/^transform_me$/) {|arg| :foo }
279
+ @dsl.Transform(/^transform_me$/) {|arg| :bar }
280
+ @dsl.Transform(/^transform_me$/) {|arg| :baz }
281
+ @rb.execute_transforms(['transform_me']).should == [:baz]
279
282
  end
280
283
  end
281
284
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.101
4
+ version: 0.3.102
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-15 00:00:00 +02:00
12
+ date: 2009-09-22 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.0
33
+ version: 1.4.2
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: polyglot
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.2.8
43
+ version: 0.2.9
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: diff-lcs
@@ -289,7 +289,6 @@ files:
289
289
  - examples/self_test/features/support/env.rb
290
290
  - examples/self_test/features/tags_sample.feature
291
291
  - examples/self_test/features/tons_of_cukes.feature
292
- - examples/self_test/features/transform_sample.feature
293
292
  - examples/self_test/features/undefined_multiline_args.feature
294
293
  - examples/self_test/list-of-features.txt
295
294
  - examples/sinatra/README.textile
@@ -347,6 +346,7 @@ files:
347
346
  - features/cucumber_cli_diff_disabled.feature
348
347
  - features/cucumber_cli_outlines.feature
349
348
  - features/custom_formatter.feature
349
+ - features/default_snippets.feature
350
350
  - features/drb_server_integration.feature
351
351
  - features/exception_in_after_block.feature
352
352
  - features/exception_in_after_step_block.feature
@@ -358,6 +358,7 @@ files:
358
358
  - features/junit_formatter.feature
359
359
  - features/language_from_header.feature
360
360
  - features/multiline_names.feature
361
+ - features/negative_tagged_hooks.feature
361
362
  - features/post_configuration_hook.feature
362
363
  - features/profiles.feature
363
364
  - features/rake_task.feature
@@ -455,13 +456,18 @@ files:
455
456
  - lib/cucumber/py_support/py_dsl.py
456
457
  - lib/cucumber/py_support/py_language.py
457
458
  - lib/cucumber/py_support/py_language.rb
459
+ - lib/cucumber/rails/action_controller.rb
460
+ - lib/cucumber/rails/active_record.rb
458
461
  - lib/cucumber/rails/rspec.rb
462
+ - lib/cucumber/rails/test_unit.rb
459
463
  - lib/cucumber/rails/world.rb
460
464
  - lib/cucumber/rake/task.rb
461
465
  - lib/cucumber/rb_support/rb_dsl.rb
466
+ - lib/cucumber/rb_support/rb_group.rb
462
467
  - lib/cucumber/rb_support/rb_hook.rb
463
468
  - lib/cucumber/rb_support/rb_language.rb
464
469
  - lib/cucumber/rb_support/rb_step_definition.rb
470
+ - lib/cucumber/rb_support/rb_transform.rb
465
471
  - lib/cucumber/rb_support/rb_world.rb
466
472
  - lib/cucumber/rspec_neuter.rb
467
473
  - lib/cucumber/step_match.rb
@@ -507,9 +513,6 @@ files:
507
513
  - spec/cucumber/formatter/progress_spec.rb
508
514
  - spec/cucumber/parser/feature_parser_spec.rb
509
515
  - spec/cucumber/parser/table_parser_spec.rb
510
- - spec/cucumber/rails/stubs/mini_rails.rb
511
- - spec/cucumber/rails/stubs/test_help.rb
512
- - spec/cucumber/rails/world_spec.rb
513
516
  - spec/cucumber/rb_support/rb_step_definition_spec.rb
514
517
  - spec/cucumber/sell_cucumbers.feature
515
518
  - spec/cucumber/step_mother_spec.rb
@@ -1,10 +0,0 @@
1
- Feature: Step argument transformations
2
-
3
- Scenario: transform with matches
4
- Then I should transform '10' to an Integer
5
-
6
- Scenario: transform with matches that capture
7
- Then I should transform 'abc' to a Symbol
8
-
9
- Scenario: transform without matches
10
- Then I should not transform '10' to an Integer
@@ -1,18 +0,0 @@
1
- # Define some stubs to fake Rails...
2
- module ActiveRecord
3
- class Base
4
- end
5
- end
6
-
7
- module ActionController
8
- class Dispatcher
9
- end
10
-
11
- class Base
12
- end
13
-
14
- class IntegrationTest
15
- def self.use_transactional_fixtures=(x)
16
- end
17
- end
18
- end
@@ -1 +0,0 @@
1
- # This file is loaded by rails/world.rb
@@ -1,16 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- $:.unshift(File.dirname(__FILE__) + '/stubs')
3
-
4
- describe "Rails world" do
5
-
6
- it "should run without Test::Unit.run defined" do
7
- require "mini_rails"
8
-
9
- step_mother = Cucumber::StepMother.new
10
- step_mother.load_natural_language('en')
11
- rb = step_mother.load_programming_language('rb')
12
-
13
- require "cucumber/rails/world"
14
- end
15
-
16
- end