cucumber 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,112 @@
1
+ require 'spec_helper'
2
+
3
+ module Cucumber
4
+ describe Runtime::SupportCode do
5
+ let(:user_interface) { double('user interface') }
6
+ subject { Runtime::SupportCode.new(user_interface, options) }
7
+ let(:options) { {} }
8
+ let(:dsl) do
9
+ @rb = subject.load_programming_language('rb')
10
+ Object.new.extend(RbSupport::RbDsl)
11
+ end
12
+
13
+ it "should format step names" do
14
+ dsl.Given(/it (.*) in (.*)/) { |what, month| }
15
+ dsl.Given(/nope something else/) { |what, month| }
16
+
17
+ format = subject.step_match("it snows in april").format_args("[%s]")
18
+ format.should == "it [snows] in [april]"
19
+ end
20
+
21
+ describe "resolving step defintion matches" do
22
+
23
+ it "should raise Ambiguous error with guess hint when multiple step definitions match" do
24
+ expected_error = %{Ambiguous match of "Three blind mice":
25
+
26
+ spec/cucumber/runtime/support_code_spec.rb:\\d+:in `/Three (.*) mice/'
27
+ spec/cucumber/runtime/support_code_spec.rb:\\d+:in `/Three blind (.*)/'
28
+
29
+ You can run again with --guess to make Cucumber be more smart about it
30
+ }
31
+ dsl.Given(/Three (.*) mice/) {|disability|}
32
+ dsl.Given(/Three blind (.*)/) {|animal|}
33
+
34
+ lambda do
35
+ subject.step_match("Three blind mice")
36
+ end.should raise_error(Ambiguous, /#{expected_error}/)
37
+ end
38
+
39
+ describe "when --guess is used" do
40
+ let(:options) { {:guess => true} }
41
+
42
+ it "should not show --guess hint" do
43
+ expected_error = %{Ambiguous match of "Three cute mice":
44
+
45
+ spec/cucumber/runtime/support_code_spec.rb:\\d+:in `/Three (.*) mice/'
46
+ spec/cucumber/runtime/support_code_spec.rb:\\d+:in `/Three cute (.*)/'
47
+
48
+ }
49
+ dsl.Given(/Three (.*) mice/) {|disability|}
50
+ dsl.Given(/Three cute (.*)/) {|animal|}
51
+
52
+ lambda do
53
+ subject.step_match("Three cute mice")
54
+ end.should raise_error(Ambiguous, /#{expected_error}/)
55
+ end
56
+
57
+ it "should not raise Ambiguous error when multiple step definitions match" do
58
+ dsl.Given(/Three (.*) mice/) {|disability|}
59
+ dsl.Given(/Three (.*)/) {|animal|}
60
+
61
+ lambda do
62
+ subject.step_match("Three blind mice")
63
+ end.should_not raise_error
64
+ end
65
+
66
+ it "should not raise NoMethodError when guessing from multiple step definitions with nil fields" do
67
+ dsl.Given(/Three (.*) mice( cannot find food)?/) {|disability, is_disastrous|}
68
+ dsl.Given(/Three (.*)?/) {|animal|}
69
+
70
+ lambda do
71
+ subject.step_match("Three blind mice")
72
+ end.should_not raise_error
73
+ end
74
+
75
+ it "should pick right step definition when an equal number of capture groups" do
76
+ right = dsl.Given(/Three (.*) mice/) {|disability|}
77
+ wrong = dsl.Given(/Three (.*)/) {|animal|}
78
+
79
+ subject.step_match("Three blind mice").step_definition.should == right
80
+ end
81
+
82
+ it "should pick right step definition when an unequal number of capture groups" do
83
+ right = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
84
+ wrong = dsl.Given(/Three (.*)/) {|animal|}
85
+
86
+ subject.step_match("Three blind mice ran far").step_definition.should == right
87
+ end
88
+
89
+ it "should pick most specific step definition when an unequal number of capture groups" do
90
+ general = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
91
+ specific = dsl.Given(/Three blind mice ran far/) do; end
92
+ more_specific = dsl.Given(/^Three blind mice ran far$/) do; end
93
+
94
+ subject.step_match("Three blind mice ran far").step_definition.should == more_specific
95
+ end
96
+ end
97
+
98
+ it "should raise Undefined error when no step definitions match" do
99
+ lambda do
100
+ subject.step_match("Three blind mice")
101
+ end.should raise_error(Undefined)
102
+ end
103
+
104
+ # http://railsforum.com/viewtopic.php?pid=93881
105
+ it "should not raise Redundant unless it's really redundant" do
106
+ dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
107
+ dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
108
+ end
109
+ end
110
+
111
+ end
112
+ end
@@ -4,19 +4,7 @@ module Cucumber
4
4
  describe Runtime do
5
5
  subject { Runtime.new(options) }
6
6
  let(:options) { {} }
7
- let(:dsl) do
8
- @rb = subject.load_programming_language('rb')
9
- Object.new.extend(RbSupport::RbDsl)
10
- end
11
7
 
12
- it "should format step names" do
13
- dsl.Given(/it (.*) in (.*)/) { |what, month| }
14
- dsl.Given(/nope something else/) { |what, month| }
15
-
16
- format = subject.step_match("it snows in april").format_args("[%s]")
17
- format.should == "it [snows] in [april]"
18
- end
19
-
20
8
  describe "#features_paths" do
21
9
  let(:options) { {:paths => ['foo/bar/baz.feature', 'foo/bar/features/baz.feature', 'other_features'] } }
22
10
  it "returns the value from configuration.paths" do
@@ -24,271 +12,30 @@ describe Runtime do
24
12
  end
25
13
  end
26
14
 
27
- describe "resolving step defintion matches" do
28
-
29
- it "should raise Ambiguous error with guess hint when multiple step definitions match" do
30
- expected_error = %{Ambiguous match of "Three blind mice":
31
-
32
- spec/cucumber/runtime_spec.rb:\\d+:in `/Three (.*) mice/'
33
- spec/cucumber/runtime_spec.rb:\\d+:in `/Three blind (.*)/'
34
-
35
- You can run again with --guess to make Cucumber be more smart about it
36
- }
37
- dsl.Given(/Three (.*) mice/) {|disability|}
38
- dsl.Given(/Three blind (.*)/) {|animal|}
39
-
40
- lambda do
41
- subject.step_match("Three blind mice")
42
- end.should raise_error(Ambiguous, /#{expected_error}/)
43
- end
44
-
45
- describe "when --guess is used" do
46
- let(:options) { {:guess => true} }
47
-
48
- it "should not show --guess hint" do
49
- expected_error = %{Ambiguous match of "Three cute mice":
50
-
51
- spec/cucumber/runtime_spec.rb:\\d+:in `/Three (.*) mice/'
52
- spec/cucumber/runtime_spec.rb:\\d+:in `/Three cute (.*)/'
53
-
54
- }
55
- dsl.Given(/Three (.*) mice/) {|disability|}
56
- dsl.Given(/Three cute (.*)/) {|animal|}
57
-
58
- lambda do
59
- subject.step_match("Three cute mice")
60
- end.should raise_error(Ambiguous, /#{expected_error}/)
61
- end
62
-
63
- it "should not raise Ambiguous error when multiple step definitions match" do
64
- dsl.Given(/Three (.*) mice/) {|disability|}
65
- dsl.Given(/Three (.*)/) {|animal|}
66
-
67
- lambda do
68
- subject.step_match("Three blind mice")
69
- end.should_not raise_error
70
- end
71
-
72
- it "should not raise NoMethodError when guessing from multiple step definitions with nil fields" do
73
- dsl.Given(/Three (.*) mice( cannot find food)?/) {|disability, is_disastrous|}
74
- dsl.Given(/Three (.*)?/) {|animal|}
75
-
76
- lambda do
77
- subject.step_match("Three blind mice")
78
- end.should_not raise_error
79
- end
80
-
81
- it "should pick right step definition when an equal number of capture groups" do
82
- right = dsl.Given(/Three (.*) mice/) {|disability|}
83
- wrong = dsl.Given(/Three (.*)/) {|animal|}
84
-
85
- subject.step_match("Three blind mice").step_definition.should == right
86
- end
87
-
88
- it "should pick right step definition when an unequal number of capture groups" do
89
- right = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
90
- wrong = dsl.Given(/Three (.*)/) {|animal|}
91
-
92
- subject.step_match("Three blind mice ran far").step_definition.should == right
93
- end
94
-
95
- it "should pick most specific step definition when an unequal number of capture groups" do
96
- general = dsl.Given(/Three (.*) mice ran (.*)/) {|disability|}
97
- specific = dsl.Given(/Three blind mice ran far/) do; end
98
- more_specific = dsl.Given(/^Three blind mice ran far$/) do; end
99
-
100
- subject.step_match("Three blind mice ran far").step_definition.should == more_specific
101
- end
102
- end
103
-
104
- it "should raise Undefined error when no step definitions match" do
105
- lambda do
106
- subject.step_match("Three blind mice")
107
- end.should raise_error(Undefined)
108
- end
109
-
110
- # http://railsforum.com/viewtopic.php?pid=93881
111
- it "should not raise Redundant unless it's really redundant" do
112
- dsl.Given(/^(.*) (.*) user named '(.*)'$/) {|a,b,c|}
113
- dsl.Given(/^there is no (.*) user named '(.*)'$/) {|a,b|}
114
- end
115
- end
116
-
117
- describe "Handling the World" do
118
-
119
- it "should raise an error if the world is nil" do
120
- dsl.World {}
121
-
122
- begin
123
- subject.before_and_after(nil) do; end
124
- raise "Should fail"
125
- rescue RbSupport::NilWorld => e
126
- e.message.should == "World procs should never return nil"
127
- e.backtrace.length.should == 1
128
- e.backtrace[0].should =~ /spec\/cucumber\/runtime_spec\.rb\:\d+\:in `World'/
129
- end
130
- end
131
-
132
- module ModuleOne
133
- end
134
-
135
- module ModuleTwo
136
- end
137
-
138
- class ClassOne
139
- end
140
-
141
- it "should implicitly extend world with modules" do
142
- dsl.World(ModuleOne, ModuleTwo)
143
- subject.before(mock('scenario').as_null_object)
144
- class << @rb.current_world
145
- included_modules.inspect.should =~ /ModuleOne/ # Workaround for RSpec/Ruby 1.9 issue with namespaces
146
- included_modules.inspect.should =~ /ModuleTwo/
147
- end
148
- @rb.current_world.class.should == Object
149
- end
150
-
151
- it "should raise error when we try to register more than one World proc" do
152
- expected_error = %{You can only pass a proc to #World once, but it's happening
153
- in 2 places:
154
-
155
- spec/cucumber/runtime_spec.rb:\\d+:in `World'
156
- spec/cucumber/runtime_spec.rb:\\d+: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
- dsl.World { Hash.new }
163
- lambda do
164
- dsl.World { Array.new }
165
- end.should raise_error(RbSupport::MultipleWorld, /#{expected_error}/)
166
-
167
- end
168
- end
169
-
170
- describe "hooks" do
171
-
172
- it "should find before hooks" do
173
- fish = dsl.Before('@fish'){}
174
- meat = dsl.Before('@meat'){}
175
-
176
- scenario = mock('Scenario')
177
- scenario.should_receive(:accept_hook?).with(fish).and_return(true)
178
- scenario.should_receive(:accept_hook?).with(meat).and_return(false)
179
-
180
- @rb.hooks_for(:before, scenario).should == [fish]
181
- end
182
-
183
- it "should find around hooks" do
184
- a = dsl.Around do |scenario, block|
185
- end
186
-
187
- b = dsl.Around('@tag') do |scenario, block|
188
- end
189
-
190
- scenario = mock('Scenario')
191
- scenario.should_receive(:accept_hook?).with(a).and_return(true)
192
- scenario.should_receive(:accept_hook?).with(b).and_return(false)
193
-
194
- @rb.hooks_for(:around, scenario).should == [a]
195
- end
196
- end
197
-
198
- describe "step argument transformations" do
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
15
+ describe "#configure" do
16
+ let(:support_code) { double(Runtime::SupportCode).as_null_object }
17
+ let(:results) { double(Runtime::Results).as_null_object }
18
+ let(:new_configuration) { double('New configuration')}
19
+ before(:each) do
20
+ Runtime::SupportCode.stub(:new => support_code)
21
+ Runtime::Results.stub(:new => results)
269
22
  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]
23
+
24
+ it "tells the support_code and results about the new configuration" do
25
+ support_code.should_receive(:configure).with(new_configuration)
26
+ results.should_receive(:configure).with(new_configuration)
27
+ subject.configure(new_configuration)
284
28
  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]
29
+
30
+ it "replaces the existing configuration" do
31
+ # not really sure how to test this. Maybe we should just expose
32
+ # Runtime#configuration with an attr_reader?
33
+ some_new_paths = ['foo/bar', 'baz']
34
+ new_configuration.stub(:paths => some_new_paths)
35
+ subject.configure(new_configuration)
36
+ subject.features_paths.should == some_new_paths
290
37
  end
291
38
  end
292
-
39
+
293
40
  end
294
41
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Aslak Helles\xC3\xB8y"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-04 00:00:00 +02:00
17
+ date: 2010-10-24 00:00:00 +01:00
18
18
  default_executable: cucumber
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 2
29
29
  - 2
30
- - 5
31
- version: 2.2.5
30
+ - 9
31
+ version: 2.2.9
32
32
  type: :runtime
33
33
  prerelease: false
34
34
  version_requirements: *id001
@@ -471,6 +471,7 @@ files:
471
471
  - examples/watir/features/support/screenshots.rb
472
472
  - features/announce.feature
473
473
  - features/api/list_step_defs_as_json.feature
474
+ - features/api/run_cli_main_with_existing_runtime.feature
474
475
  - features/around_hooks.feature
475
476
  - features/background.feature
476
477
  - features/bug_371.feature
@@ -644,6 +645,7 @@ files:
644
645
  - lib/cucumber/cli/profile_loader.rb
645
646
  - lib/cucumber/configuration.rb
646
647
  - lib/cucumber/constantize.rb
648
+ - lib/cucumber/core_ext/disable_mini_unit_autorun.rb
647
649
  - lib/cucumber/core_ext/instance_exec.rb
648
650
  - lib/cucumber/core_ext/proc.rb
649
651
  - lib/cucumber/core_ext/string.rb
@@ -696,6 +698,7 @@ files:
696
698
  - lib/cucumber/rspec/doubles.rb
697
699
  - lib/cucumber/runtime.rb
698
700
  - lib/cucumber/runtime/features_loader.rb
701
+ - lib/cucumber/runtime/for_programming_languages.rb
699
702
  - lib/cucumber/runtime/results.rb
700
703
  - lib/cucumber/runtime/support_code.rb
701
704
  - lib/cucumber/runtime/user_interface.rb
@@ -741,6 +744,7 @@ files:
741
744
  - spec/cucumber/rb_support/rb_language_spec.rb
742
745
  - spec/cucumber/rb_support/rb_step_definition_spec.rb
743
746
  - spec/cucumber/rb_support/regexp_argument_matcher_spec.rb
747
+ - spec/cucumber/runtime/support_code_spec.rb
744
748
  - spec/cucumber/runtime_spec.rb
745
749
  - spec/cucumber/sell_cucumbers.feature
746
750
  - spec/cucumber/step_match_spec.rb
@@ -758,7 +762,7 @@ licenses: []
758
762
 
759
763
  post_install_message: "\n\
760
764
  (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n\
761
- Thank you for installing cucumber-0.9.2.\n\
765
+ Thank you for installing cucumber-0.9.3.\n\
762
766
  Please be sure to read http://wiki.github.com/aslakhellesoy/cucumber/upgrading\n\
763
767
  for important information about this release. Happy cuking!\n\n\
764
768
  (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n"
@@ -771,7 +775,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
771
775
  requirements:
772
776
  - - ">="
773
777
  - !ruby/object:Gem::Version
774
- hash: -4350081560409194563
778
+ hash: 4045923160433736312
775
779
  segments:
776
780
  - 0
777
781
  version: "0"
@@ -780,7 +784,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
780
784
  requirements:
781
785
  - - ">="
782
786
  - !ruby/object:Gem::Version
783
- hash: -4350081560409194563
787
+ hash: 4045923160433736312
784
788
  segments:
785
789
  - 0
786
790
  version: "0"
@@ -790,10 +794,11 @@ rubyforge_project:
790
794
  rubygems_version: 1.3.7
791
795
  signing_key:
792
796
  specification_version: 3
793
- summary: cucumber-0.9.2
797
+ summary: cucumber-0.9.3
794
798
  test_files:
795
799
  - features/announce.feature
796
800
  - features/api/list_step_defs_as_json.feature
801
+ - features/api/run_cli_main_with_existing_runtime.feature
797
802
  - features/around_hooks.feature
798
803
  - features/background.feature
799
804
  - features/bug_371.feature
@@ -876,6 +881,7 @@ test_files:
876
881
  - spec/cucumber/rb_support/rb_language_spec.rb
877
882
  - spec/cucumber/rb_support/rb_step_definition_spec.rb
878
883
  - spec/cucumber/rb_support/regexp_argument_matcher_spec.rb
884
+ - spec/cucumber/runtime/support_code_spec.rb
879
885
  - spec/cucumber/runtime_spec.rb
880
886
  - spec/cucumber/sell_cucumbers.feature
881
887
  - spec/cucumber/step_match_spec.rb