cucumber 0.8.7 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +5 -0
  3. data/History.txt +16 -3
  4. data/Rakefile +4 -50
  5. data/cucumber.gemspec +36 -600
  6. data/features/cucumber_cli.feature +1 -1
  7. data/features/json_formatter.feature +1 -1
  8. data/features/junit_formatter.feature +10 -6
  9. data/features/post_configuration_hook.feature +15 -2
  10. data/features/step_definitions/cucumber_steps.rb +5 -1
  11. data/features/step_definitions/wire_steps.rb +1 -0
  12. data/features/support/env.rb +2 -5
  13. data/features/wire_protocol.feature +1 -1
  14. data/lib/cucumber.rb +8 -0
  15. data/lib/cucumber/ast/outline_table.rb +4 -4
  16. data/lib/cucumber/ast/step_invocation.rb +14 -13
  17. data/lib/cucumber/ast/table.rb +2 -1
  18. data/lib/cucumber/ast/tree_walker.rb +3 -3
  19. data/lib/cucumber/cli/configuration.rb +32 -7
  20. data/lib/cucumber/cli/main.rb +26 -30
  21. data/lib/cucumber/cli/options.rb +1 -3
  22. data/lib/cucumber/cli/profile_loader.rb +2 -0
  23. data/lib/cucumber/configuration.rb +37 -0
  24. data/lib/cucumber/errors.rb +40 -0
  25. data/lib/cucumber/feature_file.rb +5 -12
  26. data/lib/cucumber/formatter/junit.rb +2 -2
  27. data/lib/cucumber/formatter/tag_cloud.rb +1 -1
  28. data/lib/cucumber/js_support/js_dsl.js +4 -4
  29. data/lib/cucumber/js_support/js_language.rb +9 -5
  30. data/lib/cucumber/language_support.rb +2 -2
  31. data/lib/cucumber/parser/gherkin_builder.rb +19 -19
  32. data/lib/cucumber/platform.rb +3 -4
  33. data/lib/cucumber/rake/task.rb +1 -7
  34. data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
  35. data/lib/cucumber/rb_support/rb_language.rb +1 -0
  36. data/lib/cucumber/rspec/doubles.rb +3 -3
  37. data/lib/cucumber/runtime.rb +192 -0
  38. data/lib/cucumber/runtime/features_loader.rb +62 -0
  39. data/lib/cucumber/runtime/results.rb +46 -0
  40. data/lib/cucumber/runtime/support_code.rb +174 -0
  41. data/lib/cucumber/runtime/user_interface.rb +80 -0
  42. data/lib/cucumber/step_mother.rb +6 -427
  43. data/lib/cucumber/wire_support/configuration.rb +2 -0
  44. data/lib/cucumber/wire_support/wire_language.rb +1 -8
  45. data/spec/cucumber/ast/background_spec.rb +3 -3
  46. data/spec/cucumber/ast/feature_spec.rb +2 -2
  47. data/spec/cucumber/ast/scenario_outline_spec.rb +1 -1
  48. data/spec/cucumber/ast/scenario_spec.rb +1 -2
  49. data/spec/cucumber/ast/tree_walker_spec.rb +1 -1
  50. data/spec/cucumber/cli/configuration_spec.rb +31 -5
  51. data/spec/cucumber/cli/drb_client_spec.rb +1 -1
  52. data/spec/cucumber/cli/main_spec.rb +8 -37
  53. data/spec/cucumber/cli/options_spec.rb +20 -0
  54. data/spec/cucumber/formatter/spec_helper.rb +5 -7
  55. data/spec/cucumber/rb_support/rb_language_spec.rb +2 -2
  56. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -1
  57. data/spec/cucumber/runtime_spec.rb +294 -0
  58. data/spec/cucumber/step_match_spec.rb +10 -8
  59. data/spec/cucumber/world/pending_spec.rb +1 -1
  60. data/spec/spec_helper.rb +2 -21
  61. metadata +215 -84
  62. data/Caliper.yml +0 -4
  63. data/VERSION.yml +0 -5
  64. data/spec/cucumber/step_mother_spec.rb +0 -302
