aslakhellesoy-cucumber 0.1.99.15 → 0.1.99.17

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.
@@ -5,233 +5,47 @@ module Cucumber
5
5
  module Cli
6
6
  describe Main do
7
7
 
8
- def mock_executor(stubs = {})
9
- stub('executor', {:visit_features => nil, :lines_for_features= => nil, :failed => false, :formatters= => nil}.merge(stubs))
10
- end
11
-
12
- def mock_broadcaster(stubs = {})
13
- stub(Broadcaster, {:register => nil}.merge(stubs))
14
- end
15
-
16
- def mock_features(stubs ={})
17
- stub('features', {:<< => nil}.merge(stubs))
18
- end
19
-
20
8
  before(:each) do
21
9
  Kernel.stub!(:exit).and_return(nil)
22
10
  end
23
-
24
- def given_cucumber_yml_defined_as(hash_or_string)
25
- File.stub!(:exist?).and_return(true)
26
- cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
27
- IO.stub!(:read).with('cucumber.yml').and_return(cucumber_yml)
28
- end
29
-
30
- it "should expand args from YAML file" do
31
- cli = Main.new
32
-
33
- given_cucumber_yml_defined_as({'bongo' => '--require from/yml'})
34
-
35
- cli.parse_options!(%w{--format progress --profile bongo})
36
- cli.options[:formats].should == {'progress' => STDOUT}
37
- cli.options[:require].should == ['from/yml']
38
- end
39
-
40
- it "should expand args from YAML file's default if there are no args" do
41
- cli = Main.new
42
-
43
- given_cucumber_yml_defined_as({'default' => '--require from/yml'})
44
-
45
- cli.parse_options!([])
46
- cli.options[:require].should == ['from/yml']
47
- end
48
-
49
- it "should provide a helpful error message when a specified profile does not exists in YAML file" do
50
- cli = Main.new(StringIO.new, error = StringIO.new)
51
-
52
- given_cucumber_yml_defined_as({'default' => '--require from/yml', 'html_report' => '--format html'})
53
-
54
- cli.parse_options!(%w{--profile i_do_not_exist})
55
-
56
- expected_message = <<-END_OF_MESSAGE
57
- Could not find profile: 'i_do_not_exist'
58
-
59
- Defined profiles in cucumber.yml:
60
- * default
61
- * html_report
62
- END_OF_MESSAGE
63
-
64
- error.string.should == expected_message
65
- end
66
-
67
- it "should provide a helpful error message when a specified profile is not a String" do
68
- cli = Main.new(StringIO.new, error = StringIO.new)
69
-
70
- given_cucumber_yml_defined_as({'foo' => [1,2,3]})
71
-
72
- cli.parse_options!(%w{--profile foo})
73
-
74
- error.string.should == "Profiles must be defined as a String. The 'foo' profile was [1, 2, 3] (Array).\n"
75
- end
76
-
77
- it "should provide a helpful error message when a specified profile exists but is nil or blank" do
78
- [nil, ' '].each do |bad_input|
79
- cli = Main.new(StringIO.new, error = StringIO.new)
80
-
81
- given_cucumber_yml_defined_as({'foo' => bad_input})
82
-
83
- cli.parse_options!(%w{--profile foo})
84
-
85
- error.string.should match(/The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml./)
86
- end
87
- end
88
-
89
- it "should provide a helpful error message when no YAML file exists and a profile is specified" do
90
- cli = Main.new(StringIO.new, error = StringIO.new)
91
-
92
- File.should_receive(:exist?).with('cucumber.yml').and_return(false)
93
-
94
- cli.parse_options!(%w{--profile i_do_not_exist})
95
-
96
- error.string.should match(/cucumber.yml was not found. Please refer to cucumber's documentaion on defining profiles in cucumber.yml./)
97
- end
98
-
99
- it "should provide a helpful error message when cucumber.yml is blank or malformed" do
100
- expected_error_message = /cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentaion on correct profile usage./
101
-
102
- ['', 'sfsadfs', "--- \n- an\n- array\n", "---dddfd"].each do |bad_input|
103
- cli = Main.new(StringIO.new, error = StringIO.new)
104
-
105
- given_cucumber_yml_defined_as(bad_input)
106
- cli.parse_options!([])
107
-
108
- error.string.should match(expected_error_message)
109
- end
110
- end
111
-
112
- it "should procide a helpful error message when the YAML can not be parsed" do
113
- expected_error_message = /cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentaion on correct profile usage./
114
- cli = Main.new(StringIO.new, error = StringIO.new)
115
-
116
- given_cucumber_yml_defined_as("input that causes an exception in YAML loading")
117
- YAML.should_receive(:load).and_raise Exception
118
-
119
- cli.parse_options!([])
120
-
121
- error.string.should match(expected_error_message)
122
- end
123
-
124
- it "should accept --dry-run option" do
125
- cli = Main.new(StringIO.new)
126
- cli.parse_options!(%w{--dry-run})
127
- cli.options[:dry_run].should be_true
128
- cli.execute!(stub('step mother'))
129
- end
130
-
131
- it "should accept --no-source option" do
132
- cli = Main.new
133
- cli.parse_options!(%w{--no-source})
134
-
135
- cli.options[:source].should be_false
136
- end
137
-
138
- it "should accept --no-snippets option" do
139
- cli = Main.new
140
- cli.parse_options!(%w{--no-snippets})
141
-
142
- cli.options[:snippets].should be_false
143
- end
144
-
145
- it "should set snippets and source to false with --quiet option" do
146
- cli = Main.new
147
- cli.parse_options!(%w{--quiet})
148
-
149
- cli.options[:snippets].should be_nil
150
- cli.options[:source].should be_nil
151
- end
152
-
153
- it "should accept --verbose option" do
154
- cli = Main.new
155
- cli.parse_options!(%w{--verbose})
156
-
157
- cli.options[:verbose].should be_true
158
- end
159
-
160
- it "should require files in support paths first" do
161
- File.stub!(:directory?).and_return(true)
162
- Dir.stub!(:[]).and_return(["/features/step_definitions/foo.rb","/features/support/env.rb"])
163
-
164
- cli = Main.new(StringIO.new)
165
- cli.parse_options!(%w{--require /features})
166
-
167
- cli.should_receive(:require).with("/features/support/env.rb").ordered
168
- cli.should_receive(:require).with("/features/step_definitions/foo.rb").ordered
169
- cli.should_receive(:require).with("spec/expectations/differs/default").ordered
170
-
171
- cli.execute!(stub('step mother'))
172
- end
173
11
 
174
12
  describe "verbose mode" do
175
13
 
176
14
  before(:each) do
177
15
  @out = StringIO.new
178
- @cli = Main.new(@out)
179
- @cli.stub!(:require)
180
16
  @empty_feature = Ast::Feature.new(Ast::Comment.new(''), Ast::Tags.new(2, []), "Feature", [])
181
17
  Dir.stub!(:[])
182
18
  end
183
19
 
184
20
  it "should show ruby files required" do
185
- @cli.parse_options!(%w{--verbose --require example.rb})
186
- @cli.execute!(stub('step mother'))
21
+ @cli = Main.new(%w{--verbose --require example.rb}, @out)
22
+ @cli.stub!(:require)
23
+
24
+ @cli.execute!(Object.new.extend(StepMother))
187
25
 
188
26
  @out.string.should include('example.rb')
189
27
  end
190
28
 
191
29
  it "should show feature files parsed" do
30
+ @cli = Main.new(%w{--verbose example.feature}, @out)
31
+ @cli.stub!(:require)
32
+
192
33
  Parser::FeatureParser.stub!(:new).and_return(mock("feature parser", :parse_file => @empty_feature))
193
34
 
194
- @cli.parse_options!(%w{--verbose example.feature})
195
- @cli.execute!(stub('step mother'))
35
+ @cli.execute!(Object.new.extend(StepMother))
196
36
 
197
37
  @out.string.should include('example.feature')
198
38
  end
199
39
 
200
40
  end
201
41
 
202
- it "should accept --out option" do
203
- cli = Main.new(StringIO.new)
204
- cli.parse_options!(%w{--out jalla.txt})
205
- cli.options[:formats]['pretty'].should == 'jalla.txt'
206
- end
207
-
208
- it "should accept multiple --out options" do
209
- cli = Main.new(StringIO.new)
210
- cli.parse_options!(%w{--format progress --out file1 --out file2})
211
- cli.options[:formats].should == {'progress' => 'file2'}
212
- end
213
-
214
- it "should accept multiple --format options" do
215
- cli = Main.new(StringIO.new)
216
- cli.parse_options!(%w{--format pretty --format progress})
217
- cli.options[:formats].should have_key('pretty')
218
- cli.options[:formats].should have_key('progress')
219
- end
220
-
221
- it "should associate --out to previous --format" do
222
- cli = Main.new(StringIO.new)
223
- cli.parse_options!(%w{--format progress --out file1 --format profile --out file2})
224
- cli.options[:formats].should == {"profile"=>"file2", "progress"=>"file1"}
225
- end
226
-
227
42
  describe "--format with class" do
228
43
 
229
44
  describe "in module" do
230
45
 
231
46
  it "should resolve each module until it gets Formatter class" do
232
- cli = Main.new(nil)
47
+ cli = Main.new(%w{--format ZooModule::MonkeyFormatterClass}, nil)
233
48
  mock_module = mock('module')
234
- cli.parse_options!(%w{--format ZooModule::MonkeyFormatterClass})
235
49
  Object.stub!(:const_defined?).and_return(true)
236
50
  mock_module.stub!(:const_defined?).and_return(true)
237
51
 
@@ -240,7 +54,7 @@ END_OF_MESSAGE
240
54
  Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
241
55
  mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => f))
