cucumber 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 10
5
+ TINY = 11
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -4,5 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
4
4
  require 'cucumber/rails/world'
5
5
  Cucumber::Rails.use_transactional_fixtures
6
6
 
7
- # Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
7
+ require 'webrat/rails'
8
+
9
+ # Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps.
8
10
  require 'cucumber/rails/rspec'
11
+ require 'webrat/rspec-rails'
@@ -1,28 +1,26 @@
1
1
  # Commonly used webrat steps
2
2
  # http://github.com/brynary/webrat
3
3
 
4
- require 'webrat' if !defined?(Webrat) # Because some people have it installed as a Gem
5
-
6
4
  When /^I press "(.*)"$/ do |button|
7
- clicks_button(button)
5
+ click_button(button)
8
6
  end
9
7
 
10
8
  When /^I follow "(.*)"$/ do |link|
11
- clicks_link(link)
9
+ click_link(link)
12
10
  end
13
11
 
14
12
  When /^I fill in "(.*)" with "(.*)"$/ do |field, value|
15
- fills_in(field, :with => value)
13
+ fill_in(field, :with => value)
16
14
  end
17
15
 
18
16
  When /^I select "(.*)" from "(.*)"$/ do |value, field|
19
- selects(value, :from => field)
17
+ select(value, :from => field)
20
18
  end
21
19
 
22
20
  # Use this step in conjunction with Rail's datetime_select helper. For example:
23
21
  # When I select "December 25, 2008 10:00" as the date and time
24
22
  When /^I select "(.*)" as the date and time$/ do |time|
25
- selects_datetime(time)
23
+ select_datetime(time)
26
24
  end
27
25
 
28
26
  # Use this step when using multiple datetime_select helpers on a page or
@@ -35,7 +33,7 @@ end
35
33
  # When I select "November 23, 2004 11:20" as the "Preferred" data and time
36
34
  # And I select "November 25, 2004 10:30" as the "Alternative" data and time
37
35
  When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_label|
38
- selects_datetime(datetime, :from => datetime_label)
36
+ select_datetime(datetime, :from => datetime_label)
39
37
  end
40
38
 
41
39
  # Use this step in conjuction with Rail's time_select helper. For example:
@@ -43,43 +41,43 @@ end
43
41
  # Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
44
42
  # will convert the 2:20PM to 14:20 and then select it.
45
43
  When /^I select "(.*)" as the time$/ do |time|
46
- selects_time(time)
44
+ select_time(time)
47
45
  end
48
46
 
49
47
  # Use this step when using multiple time_select helpers on a page or you want to
50
48
  # specify the name of the time on the form. For example:
51
49
  # When I select "7:30AM" as the "Gym" time
52
50
  When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
53
- selects_time(time, :from => time_label)
51
+ select_time(time, :from => time_label)
54
52
  end
55
53
 
56
54
  # Use this step in conjuction with Rail's date_select helper. For example:
57
55
  # When I select "February 20, 1981" as the date
58
56
  When /^I select "(.*)" as the date$/ do |date|
59
- selects_date(date)
57
+ select_date(date)
60
58
  end
61
59
 
62
60
  # Use this step when using multiple date_select helpers on one page or
63
61
  # you want to specify the name of the date on the form. For example:
64
62
  # When I select "April 26, 1982" as the "Date of Birth" date
65
63
  When /^I select "(.*)" as the "(.*)" date$/ do |date, date_label|
66
- selects_date(date, :from => date_label)
64
+ select_date(date, :from => date_label)
67
65
  end
68
66
 
69
67
  When /^I check "(.*)"$/ do |field|
70
- checks(field)
68
+ check(field)
71
69
  end
72
70
 
73
71
  When /^I uncheck "(.*)"$/ do |field|
74
- unchecks(field)
72
+ uncheck(field)
75
73
  end
76
74
 
77
75
  When /^I choose "(.*)"$/ do |field|
78
- chooses(field)
76
+ choose(field)
79
77
  end
80
78
 
81
79
  When /^I attach the file at "(.*)" to "(.*)" $/ do |path, field|
82
- attaches_file(field, path)
80
+ attach_file(field, path)
83
81
  end
