cucumber 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +44 -1
- data/Manifest.txt +11 -1
- data/bin/cucumber +11 -1
- data/examples/cs/Rakefile +1 -1
- data/examples/cs/features/addition.feature +5 -5
- data/examples/cs/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/dos_line_endings/Rakefile +1 -1
- data/examples/i18n/ar/Rakefile +1 -1
- data/examples/i18n/bg/Rakefile +1 -1
- data/examples/i18n/cat/Rakefile +6 -0
- data/examples/i18n/cat/features/step_definitons/calculator_steps.rb +21 -0
- data/examples/i18n/cat/features/suma.feature +16 -0
- data/examples/i18n/cat/lib/calculadora.rb +16 -0
- data/examples/i18n/da/Rakefile +1 -1
- data/examples/i18n/de/Rakefile +1 -1
- data/examples/i18n/en-lol/Rakefile +1 -1
- data/examples/i18n/en/Rakefile +1 -1
- data/examples/i18n/es/Rakefile +1 -1
- data/examples/i18n/et/Rakefile +1 -1
- data/examples/i18n/fi/Rakefile +1 -1
- data/examples/i18n/fr/Rakefile +1 -1
- data/examples/i18n/he/Rakefile +1 -1
- data/examples/i18n/hu/Rakefile +1 -1
- data/examples/i18n/id/Rakefile +1 -1
- data/examples/i18n/it/Rakefile +1 -1
- data/examples/i18n/ja/Rakefile +1 -1
- data/examples/i18n/ko/Rakefile +1 -1
- data/examples/i18n/lt/Rakefile +1 -1
- data/examples/i18n/lt/features/addition.feature +2 -3
- data/examples/i18n/lv/Rakefile +1 -1
- data/examples/i18n/no/Rakefile +1 -1
- data/examples/i18n/pt/Rakefile +1 -1
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -7
- data/examples/i18n/pt/features/support/env.rb +6 -0
- data/examples/i18n/ro/Rakefile +1 -1
- data/examples/i18n/ru/Rakefile +1 -1
- data/examples/i18n/se/Rakefile +1 -1
- data/examples/i18n/sk/Rakefile +1 -1
- data/examples/i18n/zh-CN/Rakefile +1 -1
- data/examples/i18n/zh-TW/Rakefile +1 -1
- data/examples/java/README.textile +2 -6
- data/examples/java/build.xml +26 -0
- data/examples/java/features/step_definitons/hello_steps.rb +0 -2
- data/examples/junit/features/one_passing_one_failing.feature +8 -0
- data/examples/junit/features/pending.feature +5 -0
- data/examples/junit/features/step_definitions/steps.rb +11 -0
- data/examples/selenium/Rakefile +1 -1
- data/examples/selenium_webrat/Rakefile +1 -1
- data/examples/sinatra/Rakefile +1 -1
- data/examples/test_unit/Rakefile +1 -1
- data/examples/tickets/Rakefile +3 -3
- data/examples/tickets/features/177/1.feature +29 -29
- data/examples/tickets/features/177/2.feature +20 -20
- data/examples/watir/Rakefile +1 -1
- data/features/junit_formatter.feature +59 -0
- data/features/rake_task.feature +4 -4
- data/features/step_definitions/cucumber_steps.rb +25 -2
- data/gem_tasks/features.rake +5 -1
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/cli/configuration.rb +28 -32
- data/lib/cucumber/cli/main.rb +0 -2
- data/lib/cucumber/core_ext/proc.rb +9 -13
- data/lib/cucumber/formatter.rb +1 -1
- data/lib/cucumber/formatter/html.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +78 -0
- data/lib/cucumber/languages.yml +36 -4
- data/lib/cucumber/parser/feature.rb +10 -6
- data/lib/cucumber/parser/feature.tt +18 -14
- data/lib/cucumber/rake/task.rb +92 -24
- data/lib/cucumber/step_mother.rb +3 -0
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/cucumber.rake +2 -1
- data/spec/cucumber/cli/configuration_spec.rb +9 -18
- metadata +13 -3
- data/examples/java/Rakefile +0 -12
data/lib/cucumber/rake/task.rb
CHANGED
@@ -14,7 +14,7 @@ module Cucumber
|
|
14
14
|
# To further configure the task, you can pass a block:
|
15
15
|
#
|
16
16
|
# Cucumber::Rake::Task.new do |t|
|
17
|
-
# t.cucumber_opts =
|
17
|
+
# t.cucumber_opts = %w{--format progress}
|
18
18
|
# end
|
19
19
|
#
|
20
20
|
# This task can also be configured to be run with RCov:
|
@@ -25,7 +25,62 @@ module Cucumber
|
|
25
25
|
#
|
26
26
|
# See the attributes for additional configuration possibilities.
|
27
27
|
class Task
|
28
|
-
|
28
|
+
class InProcessCucumberRunner #:nodoc:
|
29
|
+
attr_reader :args
|
30
|
+
|
31
|
+
def initialize(libs, cucumber_opts, feature_files)
|
32
|
+
libs.reverse.each{|lib| $:.unshift(lib)}
|
33
|
+
@args = (
|
34
|
+
cucumber_opts +
|
35
|
+
feature_files
|
36
|
+
).flatten.compact
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
require 'cucumber/cli/main'
|
41
|
+
Cucumber::Cli::Main.execute(args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class ForkedCucumberRunner #:nodoc:
|
46
|
+
attr_reader :args
|
47
|
+
|
48
|
+
def initialize(libs, cucumber_bin, cucumber_opts, feature_files)
|
49
|
+
@args = (
|
50
|
+
['-I'] + load_path(libs) +
|
51
|
+
quoted_binary(cucumber_bin) +
|
52
|
+
cucumber_opts +
|
53
|
+
feature_files
|
54
|
+
).flatten
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_path(libs)
|
58
|
+
['"%s"' % libs.join(File::PATH_SEPARATOR)]
|
59
|
+
end
|
60
|
+
|
61
|
+
def quoted_binary(cucumber_bin)
|
62
|
+
['"%s"' % cucumber_bin]
|
63
|
+
end
|
64
|
+
|
65
|
+
def run
|
66
|
+
ruby(args.join(" ")) # ruby(*args) is broken on Windows
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class RCovCucumberRunner < ForkedCucumberRunner #:nodoc:
|
71
|
+
def initialize(libs, cucumber_bin, cucumber_opts, feature_files, rcov_opts)
|
72
|
+
@args = (
|
73
|
+
['-I'] + load_path(libs) +
|
74
|
+
['-S', 'rcov'] + rcov_opts +
|
75
|
+
quoted_binary(cucumber_bin) +
|
76
|
+
['--'] +
|
77
|
+
cucumber_opts +
|
78
|
+
feature_files
|
79
|
+
).flatten
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
LIB = File.expand_path(File.dirname(__FILE__) + '/../..') # :nodoc:
|
29
84
|
|
30
85
|
# TODO: remove depreated accessors for 0.4.0
|
31
86
|
def self.deprecate_accessor(attribute) # :nodoc:
|
@@ -40,24 +95,45 @@ module Cucumber
|
|
40
95
|
|
41
96
|
# Directories to add to the Ruby $LOAD_PATH
|
42
97
|
attr_accessor :libs
|
98
|
+
|
43
99
|
# Name of the cucumber binary to use for running features. Defaults to Cucumber::BINARY
|
44
100
|
attr_accessor :binary
|
101
|
+
|
45
102
|
# Array of paths to specific step definition files to use
|
46
103
|
deprecate_accessor :step_list
|
104
|
+
|
47
105
|
# File pattern for finding step definitions. Defaults to
|
48
106
|
# 'features/**/*.rb'.
|
49
107
|
deprecate_accessor :step_pattern
|
108
|
+
|
50
109
|
# Array of paths to specific features to run.
|
51
110
|
deprecate_accessor :feature_list
|
111
|
+
|
52
112
|
# File pattern for finding features to run. Defaults to
|
53
113
|
# 'features/**/*.feature'. Can be overridden by the FEATURE environment variable.
|
54
114
|
deprecate_accessor :feature_pattern
|
115
|
+
|
55
116
|
# Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable.
|
117
|
+
# It's recommended to pass an Array, but if it's a String it will be #split by ' '.
|
56
118
|
attr_accessor :cucumber_opts
|
57
|
-
|
119
|
+
def cucumber_opts=(opts) #:nodoc:
|
120
|
+
@cucumber_opts = String === opts ? opts.split(' ') : opts
|
121
|
+
end
|
122
|
+
|
123
|
+
# Run cucumber with RCov? Defaults to false. If you set this to
|
124
|
+
# true, +fork+ is implicit.
|
58
125
|
attr_accessor :rcov
|
59
|
-
|
126
|
+
|
127
|
+
# Extra options to pass to rcov.
|
128
|
+
# It's recommended to pass an Array, but if it's a String it will be #split by ' '.
|
60
129
|
attr_accessor :rcov_opts
|
130
|
+
def rcov_opts=(opts) #:nodoc:
|
131
|
+
@rcov_opts = String === opts ? opts.split(' ') : opts
|
132
|
+
end
|
133
|
+
|
134
|
+
# Whether or not to fork a new ruby interpreter. Defaults to false.
|
135
|
+
attr_accessor :fork
|
136
|
+
|
61
137
|
# Define what profile to be used. When used with cucumber_opts it is simply appended to it. Will be ignored when CUCUMBER_OPTS is used.
|
62
138
|
def profile=(profile)
|
63
139
|
@profile = profile
|
@@ -69,13 +145,14 @@ module Cucumber
|
|
69
145
|
end
|
70
146
|
attr_reader :profile
|
71
147
|
|
72
|
-
# Define
|
148
|
+
# Define Cucumber Rake task
|
73
149
|
def initialize(task_name = "features", desc = "Run Features with Cucumber")
|
74
150
|
@task_name, @desc = task_name, desc
|
75
151
|
@libs = ['lib']
|
76
152
|
@rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
|
77
153
|
|
78
154
|
yield self if block_given?
|
155
|
+
@fork = true if @rcov
|
79
156
|
|
80
157
|
@feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil?
|
81
158
|
@step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil?
|
@@ -89,32 +166,23 @@ module Cucumber
|
|
89
166
|
def define_task # :nodoc:
|
90
167
|
desc @desc
|
91
168
|
task @task_name do
|
92
|
-
|
169
|
+
runner.run
|
93
170
|
end
|
94
171
|
end
|
95
172
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
cuc_opts << '--require'
|
103
|
-
cuc_opts << step_file
|
104
|
-
end
|
105
|
-
|
106
|
-
if rcov
|
107
|
-
args = (['-I'] + lib_args + ['-S', 'rcov'] + rcov_opts +
|
108
|
-
cucumber_bin + ['--'] + cuc_opts + feature_files(task_args)).flatten
|
173
|
+
def runner(task_args = nil) # :nodoc:
|
174
|
+
cucumber_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts_with_profile)]
|
175
|
+
if(@rcov)
|
176
|
+
RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files(task_args), rcov_opts)
|
177
|
+
elsif(@fork)
|
178
|
+
ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files(task_args))
|
109
179
|
else
|
110
|
-
|
180
|
+
InProcessCucumberRunner.new(libs, cucumber_opts, feature_files(task_args))
|
111
181
|
end
|
112
|
-
|
113
|
-
args
|
114
182
|
end
|
115
183
|
|
116
184
|
def cucumber_opts_with_profile # :nodoc:
|
117
|
-
@profile ?
|
185
|
+
@profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts
|
118
186
|
end
|
119
187
|
|
120
188
|
def feature_files(task_args = nil) # :nodoc:
|
@@ -149,7 +217,7 @@ module Cucumber
|
|
149
217
|
def define_task # :nodoc:
|
150
218
|
desc @desc
|
151
219
|
task @task_name, :feature_name do |t, args|
|
152
|
-
|
220
|
+
runner(args).run
|
153
221
|
end
|
154
222
|
end
|
155
223
|
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -262,6 +262,7 @@ module Cucumber
|
|
262
262
|
|
263
263
|
# Creates a new world instance
|
264
264
|
def new_world!
|
265
|
+
return if options[:dry_run]
|
265
266
|
create_world!
|
266
267
|
extend_world
|
267
268
|
connect_world
|
@@ -309,12 +310,14 @@ module Cucumber
|
|
309
310
|
end
|
310
311
|
|
311
312
|
def execute_before(scenario)
|
313
|
+
return if options[:dry_run]
|
312
314
|
hooks_for(:before, scenario).each do |hook|
|
313
315
|
hook.execute_in(@current_world, scenario, 'Before')
|
314
316
|
end
|
315
317
|
end
|
316
318
|
|
317
319
|
def execute_after(scenario)
|
320
|
+
return if options[:dry_run]
|
318
321
|
hooks_for(:after, scenario).each do |hook|
|
319
322
|
hook.execute_in(@current_world, scenario, 'After')
|
320
323
|
end
|
data/lib/cucumber/version.rb
CHANGED
@@ -107,8 +107,6 @@ module Cli
|
|
107
107
|
given_cucumber_yml_defined_as({'default' => '--require from/yml', 'html_report' => '--format html'})
|
108
108
|
|
109
109
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
110
|
-
config.parse!(%w{--profile i_do_not_exist})
|
111
|
-
|
112
110
|
expected_message = <<-END_OF_MESSAGE
|
113
111
|
Could not find profile: 'i_do_not_exist'
|
114
112
|
|
@@ -117,16 +115,15 @@ Defined profiles in cucumber.yml:
|
|
117
115
|
* html_report
|
118
116
|
END_OF_MESSAGE
|
119
117
|
|
120
|
-
|
118
|
+
lambda{config.parse!(%w{--profile i_do_not_exist})}.should raise_error(expected_message)
|
121
119
|
end
|
122
120
|
|
123
|
-
it "should
|
121
|
+
it "should allow array as profile" do
|
124
122
|
given_cucumber_yml_defined_as({'foo' => [1,2,3]})
|
125
123
|
|
126
124
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
127
125
|
config.parse!(%w{--profile foo})
|
128
|
-
|
129
|
-
error.string.should == "Profiles must be defined as a String. The 'foo' profile was [1, 2, 3] (Array).\n"
|
126
|
+
config.paths.should == [1,2,3]
|
130
127
|
end
|
131
128
|
|
132
129
|
it "should provide a helpful error message when a specified profile exists but is nil or blank" do
|
@@ -134,9 +131,8 @@ END_OF_MESSAGE
|
|
134
131
|
given_cucumber_yml_defined_as({'foo' => bad_input})
|
135
132
|
|
136
133
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
137
|
-
|
138
|
-
|
139
|
-
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./)
|
134
|
+
expected_error = /The 'foo' profile in cucumber.yml was blank. Please define the command line arguments for the 'foo' profile in cucumber.yml./
|
135
|
+
lambda{config.parse!(%w{--profile foo})}.should raise_error(expected_error)
|
140
136
|
end
|
141
137
|
end
|
142
138
|
|
@@ -144,9 +140,8 @@ END_OF_MESSAGE
|
|
144
140
|
File.should_receive(:exist?).with('cucumber.yml').and_return(false)
|
145
141
|
|
146
142
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
147
|
-
|
148
|
-
|
149
|
-
error.string.should match(/cucumber.yml was not found. Please refer to cucumber's documentation on defining profiles in cucumber.yml./)
|
143
|
+
expected_error = /cucumber.yml was not found. Please refer to cucumber's documentation on defining profiles in cucumber.yml./
|
144
|
+
lambda{config.parse!(%w{--profile i_do_not_exist})}.should raise_error(expected_error)
|
150
145
|
end
|
151
146
|
|
152
147
|
it "should provide a helpful error message when cucumber.yml is blank or malformed" do
|
@@ -156,9 +151,7 @@ END_OF_MESSAGE
|
|
156
151
|
given_cucumber_yml_defined_as(bad_input)
|
157
152
|
|
158
153
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
159
|
-
config.parse!([])
|
160
|
-
|
161
|
-
error.string.should match(expected_error_message)
|
154
|
+
lambda{config.parse!([])}.should raise_error(expected_error_message)
|
162
155
|
end
|
163
156
|
end
|
164
157
|
|
@@ -169,9 +162,7 @@ END_OF_MESSAGE
|
|
169
162
|
YAML.should_receive(:load).and_raise Exception
|
170
163
|
|
171
164
|
config = Configuration.new(StringIO.new, error = StringIO.new)
|
172
|
-
config.parse!([])
|
173
|
-
|
174
|
-
error.string.should match(expected_error_message)
|
165
|
+
lambda{config.parse!([])}.should raise_error(expected_error_message)
|
175
166
|
end
|
176
167
|
|
177
168
|
it "should accept --dry-run option" do
|
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.
|
4
|
+
version: 0.3.4
|
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-05-
|
12
|
+
date: 2009-05-14 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,10 @@ files:
|
|
106
106
|
- examples/i18n/bg/features/support/env.rb
|
107
107
|
- examples/i18n/bg/features/support/world.rb
|
108
108
|
- examples/i18n/bg/lib/calculator.rb
|
109
|
+
- examples/i18n/cat/Rakefile
|
110
|
+
- examples/i18n/cat/features/step_definitons/calculator_steps.rb
|
111
|
+
- examples/i18n/cat/features/suma.feature
|
112
|
+
- examples/i18n/cat/lib/calculadora.rb
|
109
113
|
- examples/i18n/da/Rakefile
|
110
114
|
- examples/i18n/da/features/step_definitons/kalkulator_steps.rb
|
111
115
|
- examples/i18n/da/features/summering.feature
|
@@ -191,6 +195,7 @@ files:
|
|
191
195
|
- examples/i18n/pt/Rakefile
|
192
196
|
- examples/i18n/pt/features/adicao.feature
|
193
197
|
- examples/i18n/pt/features/step_definitions/calculadora_steps.rb
|
198
|
+
- examples/i18n/pt/features/support/env.rb
|
194
199
|
- examples/i18n/pt/lib/calculadora.rb
|
195
200
|
- examples/i18n/ro/Rakefile
|
196
201
|
- examples/i18n/ro/features/step_definitons/calculator_steps.rb
|
@@ -223,12 +228,15 @@ files:
|
|
223
228
|
- examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb
|
224
229
|
- examples/i18n/zh-TW/lib/calculator.rb
|
225
230
|
- examples/java/README.textile
|
226
|
-
- examples/java/
|
231
|
+
- examples/java/build.xml
|
227
232
|
- examples/java/features/hello.feature
|
228
233
|
- examples/java/features/step_definitons/hello_steps.rb
|
229
234
|
- examples/java/features/step_definitons/tree_steps.rb
|
230
235
|
- examples/java/features/tree.feature
|
231
236
|
- examples/java/src/cucumber/demo/Hello.java
|
237
|
+
- examples/junit/features/one_passing_one_failing.feature
|
238
|
+
- examples/junit/features/pending.feature
|
239
|
+
- examples/junit/features/step_definitions/steps.rb
|
232
240
|
- examples/pure_java/README.textile
|
233
241
|
- examples/selenium/Rakefile
|
234
242
|
- examples/selenium/features/search.feature
|
@@ -313,6 +321,7 @@ files:
|
|
313
321
|
- features/cucumber_cli_outlines.feature
|
314
322
|
- features/custom_formatter.feature
|
315
323
|
- features/exclude_files.feature
|
324
|
+
- features/junit_formatter.feature
|
316
325
|
- features/multiline_names.feature
|
317
326
|
- features/rake_task.feature
|
318
327
|
- features/report_called_undefined_steps.feature
|
@@ -368,6 +377,7 @@ files:
|
|
368
377
|
- lib/cucumber/formatter/cucumber.css
|
369
378
|
- lib/cucumber/formatter/cucumber.sass
|
370
379
|
- lib/cucumber/formatter/html.rb
|
380
|
+
- lib/cucumber/formatter/junit.rb
|
371
381
|
- lib/cucumber/formatter/pretty.rb
|
372
382
|
- lib/cucumber/formatter/profile.rb
|
373
383
|
- lib/cucumber/formatter/progress.rb
|
data/examples/java/Rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
require 'cucumber/rake/task'
|
3
|
-
|
4
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
5
|
-
t.cucumber_opts = "--format pretty"
|
6
|
-
end
|
7
|
-
|
8
|
-
task :features => :compile
|
9
|
-
|
10
|
-
task :compile do
|
11
|
-
sh "javac src/cucumber/demo/Hello.java && jar cf src/cucumber_demo.jar -C src cucumber/demo/Hello.class"
|
12
|
-
end
|