242
56
 
243
- cli.execute!(stub('step mother'))
57
+ cli.execute!(Object.new.extend(StepMother))
244
58
  end
245
59
 
246
60
  end
@@ -345,74 +159,6 @@ END_OF_MESSAGE
345
159
 
346
160
  end
347
161
 
348
- it "should accept multiple --scenario options" do
349
- cli = Main.new
350
- cli.parse_options!(['--scenario', "User logs in", '--scenario', "User signs up"])
351
- cli.options[:scenario_names].should include("User logs in")
352
- cli.options[:scenario_names].should include("User signs up")
353
- end
354
-
355
- xit "should register --scenario options with the executor" do
356
- cli = Main.new
357
- cli.parse_options!(['--scenario', "User logs in", '--scenario', "User signs up"])
358
- executor = mock_executor
359
- executor.should_receive(:scenario_names=).with(["User logs in", "User signs up"])
360
- cli.execute!(stub('step mother'), executor, stub('features'))
361
- end
362
-
363
- it "should accept --color option" do
364
- cli = Main.new(StringIO.new)
365
- Term::ANSIColor.should_receive(:coloring=).with(true)
366
- cli.parse_options!(['--color'])
367
- end
368
-
369
- it "should accept --no-color option" do
370
- cli = Main.new(StringIO.new)
371
- Term::ANSIColor.should_receive(:coloring=).with(false)
372
- cli.parse_options!(['--no-color'])
373
- end
374
-
375
- describe "--backtrace" do
376
- before do
377
- Exception.cucumber_full_backtrace = false
378
- end
379
-
380
- it "should show full backtrace when --backtrace is present" do
381
- cli = Main.new
382
- cli.parse_options!(['--backtrace'])
383
- begin
384
- "x".should == "y"
385
- rescue => e
386
- e.backtrace[0].should_not == "#{__FILE__}:#{__LINE__ - 2}"
387
- end
388
- end
389
-
390
- xit "should strip gems when --backtrace is absent" do
391
- cli = Main.new
392
- cli.parse_options!(['--'])
393
- begin
394
- "x".should == "y"
395
- rescue => e
396
- e.backtrace[0].should == "#{__FILE__}:#{__LINE__ - 2}"
397
- end
398
- end
399
-
400
- after do
401
- Exception.cucumber_full_backtrace = false
402
- end
403
- end
404
-
405
- it "should search for all features in the specified directory" do
406
- cli = Main.new(StringIO.new)
407
-
408
- cli.parse_options!(%w{feature_directory/})
409
- File.stub!(:directory?).and_return(true)
410
-
411
- Dir.should_receive(:[]).with("feature_directory/**/*.feature").any_number_of_times.and_return([])
412
-
413
- cli.execute!(stub('step mother'))
414
- end
415
-
416
162
  end