84
82
 
85
83
  Then /^I should see "(.*)"$/ do |text|
@@ -12,6 +12,10 @@ module Cucumber
12
12
  stub(Broadcaster, {:register => nil}.merge(stubs))
13
13
  end
14
14
 
15
+ def mock_features(stubs ={})
16
+ stub('features', {:<< => nil}.merge(stubs))
17
+ end
18
+
15
19
  before(:each) do
16
20
  Kernel.stub!(:exit)
17
21
  end
@@ -101,6 +105,40 @@ Defined profiles in cucumber.yml:
101
105
  cli.options[:source].should be_false
102
106
  end
103
107
 
108
+ it "should accept --verbose option" do
109
+ cli = CLI.new
110
+ cli.parse_options!(%w{--verbose})
111
+
112
+ cli.options[:verbose].should be_true
113
+ end
114
+
115
+ describe "verbose mode" do
116
+
117
+ before(:each) do
118
+ @out = StringIO.new
119
+ @cli = CLI.new(@out)
120
+ @cli.stub!(:require)
121
+ Dir.stub!(:[])
122
+ end
123
+
124
+ it "should show ruby files required" do
125
+ @cli.parse_options!(%w{--verbose --require example.rb})
126
+ @cli.execute!(stub('step mother'), mock_executor, mock_features)
127
+
128
+ @out.string.should include('example.rb')
129
+ end
130
+
131
+ it "should show feature files parsed" do
132
+ TreetopParser::FeatureParser.stub!(:new).and_return(mock("feature parser", :parse_feature => nil))
133
+
134
+ @cli.parse_options!(%w{--verbose example.feature})
135
+ @cli.execute!(stub('step mother'), mock_executor, mock_features)
136
+
137
+ @out.string.should include('example.feature')
138
+ end
139
+
140
+ end
141
+
104
142
  it "should accept --out option" do
105
143
  cli = CLI.new
106
144
  File.should_receive(:open).with('jalla.txt', 'w')
@@ -179,6 +217,125 @@ Defined profiles in cucumber.yml:
179
217
 
180
218
  cli.execute!(stub('step mother'), mock_executor, stub('features'))
181
219
  end