@@ -1,4 +0,0 @@
1
- ---
2
- # Config for https://devver.net/caliper
3
- file_globs_to_ignore:
4
- - lib/rubygems/**/*
@@ -1,5 +0,0 @@
1
- ---
2
- :patch: 7
3
- :build:
4
- :major: 0
5
- :minor: 8
@@ -1,302 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- require 'cucumber'
4
- require 'cucumber/rb_support/rb_language'
5
-
6
- module Cucumber
7
- describe StepMother do
8
- before do
9
- @dsl = Object.new
10
- @dsl.extend(RbSupport::RbDsl)
11
-
12
- @step_mother = StepMother.new
13
-
14
- @rb = @step_mother.load_programming_language('rb')
15
-
16
- @visitor = mock('Visitor')
17
- end
18
-
19
- it "should format step names" do
20
- @dsl.Given(/it (.*) in (.*)/) do |what, month|
21
- end
22
- @dsl.Given(/nope something else/) do |what, month|
23
- end
24
-
25
- format = @step_mother.step_match("it snows in april").format_args("[%s]")
26
- format.should == "it [snows] in [april]"
27
- end
28
-
29
- it "should raise Ambiguous error with guess hint when multiple step definitions match" do
30
- @dsl.Given(/Three (.*) mice/) {|disability|}
31
- @dsl.Given(/Three blind (.*)/) {|animal|}
32
-
33
- lambda do
34
- @step_mother.step_match("Three blind mice")
35
- end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
36
-
37
- spec/cucumber/step_mother_spec.rb:30:in `/Three (.*) mice/'
38
- spec/cucumber/step_mother_spec.rb:31:in `/Three blind (.*)/'
39
-
40
- You can run again with --guess to make Cucumber be more smart about it
41
- })
42
- end
43
-
44
- it "should not show --guess hint when --guess is used" do
45
- @step_mother.options = {:guess => true}
46
-
47
- @dsl.Given(/Three (.*) mice/) {|disability|}
48
- @dsl.Given(/Three cute (.*)/) {|animal|}
49
-
50
- lambda do
51
- @step_mother.step_match("Three cute mice")
52
- end.should raise_error(Ambiguous, %{Ambiguous match of "Three cute mice":
53
-
54
- spec/cucumber/step_mother_spec.rb:47:in `/Three (.*) mice/'
55
- spec/cucumber/step_mother_spec.rb:48:in `/Three cute (.*)/'
56
-
57
- })
58
- end
59
-
60
- it "should not raise Ambiguous error when multiple step definitions match, but --guess is enabled" do
61
- @step_mother.options = {:guess => true}
62
- @dsl.Given(/Three (.*) mice/) {|disability|}
63
- @dsl.Given(/Three (.*)/) {|animal|}
64
-
65
- lambda do
66
- @step_mother.step_match("Three blind mice")
67
- end.should_not raise_error
68
- end
69
-
70
- it "should not raise NoMethodError when guessing from multiple step definitions with nil fields" do
71
- @step_mother.options = {:guess => true}
72
- @dsl.Given(/Three (.*) mice( cannot find food)?/) {|disability, is_disastrous|}
73
- @dsl.Given(/Three (.*)?/) {|animal|}
74
-
75
- lambda do
76
- @step_mother.step_match("Three blind mice")
77
- end.should_not raise_error
78
- end
79
-
80
- it "should pick right step definition when --guess is enabled and equal number of capture groups" do
81
- @step_mother.options = {:guess => true}
82
- right = @dsl.Given(/Three (.*) mice/) {|disability|}
83
- wrong = @dsl.Given(/Three (.*)/) {|animal|}
84
-
85
- @step_mother.step_match("Three blind mice").step_definition.should == right
86
- end
87
-
88
- it "should pick right step definition when --guess is enabled and unequal number of capture groups" do
89
- @step_mother.options = {:guess => true}
90
- right = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
91
- wrong = @dsl.Given(/Three (.*)/) {|animal|}
92
-
93
- @step_mother.step_match("Three blind mice ran far").step_definition.should == right
94
- end
95
-
96
- it "should pick most specific step definition when --guess is enabled and unequal number of capture groups" do
97
- @step_mother.options = {:guess => true}
98
- general = @dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
99
- specific = @dsl.Given(/Three blind mice ran far/) do; end
100
- more_specific = @dsl.Given(/^Three blind mice ran far$/) do; end
101
-
102
- @step_mother.step_match("Three blind mice ran far").step_definition.should == more_specific
103
- end
104
-
105
- it "should raise Undefined error when no step definitions match" do
106
- lambda do
107
- @step_mother.step_match("Three blind mice")
108
- end.should raise_error(Undefined)
109
- end
110
-
111
- # http://railsforum.com/viewtopic.php?pid=93881
112
- it "should not raise Redundant unless it's really redundant" do
113
- @dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
114
- @dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
115
- end
116
-
117
- it "should raise an error if the world is nil" do
118
- @dsl.World {}
119
-
120
- begin
121
- @step_mother.before_and_after(nil) do; end
122
- raise "Should fail"
123
- rescue RbSupport::NilWorld => e
124
- e.message.should == "World procs should never return nil"
125
- e.backtrace.should == ["spec/cucumber/step_mother_spec.rb:118:in `World'"]
126
- end
127
- end
128
-
129
- module ModuleOne
130
- end
131
-
132
- module ModuleTwo
133
- end
134
-
135
- class ClassOne
136
- end
137
-
138
- it "should implicitly extend world with modules" do
139
- @dsl.World(ModuleOne, ModuleTwo)
140
- @step_mother.before(mock('scenario').as_null_object)
141
- class << @rb.current_world
142
- included_modules.inspect.should =~ /ModuleOne/ # Workaround for RSpec/Ruby 1.9 issue with namespaces
143
- included_modules.inspect.should =~ /ModuleTwo/
144
- end
145
- @rb.current_world.class.should == Object
146
- end
147
-
148
- it "should raise error when we try to register more than one World proc" do
149
- @dsl.World { Hash.new }
150
- lambda do
151
- @dsl.World { Array.new }
152
- end.should raise_error(RbSupport::MultipleWorld, %{You can only pass a proc to #World once, but it's happening
153
- in 2 places:
154
-
155
- spec/cucumber/step_mother_spec.rb:149:in `World'
156
- spec/cucumber/step_mother_spec.rb:151:in `World'
157
-
158
- Use Ruby modules instead to extend your worlds. See the Cucumber::RbSupport::RbDsl#World RDoc
159
- or http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world.
160
-
161
- })
162
- end
163
-
164
- it "should find before hooks" do
165
- fish = @dsl.Before('@fish'){}
166
- meat = @dsl.Before('@meat'){}
167
-
168
- scenario = mock('Scenario')
169
- scenario.should_receive(:accept_hook?).with(fish).and_return(true)
170
- scenario.should_receive(:accept_hook?).with(meat).and_return(false)
171
-
172
- @rb.hooks_for(:before, scenario).should == [fish]
173
- end
174
-
175
- it "should find around hooks" do
176
- a = @dsl.Around do |scenario, block|
177
- end
178
-
179
- b = @dsl.Around('@tag') do |scenario, block|
180
- end
181
-
182
- scenario = mock('Scenario')
183
- scenario.should_receive(:accept_hook?).with(a).and_return(true)
184
- scenario.should_receive(:accept_hook?).with(b).and_return(false)
185
-
186
- @rb.hooks_for(:around, scenario).should == [a]
187
- end
188
- end
189
-
190
- describe StepMother, "step argument transformations" do
191
- before do
192
- @dsl = Object.new
193
- @dsl.extend(RbSupport::RbDsl)
194
-
195
- @step_mother = StepMother.new
196
-
197
- @rb = @step_mother.load_programming_language('rb')
198
- end
199
-
200
- describe "without capture groups" do
201
- it "complains when registering with a with no transform block" do
202
- lambda do
203
- @dsl.Transform('^abc$')
204
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
205
- end
206
-
207
- it "complains when registering with a zero-arg transform block" do
208
- lambda do
209
- @dsl.Transform('^abc$') {42}
210
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
211
- end
212
-
213
- it "complains when registering with a splat-arg transform block" do
214
- lambda do
215
- @dsl.Transform('^abc$') {|*splat| 42 }
216
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
217
- end
218
-
219
- it "complains when transforming with an arity mismatch" do
220
- lambda do
221
- @dsl.Transform('^abc$') {|one, two| 42 }
222
- @rb.execute_transforms(['abc'])
223
- end.should raise_error(Cucumber::ArityMismatchError)
224
- end
225
-
226
- it "allows registering a regexp pattern that yields the step_arg matched" do
227
- @dsl.Transform(/^ab*c$/) {|arg| 42}
228
- @rb.execute_transforms(['ab']).should == ['ab']
229
- @rb.execute_transforms(['ac']).should == [42]
230
- @rb.execute_transforms(['abc']).should == [42]
231
- @rb.execute_transforms(['abbc']).should == [42]
232
- end
233
- end
234
-
235
- describe "with capture groups" do
236
- it "complains when registering with a with no transform block" do
237
- lambda do
238
- @dsl.Transform('^a(.)c$')
239
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
240
- end
241
-
242
- it "complains when registering with a zero-arg transform block" do
243
- lambda do
244
- @dsl.Transform('^a(.)c$') { 42 }
245
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
246
- end
247
-
248
- it "complains when registering with a splat-arg transform block" do
249
- lambda do
250
- @dsl.Transform('^a(.)c$') {|*splat| 42 }
251
- end.should raise_error(Cucumber::RbSupport::RbTransform::MissingProc)
252
- end
253
-
254
- it "complains when transforming with an arity mismatch" do
255
- lambda do
256
- @dsl.Transform('^a(.)c$') {|one, two| 42 }
257
- @rb.execute_transforms(['abc'])
258
- end.should raise_error(Cucumber::ArityMismatchError)
259
- end
260
-
261
- it "allows registering a regexp pattern that yields capture groups" do
262
- @dsl.Transform(/^shape: (.+), color: (.+)$/) do |shape, color|
263
- {shape.to_sym => color.to_sym}
264
- end
265
- @rb.execute_transforms(['shape: circle, color: blue']).should == [{:circle => :blue}]
266
- @rb.execute_transforms(['shape: square, color: red']).should == [{:square => :red}]
267
- @rb.execute_transforms(['not shape: square, not color: red']).should == ['not shape: square, not color: red']
268
- end
269
- end
270
-
271
- it "allows registering a string pattern" do
272
- @dsl.Transform('^ab*c$') {|arg| 42}
273
- @rb.execute_transforms(['ab']).should == ['ab']
274
- @rb.execute_transforms(['ac']).should == [42]
275
- @rb.execute_transforms(['abc']).should == [42]
276
- @rb.execute_transforms(['abbc']).should == [42]
277
- end
278
-
279
- it "gives match priority to transforms defined last" do
280
- @dsl.Transform(/^transform_me$/) {|arg| :foo }
281
- @dsl.Transform(/^transform_me$/) {|arg| :bar }
282
- @dsl.Transform(/^transform_me$/) {|arg| :baz }
283
- @rb.execute_transforms(['transform_me']).should == [:baz]
284
- end
285
-
286
- it "allows registering a transform which returns nil" do
287
- @dsl.Transform('^ac$') {|arg| nil}
288
- @rb.execute_transforms(['ab']).should == ['ab']
289
- @rb.execute_transforms(['ac']).should == [nil]
290
- end
291
- end
292
-
293
- end
294
-
295
- module ModuleOne
296
- end
297
-
298
- module ModuleTwo
299
- end
300
-
301
- class ClassOne
302
- end