417
163
  end
418
164
  end
@@ -80,7 +80,7 @@ Feature: hi
80
80
  @st4
81
81
  Scenario: Second}).to_sexp.should ==
82
82
  [:feature, "Feature: hi",
83
- [:comment, "# FC\n"],
83
+ [:comment, "# FC\n "],
84
84
  [:tag, "ft"],
85
85
  [:scenario, 6, 'Scenario:', 'First',
86
86
  [:tag, "st1"], [:tag, "st2"],
@@ -46,7 +46,7 @@ module Cucumber
46
46
  lambda do
47
47
  @world.__cucumber_current_step = step
48
48
  step_definition('Outside').execute(nil, @world)
49
- end.should raise_error(StepMother::Undefined, 'Undefined step: "Inside"')
49
+ end.should raise_error(Undefined, 'Undefined step: "Inside"')
50
50
  end
51
51
 
52
52
  it "should allow forced pending" do
@@ -56,7 +56,7 @@ module Cucumber
56
56
 
57
57
  lambda do
58
58
  step_definition("Outside").execute(nil, @world)
59
- end.should raise_error(StepMother::Pending, "Do me!")
59
+ end.should raise_error(Pending, "Do me!")
60
60
  end
61
61
  end
62
62
  end
@@ -25,7 +25,7 @@ module Cucumber
25
25
 
26
26
  lambda do
27
27
  @step_mother.step_definition("Three blind mice")
28
- end.should raise_error(StepMother::Ambiguous, %{Ambiguous match of "Three blind mice":
28
+ end.should raise_error(Ambiguous, %{Ambiguous match of "Three blind mice":
29
29
 
30
30
  spec/cucumber/step_mother_spec.rb:23:in `/Three (.*) mice/'
31
31
  spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
@@ -33,17 +33,41 @@ spec/cucumber/step_mother_spec.rb:24:in `/Three blind (.*)/'
33
33
  })
34
34
  end
35
35
 
36
+ it "should not raise Ambiguous error when multiple step definitions match, but --guess is enabled" do
37
+ @step_mother.options = {:guess => true}
38
+ @step_mother.Given(/Three (.*) mice/) {|disability|}
39
+ @step_mother.Given(/Three (.*)/) {|animal|}
40
+
41
+ lambda do
42
+ @step_mother.step_definition("Three blind mice")
43
+ end.should_not raise_error
44
+ end
45
+
46
+ it "should pick right step definition when --guess is enabled and equal number of capture groups" do
47
+ @step_mother.options = {:guess => true}
48
+ right = @step_mother.Given(/Three (.*) mice/) {|disability|}
49
+ wrong = @step_mother.Given(/Three (.*)/) {|animal|}
50
+ @step_mother.step_definition("Three blind mice").should == right
51
+ end
52
+
53
+ it "should pick right step definition when --guess is enabled and unequal number of capture groups" do
54
+ @step_mother.options = {:guess => true}
55
+ right = @step_mother.Given(/Three (.*) mice ran (.*)/) {|disability|}
56
+ wrong = @step_mother.Given(/Three (.*)/) {|animal|}
57
+ @step_mother.step_definition("Three blind mice ran far").should == right
58
+ end
59
+
36
60
  it "should raise Undefined error when no step definitions match" do
37
61
  lambda do
38
62
  @step_mother.step_definition("Three blind mice")
39
- end.should raise_error(StepMother::Undefined)
63
+ end.should raise_error(Undefined)
40
64
  end
41
65
 
42
66
  it "should raise Redundant error when same regexp is registered twice" do
43
67
  @step_mother.Given(/Three (.*) mice/) {|disability|}
44
68
  lambda do
45
69
  @step_mother.Given(/Three (.*) mice/) {|disability|}
46
- end.should raise_error(StepMother::Redundant)
70
+ end.should raise_error(Redundant)
47
71
  end
48
72
  end
49
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakhellesoy-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.99.15
4
+ version: 0.1.99.17
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-01-29 00:00:00 -08:00
12
+ date: 2009-01-31 00:00:00 -08:00
13
13
  default_executable: cucumber
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -177,6 +177,7 @@ files:
177
177
  - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java
178
178
  - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java
179
179
  - examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java
180
+ - examples/jbehave/target/maven-archiver/pom.properties
180
181
  - examples/selenium/Rakefile
181
182
  - examples/selenium/features/search.feature
182
183
  - examples/selenium/features/step_definitons/stories_steps.rb
@@ -201,6 +202,9 @@ files:
201
202
  - examples/tickets/Rakefile
202
203
  - examples/tickets/cucumber.yml
203
204
  - examples/tickets/features/172.feature
205
+ - examples/tickets/features/177-1.feature
206
+ - examples/tickets/features/177-2.feature
207
+ - examples/tickets/features/180.feature
204
208
  - examples/tickets/features/lib/eatting_machine.rb
205
209
  - examples/tickets/features/lib/pantry.rb
206
210
  - examples/tickets/features/scenario_outline.feature
@@ -225,6 +229,7 @@ files:
225
229
  - gem_tasks/fix_cr_lf.rake
226
230
  - gem_tasks/flog.rake
227
231
  - gem_tasks/gemspec.rake
232
+ - gem_tasks/jar.rake
228
233
  - gem_tasks/rspec.rake
229
234
  - gem_tasks/yard.rake
230
235
  - lib/autotest/cucumber.rb
@@ -250,6 +255,7 @@ files:
250
255
  - lib/cucumber/ast/tags.rb
251
256
  - lib/cucumber/ast/visitor.rb
252
257
  - lib/cucumber/broadcaster.rb
258
+ - lib/cucumber/cli/configuration.rb
253
259
  - lib/cucumber/cli/language_help_formatter.rb
254
260
  - lib/cucumber/cli/main.rb
255
261
  - lib/cucumber/core_ext/exception.rb
@@ -302,6 +308,7 @@ files:
302
308
  - spec/cucumber/ast/step_spec.rb
303
309
  - spec/cucumber/ast/table_spec.rb
304
310
  - spec/cucumber/broadcaster_spec.rb
311
+ - spec/cucumber/cli/configuration_spec.rb
305
312
  - spec/cucumber/cli/main_spec.rb
306
313
  - spec/cucumber/core_ext/proc_spec.rb
307
314
  - spec/cucumber/core_ext/string_spec.rb