220
+
221
+ describe "--format with class" do
222
+
223
+ describe "in module" do
224
+
225
+ it "should resolve each module until it gets Formatter class" do
226
+ cli = CLI.new
227
+ mock_module = mock('module')
228
+ cli.parse_options!(%w{--format ZooModule::MonkeyFormatterClass})
229
+ Object.stub!(:const_defined?).and_return(true)
230
+ mock_module.stub!(:const_defined?).and_return(true)
231
+
232
+ Object.should_receive(:const_get).with('ZooModule').and_return(mock_module)
233
+ mock_module.should_receive(:const_get).with('MonkeyFormatterClass').and_return(mock('formatter class', :new => nil))
234
+
235
+ cli.execute!(stub('step mother'), mock_executor, stub('features'))
236
+ end
237
+
238
+ end
239
+
240
+ describe "exists and valid constructor" do
241
+
242
+ before(:each) do
243
+ @mock_formatter_class = mock('formatter class')
244
+ Object.stub!(:const_get).and_return(@mock_formatter_class)
245
+ Object.stub!(:const_defined?).with('magical').and_return(true)
246
+ end
247
+
248
+ it "should create the formatter" do
249
+ cli = CLI.new
250
+ mock_formatter = mock('magical formatter')
251
+ cli.parse_options!(%w{--format magical})
252
+
253
+ @mock_formatter_class.should_receive(:new)
254
+
255
+ cli.execute!(stub('step mother'), mock_executor, stub('features'))
256
+ end
257
+
258
+ it "should register the formatter with broadcaster" do
259
+ cli = CLI.new
260
+ broadcaster = Broadcaster.new
261
+ mock_formatter = mock('magical formatter')
262
+ Broadcaster.stub!(:new).and_return(broadcaster, stub("output broadcaster", :register => nil))
263
+ @mock_formatter_class.stub!(:new).and_return(mock_formatter)
264
+ cli.parse_options!(%w{--format magical})
265
+
266
+ broadcaster.should_receive(:register).with(mock_formatter)
267
+
268
+ cli.execute!(stub('step mother'), mock_executor, stub('features'))
269
+ end
270
+
271
+ end
272
+
273
+ describe "exists but invalid constructor" do
274
+
275
+ before(:each) do
276
+ @out = StringIO.new
277
+ @error = StringIO.new
278
+ @cli = CLI.new(@out, @error)
279
+
280
+ mock_formatter_class = stub('formatter class')
281
+ mock_formatter_class.stub!(:new).and_raise("No such method")
282
+ Object.stub!(:const_get).and_return(mock_formatter_class)
283
+ Object.stub!(:const_defined?).with('exists_but_evil').and_return(true)
284
+
285
+ @cli.parse_options!(%w{--format exists_but_evil})
286
+ end
287
+
288
+ it "should show exception" do
289
+ Kernel.stub!(:exit)
290
+
291
+ @cli.execute!(stub('step mother'), mock_executor, stub('features'))
292
+
293
+ @error.string.should include("No such method")
294
+ end
295
+
296
+ it "should exit" do
297
+ Kernel.should_receive(:exit)
298
+
299
+ @cli.execute!(stub('step mother'), mock_executor, stub('features'))
300
+ end
301
+
302
+ end
303
+
304
+ describe "non-existent" do
305
+
306
+ before(:each) do
307
+ @out = StringIO.new
308
+ @error = StringIO.new
309
+ @cli = CLI.new(@out, @error)
310
+
311
+ @cli.parse_options!(%w{--format invalid})
312
+ end
313
+
314
+ it "should display a format error" do
315
+ Kernel.stub!(:exit)
316
+
317
+ @cli.execute!(stub('step mother'), mock_executor, stub('features'))
318
+
319
+ @error.string.should include("Invalid format: invalid\n")
320
+ end
321
+
322
+ it "should display --help" do
323
+ Kernel.stub!(:exit)
324
+
325
+ @cli.execute!(stub('step mother'), mock_executor, stub('features'))
326
+
327
+ @out.string.should include("Usage: cucumber")
328
+ end
329
+
330
+ it "should exit" do
331
+ Kernel.should_receive(:exit)
332
+
333
+ @cli.execute!(stub('step mother'), mock_executor, stub('features'))
334
+ end
335
+
336
+ end
337
+
338
+ end
182
339
 
183
340
  it "should accept multiple --scenario options" do
184
341
  cli = CLI.new
@@ -267,7 +424,7 @@ Defined profiles in cucumber.yml:
267
424
 
268
425
  Dir.should_receive(:[]).with("feature_directory/**/*.feature").any_number_of_times.and_return([])
269
426
 
270
- cli.execute!(stub('step mother'), mock_executor, stub('features', :<< => nil))
427
+ cli.execute!(stub('step mother'), mock_executor, mock_features)
271
428
  end
272
429
 
273
430
  end
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.1.10
4
+ version: 0.1.11
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: 2008-11-25 00:00:00 +01:00
12
+ date: 2008-12-02 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,16 +42,6 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.1.2
44
44
  version:
45
- - !ruby/object:Gem::Dependency
46
- name: rspec
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 1.1.11
54
- version:
55
45
  - !ruby/object:Gem::Dependency
56
46
  name: hoe
57
47
  type: :development
@@ -245,6 +235,7 @@ files:
245
235
  - lib/cucumber/treetop_parser/feature_cy.rb
246
236
  - lib/cucumber/treetop_parser/feature_da.rb
247
237
  - lib/cucumber/treetop_parser/feature_de.rb
238
+ - lib/cucumber/treetop_parser/feature_en-lol.rb
248
239
  - lib/cucumber/treetop_parser/feature_en-tx.rb
249
240
  - lib/cucumber/treetop_parser/feature_en.rb
250
241
  - lib/cucumber/treetop_parser/feature_es.rb
@@ -341,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
332
  requirements: []
342
333
 
343
334
  rubyforge_project: rspec
344
- rubygems_version: 1.2.0
335
+ rubygems_version: 1.3.1
345
336
  signing_key:
346
337
  specification_version: 2
347
338
  summary: Executable Feature scenarios