aslakhellesoy-cucumber 0.1.99.21 → 0.1.99.22
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.
- data/History.txt +20 -7
- data/Manifest.txt +24 -1
- data/examples/i18n/Rakefile +3 -3
- data/examples/i18n/fr/features/addition.feature +13 -11
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +10 -12
- data/examples/i18n/fr/lib/calculatrice.rb +1 -1
- data/examples/i18n/ja/features/addition.feature +10 -10
- data/examples/i18n/ja/features/division.feature +2 -2
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +3 -3
- data/examples/i18n/ko/features/addition.feature +3 -3
- data/examples/i18n/ko/features/division.feature +3 -3
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +2 -9
- data/examples/i18n/no/features/support/env.rb +6 -0
- data/examples/i18n/zh-TW/Rakefile +6 -0
- data/examples/i18n/zh-TW/features/addition.feature +16 -0
- data/examples/i18n/zh-TW/features/division.feature +10 -0
- data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/zh-TW/lib/calculator.rb +14 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +3 -1
- data/examples/sinatra/Rakefile +6 -0
- data/examples/sinatra/app.rb +14 -0
- data/examples/sinatra/features/add.feature +11 -0
- data/examples/sinatra/features/step_definitions/add_steps.rb +15 -0
- data/examples/sinatra/features/support/env.rb +20 -0
- data/examples/sinatra/views/add.erb +5 -0
- data/examples/sinatra/views/layout.erb +8 -0
- data/features/cucumber_cli.feature +7 -2
- data/features/step_definitions/cucumber_steps.rb +0 -1
- data/lib/autotest/cucumber_mixin.rb +3 -2
- data/lib/cucumber/ast/table.rb +23 -4
- data/lib/cucumber/ast/tags.rb +2 -2
- data/lib/cucumber/cli/configuration.rb +28 -11
- data/lib/cucumber/cli/language_help_formatter.rb +1 -1
- data/lib/cucumber/cli/main.rb +8 -1
- data/lib/cucumber/formatter/color_io.rb +6 -0
- data/lib/cucumber/languages.yml +37 -10
- data/lib/cucumber/parser/feature.rb +1 -1
- data/lib/cucumber/parser/feature.tt +1 -1
- data/lib/cucumber/rake/task.rb +39 -6
- data/lib/cucumber/step_definition.rb +7 -0
- data/lib/cucumber/step_mother.rb +12 -1
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/cucumber_generator.rb +22 -3
- data/rails_generators/cucumber/templates/cucumber.rake +13 -5
- data/rails_generators/cucumber/templates/env.rb +2 -1
- data/rails_generators/cucumber/templates/paths.rb +18 -11
- data/rails_generators/cucumber/templates/webrat_steps.rb +23 -7
- data/spec/cucumber/ast/table_spec.rb +36 -9
- data/spec/cucumber/ast/tags_spec.rb +13 -1
- data/spec/cucumber/cli/configuration_spec.rb +33 -4
- data/spec/cucumber/cli/main_spec.rb +45 -6
- data/spec/cucumber/parser/feature_parser_spec.rb +2 -2
- data/spec/cucumber/step_definition_spec.rb +8 -0
- metadata +21 -4
- data/examples/i18n/ja/README.txt +0 -5
data/lib/cucumber/ast/tags.rb
CHANGED
@@ -12,14 +12,14 @@ module Cucumber
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def among?(tag_names)
|
15
|
-
no_tags, yes_tags = tag_names.partition{|tag| tag =~
|
15
|
+
no_tags, yes_tags = tag_names.partition{|tag| tag =~ /^~/}
|
16
16
|
no_tags = no_tags.map{|tag| tag[1..-1]}
|
17
17
|
|
18
18
|
# Strip @
|
19
19
|
yes_tags = yes_tags.map{|tag| tag =~ /^@(.*)/ ? $1 : tag}
|
20
20
|
no_tags = no_tags.map{|tag| tag =~ /^@(.*)/ ? $1 : tag}
|
21
21
|
|
22
|
-
(@tag_names & yes_tags).any? && (@tag_names & no_tags).empty?
|
22
|
+
(yes_tags.empty? || (@tag_names & yes_tags).any?) && (no_tags.empty? || (@tag_names & no_tags).empty?)
|
23
23
|
end
|
24
24
|
|
25
25
|
def at_lines?(lines)
|
@@ -49,7 +49,7 @@ module Cucumber
|
|
49
49
|
if v == 'help'
|
50
50
|
list_languages
|
51
51
|
elsif args==['help']
|
52
|
-
|
52
|
+
list_keywords_and_exit(v)
|
53
53
|
else
|
54
54
|
@options[:lang] = v
|
55
55
|
end
|
@@ -73,7 +73,7 @@ module Cucumber
|
|
73
73
|
end
|
74
74
|
opts.on("-t TAGS", "--tags TAGS",
|
75
75
|
"Only execute the features or scenarios with the specified tags.",
|
76
|
-
"TAGS must be comma-separated without spaces. Prefix tags with
|
76
|
+
"TAGS must be comma-separated without spaces. Prefix tags with ~ to",
|
77
77
|
"exclude features or scenarios having that tag. tags can be specified",
|
78
78
|
"with or without the @ prefix.") do |v|
|
79
79
|
@options[:tags] = v.split(",")
|
@@ -134,6 +134,12 @@ module Cucumber
|
|
134
134
|
opts.on("-g", "--guess", "Guess best match for Ambiguous steps.") do
|
135
135
|
@options[:guess] = true
|
136
136
|
end
|
137
|
+
opts.on("--no-diff", "Disable diff output on failing expectations.") do
|
138
|
+
@options[:diff_enabled] = false
|
139
|
+
end
|
140
|
+
opts.on("-S", "--step-definitions", "Print the regexp and line of all step definitions, then exit.") do
|
141
|
+
@options[:print_step_definitions] = true
|
142
|
+
end
|
137
143
|
opts.on_tail("--version", "Show version.") do
|
138
144
|
@out_stream.puts VERSION::STRING
|
139
145
|
Kernel.exit
|
@@ -166,14 +172,22 @@ module Cucumber
|
|
166
172
|
end
|
167
173
|
|
168
174
|
def guess?
|
169
|
-
|
175
|
+
@options[:guess]
|
170
176
|
end
|
171
177
|
|
178
|
+
def diff_enabled?
|
179
|
+
@options[:diff_enabled]
|
180
|
+
end
|
181
|
+
|
182
|
+
def print_step_definitions?
|
183
|
+
@options[:print_step_definitions]
|
184
|
+
end
|
185
|
+
|
172
186
|
def load_language
|
173
|
-
Cucumber.
|
174
|
-
|
175
|
-
|
176
|
-
|
187
|
+
if Cucumber.language_incomplete?(@options[:lang])
|
188
|
+
list_keywords_and_exit(@options[:lang])
|
189
|
+
else
|
190
|
+
Cucumber.load_language(@options[:lang])
|
177
191
|
end
|
178
192
|
end
|
179
193
|
|
@@ -219,7 +233,9 @@ module Cucumber
|
|
219
233
|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
220
234
|
File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
|
221
235
|
end.flatten.uniq
|
222
|
-
files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }.reject{|f| f =~ /^http/}
|
236
|
+
sorted_files = files.sort { |a,b| (b =~ %r{/support/} || -1) <=> (a =~ %r{/support/} || -1) }.reject{|f| f =~ /^http/}
|
237
|
+
env_files = sorted_files.select {|f| f =~ %r{/support/env.rb} }
|
238
|
+
env_files + sorted_files.reject {|f| f =~ %r{/support/env.rb} }
|
223
239
|
end
|
224
240
|
|
225
241
|
def feature_files
|
@@ -299,7 +315,7 @@ Defined profiles in cucumber.yml:
|
|
299
315
|
return @cucumber_yml
|
300
316
|
end
|
301
317
|
|
302
|
-
def
|
318
|
+
def list_keywords_and_exit(lang)
|
303
319
|
unless Cucumber::LANGUAGES[lang]
|
304
320
|
exit_with_error("No language with key #{lang}")
|
305
321
|
end
|
@@ -321,7 +337,8 @@ Defined profiles in cucumber.yml:
|
|
321
337
|
:formats => {},
|
322
338
|
:excludes => [],
|
323
339
|
:tags => [],
|
324
|
-
:scenario_names => []
|
340
|
+
:scenario_names => [],
|
341
|
+
:diff_enabled => true
|
325
342
|
}
|
326
343
|
end
|
327
344
|
|
@@ -336,4 +353,4 @@ Defined profiles in cucumber.yml:
|
|
336
353
|
end
|
337
354
|
|
338
355
|
end
|
339
|
-
end
|
356
|
+
end
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -32,6 +32,13 @@ module Cucumber
|
|
32
32
|
step_mother.options = configuration.options
|
33
33
|
|
34
34
|
require_files
|
35
|
+
|
36
|
+
if(configuration.print_step_definitions?)
|
37
|
+
step_mother.print_step_definitions(@out_stream)
|
38
|
+
Kernel.exit(0)
|
39
|
+
return # In specs, exit is stubbed
|
40
|
+
end
|
41
|
+
|
35
42
|
enable_diffing
|
36
43
|
|
37
44
|
features = load_plain_text_features
|
@@ -86,7 +93,7 @@ module Cucumber
|
|
86
93
|
end
|
87
94
|
|
88
95
|
def enable_diffing
|
89
|
-
if defined?(::Spec)
|
96
|
+
if configuration.diff_enabled? && defined?(::Spec)
|
90
97
|
require 'spec/expectations/differs/default'
|
91
98
|
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
92
99
|
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
data/lib/cucumber/languages.yml
CHANGED
@@ -161,10 +161,11 @@
|
|
161
161
|
native: français
|
162
162
|
encoding: UTF-8
|
163
163
|
feature: Fonctionnalité
|
164
|
+
background: Contexte
|
164
165
|
scenario: Scénario
|
165
|
-
scenario_outline: Scénario
|
166
|
+
scenario_outline: Plan du Scénario
|
166
167
|
examples: Exemples
|
167
|
-
given:
|
168
|
+
given: Soit
|
168
169
|
when: Lorsque
|
169
170
|
then: Alors
|
170
171
|
and: Et
|
@@ -197,10 +198,12 @@
|
|
197
198
|
"ja":
|
198
199
|
name: Japanese
|
199
200
|
native: 日本語
|
200
|
-
encoding:
|
201
|
+
encoding: UTF-8
|
201
202
|
feature: フィーチャ
|
203
|
+
background: 背景
|
202
204
|
scenario: シナリオ
|
203
|
-
|
205
|
+
scenario_outline: シナリオテンプレート|テンプレ|シナリオテンプレ
|
206
|
+
examples: 例|サンプル
|
204
207
|
given: 前提
|
205
208
|
when: もし
|
206
209
|
then: ならば
|
@@ -292,15 +295,18 @@
|
|
292
295
|
but: Dar
|
293
296
|
"ru":
|
294
297
|
name: Russian
|
295
|
-
native: русский
|
298
|
+
native: русский
|
296
299
|
encoding: UTF-8
|
297
300
|
feature: Функционал
|
301
|
+
background: Предыстория
|
298
302
|
scenario: Сценарий
|
299
|
-
|
303
|
+
scenario_outline: Структура сценария
|
304
|
+
examples: Значения
|
305
|
+
given: Допустим
|
300
306
|
when: Если
|
301
307
|
then: То
|
302
|
-
and:
|
303
|
-
but:
|
308
|
+
and: И|К тому же
|
309
|
+
but: Но|А
|
304
310
|
"se":
|
305
311
|
name: Swedish
|
306
312
|
native: Svenska
|
@@ -317,21 +323,42 @@
|
|
317
323
|
but: Men
|
318
324
|
"zh-CN":
|
319
325
|
name: Chinese simplified
|
320
|
-
native:
|
326
|
+
native: 简体中文
|
321
327
|
encoding: UTF-8
|
322
328
|
feature: 功能
|
329
|
+
background: 背景
|
323
330
|
scenario: 场景
|
331
|
+
scenario_outline: 场景大纲
|
332
|
+
examples: 例子
|
324
333
|
given: 假如
|
325
334
|
when: 当
|
326
335
|
then: 那么
|
327
336
|
and: 而且
|
328
337
|
but: 但是
|
338
|
+
"zh-TW":
|
339
|
+
name: Chinese traditional
|
340
|
+
native: 繁體中文
|
341
|
+
encoding: UTF-8
|
342
|
+
feature: 功能
|
343
|
+
background: 背景
|
344
|
+
scenario: 場景|劇本
|
345
|
+
scenario_outline: 場景大綱|劇本大綱
|
346
|
+
examples: 例子
|
347
|
+
given: 假設
|
348
|
+
when: 當
|
349
|
+
then: 那麼
|
350
|
+
and: 而且|並且
|
351
|
+
but: 但是
|
329
352
|
"ko":
|
330
353
|
name: Korean
|
331
354
|
native: 한국어
|
332
355
|
encoding: UTF-8
|
356
|
+
background: 배경
|
333
357
|
feature: 기능
|
334
|
-
scenario:
|
358
|
+
scenario: 시나리오
|
359
|
+
scenario_outline: 시나리오 개요
|
360
|
+
examples: 예
|
361
|
+
more_examples: 다른 예
|
335
362
|
given: 조건
|
336
363
|
when: 만일
|
337
364
|
then: 그러면
|
@@ -311,7 +311,7 @@ module Cucumber
|
|
311
311
|
if r1
|
312
312
|
s2, i2 = [], index
|
313
313
|
loop do
|
314
|
-
if input.index(Regexp.new('[
|
314
|
+
if input.index(Regexp.new('[^@\\n\\t ]'), index) == index
|
315
315
|
r3 = (SyntaxNode).new(input, index...(index + 1))
|
316
316
|
@index += 1
|
317
317
|
else
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -2,21 +2,54 @@ require 'cucumber/platform'
|
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module Rake
|
5
|
-
# Defines a task for running features.
|
5
|
+
# Defines a Rake task for running features.
|
6
|
+
#
|
7
|
+
# The simplest use of it goes something like:
|
8
|
+
#
|
9
|
+
# Cucumber::Rake::Task.new
|
10
|
+
#
|
11
|
+
# This will create a task named 'features' described as 'Run Features with
|
12
|
+
# Cucumber'. It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
|
13
|
+
#
|
14
|
+
# To further configure the task, you can pass a block:
|
15
|
+
#
|
16
|
+
# Cucumber::Rake::Task.new do |t|
|
17
|
+
# t.libs << 'lib'
|
18
|
+
# t.cucumber_opts = "--format progress"
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# This task can also be configured to be run with RCov:
|
22
|
+
#
|
23
|
+
# Cucumber::Rake::Task.new do |t|
|
24
|
+
# t.rcov = true
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# See the attributes for additional configuration possibilities.
|
6
28
|
class Task
|
7
|
-
LIB = File.expand_path(File.dirname(__FILE__) + '/../..')
|
29
|
+
LIB = File.expand_path(File.dirname(__FILE__) + '/../..') # :nodoc:
|
8
30
|
|
31
|
+
# Directories to add to the load path
|
9
32
|
attr_accessor :libs
|
33
|
+
# Name of the cucumber binary to use for running features. Defaults to Cucumber::BINARY
|
10
34
|
attr_accessor :binary
|
35
|
+
# Array of paths to specific steps to use
|
11
36
|
attr_accessor :step_list
|
37
|
+
# File pattern for finding step definitions. Defaults to
|
38
|
+
# 'features/**/*.rb'. Can be overriden by the SPEC environment variable.
|
12
39
|
attr_accessor :step_pattern
|
40
|
+
# Array of paths to specific features to run.
|
13
41
|
attr_accessor :feature_list
|
42
|
+
# File pattern for finding features to run. Defaults to
|
43
|
+
# 'features/**/*.feature'. Can be overriden by the FEATURE environment variable.
|
14
44
|
attr_accessor :feature_pattern
|
45
|
+
# Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable.
|
15
46
|
attr_accessor :cucumber_opts
|
47
|
+
# Run cucumber with RCov?
|
16
48
|
attr_accessor :rcov
|
49
|
+
# Extra options to pass to rcov
|
17
50
|
attr_accessor :rcov_opts
|
18
51
|
|
19
|
-
# Define a
|
52
|
+
# Define a Rake
|
20
53
|
def initialize(task_name = "features", desc = "Run Features with Cucumber")
|
21
54
|
@task_name, @desc = task_name, desc
|
22
55
|
@libs = []
|
@@ -33,14 +66,14 @@ module Cucumber
|
|
33
66
|
define_task
|
34
67
|
end
|
35
68
|
|
36
|
-
def define_task
|
69
|
+
def define_task # :nodoc:
|
37
70
|
desc @desc
|
38
71
|
task @task_name do
|
39
72
|
ruby(arguments_for_ruby_execution.join(" ")) # ruby(*args) is broken on Windows
|
40
73
|
end
|
41
74
|
end
|
42
75
|
|
43
|
-
def arguments_for_ruby_execution(task_args = nil)
|
76
|
+
def arguments_for_ruby_execution(task_args = nil) # :nodoc:
|
44
77
|
lib_args = ['"%s"' % libs.join(File::PATH_SEPARATOR)]
|
45
78
|
cucumber_bin = ['"%s"' % binary]
|
46
79
|
cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)]
|
@@ -89,7 +122,7 @@ module Cucumber
|
|
89
122
|
super(task_name, desc)
|
90
123
|
end
|
91
124
|
|
92
|
-
def define_task
|
125
|
+
def define_task # :nodoc:
|
93
126
|
desc @desc
|
94
127
|
task @task_name, :feature_name do |t, args|
|
95
128
|
ruby(arguments_for_ruby_execution(args).join(" ")) # ruby(*args) is broken on Windows
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -136,9 +136,20 @@ module Cucumber
|
|
136
136
|
def snippet_text(step_keyword, step_name)
|
137
137
|
@snippet_generator.snippet_text(step_keyword, step_name)
|
138
138
|
end
|
139
|
+
|
140
|
+
def print_step_definitions(out)
|
141
|
+
step_definitions.each do |step_definition|
|
142
|
+
indent = max_step_definition_length - step_definition.text_length
|
143
|
+
out.puts(step_definition.to_s(indent))
|
144
|
+
end
|
145
|
+
end
|
139
146
|
|
140
147
|
private
|
141
|
-
|
148
|
+
|
149
|
+
def max_step_definition_length
|
150
|
+
@max_step_definition_length ||= step_definitions.map{|step_definition| step_definition.text_length}.max
|
151
|
+
end
|
152
|
+
|
142
153
|
def options
|
143
154
|
@options || {}
|
144
155
|
end
|
data/lib/cucumber/version.rb
CHANGED
@@ -4,13 +4,16 @@ require 'rbconfig'
|
|
4
4
|
class CucumberGenerator < Rails::Generator::Base
|
5
5
|
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
6
6
|
Config::CONFIG['ruby_install_name'])
|
7
|
+
|
8
|
+
attr_accessor :framework
|
9
|
+
|
7
10
|
def manifest
|
8
11
|
record do |m|
|
9
12
|
m.directory 'features/step_definitions'
|
10
|
-
m.
|
13
|
+
m.template 'webrat_steps.rb', 'features/step_definitions/webrat_steps.rb'
|
11
14
|
|
12
15
|
m.directory 'features/support'
|
13
|
-
m.
|
16
|
+
m.template 'env.rb', 'features/support/env.rb'
|
14
17
|
m.file 'paths.rb', 'features/support/paths.rb'
|
15
18
|
|
16
19
|
m.directory 'lib/tasks'
|
@@ -22,10 +25,26 @@ class CucumberGenerator < Rails::Generator::Base
|
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
28
|
+
def framework
|
29
|
+
options[:framework] || :rspec
|
30
|
+
end
|
31
|
+
|
25
32
|
protected
|
26
33
|
|
27
34
|
def banner
|
28
35
|
"Usage: #{$0} cucumber"
|
29
36
|
end
|
30
37
|
|
31
|
-
|
38
|
+
def add_options!(opt)
|
39
|
+
opt.separator ''
|
40
|
+
opt.separator 'Options:'
|
41
|
+
opt.on('--rspec', 'Setup cucumber for use with RSpec (default)') do |value|
|
42
|
+
options[:framework] = :rspec
|
43
|
+
end
|
44
|
+
|
45
|
+
opt.on('--testunit', 'Setup cucumber for use with test/unit') do |value|
|
46
|
+
options[:framework] = :testunit
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -1,7 +1,15 @@
|
|
1
|
-
|
2
|
-
require 'cucumber/rake/task'
|
1
|
+
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
begin
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
7
|
+
t.cucumber_opts = "--format pretty"
|
8
|
+
end
|
9
|
+
task :features => 'db:test:prepare'
|
10
|
+
rescue LoadError
|
11
|
+
desc 'Cucumber rake task not available'
|
12
|
+
task :features do
|
13
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
14
|
+
end
|
6
15
|
end
|
7
|
-
task :features => 'db:test:prepare'
|
@@ -10,7 +10,8 @@ require 'webrat'
|
|
10
10
|
Webrat.configure do |config|
|
11
11
|
config.mode = :rails
|
12
12
|
end
|
13
|
+
<% if framework == :rspec -%>
|
13
14
|
|
14
|
-
# Comment out the next two lines if you're not using RSpec's matchers (should / should_not) in your steps.
|
15
15
|
require 'cucumber/rails/rspec'
|
16
16
|
require 'webrat/core/matchers'
|
17
|
+
<% end -%>
|
@@ -1,12 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module NavigationHelpers
|
2
|
+
def path_to(page_name)
|
3
|
+
case page_name
|
4
|
+
|
5
|
+
when /the homepage/i
|
6
|
+
root_path
|
7
|
+
|
8
|
+
# Add more page name => path mappings here
|
9
|
+
|
10
|
+
else
|
11
|
+
raise "Can't find mapping from \"#{page_name}\" to a path."
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
14
|
+
end
|
15
|
+
|
16
|
+
World do |world|
|
17
|
+
world.extend NavigationHelpers
|
18
|
+
world
|
19
|
+
end
|
@@ -3,6 +3,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "pat
|
|
3
3
|
# Commonly used webrat steps
|
4
4
|
# http://github.com/brynary/webrat
|
5
5
|
|
6
|
+
Given /^I am on (.+)$/ do |page_name|
|
7
|
+
visit path_to(page_name)
|
8
|
+
end
|
9
|
+
|
6
10
|
When /^I go to (.+)$/ do |page_name|
|
7
11
|
visit path_to(page_name)
|
8
12
|
end
|
@@ -31,10 +35,10 @@ end
|
|
31
35
|
|
32
36
|
# Use this step when using multiple datetime_select helpers on a page or
|
33
37
|
# you want to specify which datetime to select. Given the following view:
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
+
# <%%= f.label :preferred %><br />
|
39
|
+
# <%%= f.datetime_select :preferred %>
|
40
|
+
# <%%= f.label :alternative %><br />
|
41
|
+
# <%%= f.datetime_select :alternative %>
|
38
42
|
# The following steps would fill out the form:
|
39
43
|
# When I select "November 23, 2004 11:20" as the "Preferred" data and time
|
40
44
|
# And I select "November 25, 2004 10:30" as the "Alternative" data and time
|
@@ -42,7 +46,7 @@ When /^I select "(.*)" as the "(.*)" date and time$/ do |datetime, datetime_labe
|
|
42
46
|
select_datetime(datetime, :from => datetime_label)
|
43
47
|
end
|
44
48
|
|
45
|
-
# Use this step in
|
49
|
+
# Use this step in conjunction with Rail's time_select helper. For example:
|
46
50
|
# When I select "2:20PM" as the time
|
47
51
|
# Note: Rail's default time helper provides 24-hour time-- not 12 hour time. Webrat
|
48
52
|
# will convert the 2:20PM to 14:20 and then select it.
|
@@ -57,7 +61,7 @@ When /^I select "(.*)" as the "(.*)" time$/ do |time, time_label|
|
|
57
61
|
select_time(time, :from => time_label)
|
58
62
|
end
|
59
63
|
|
60
|
-
# Use this step in
|
64
|
+
# Use this step in conjunction with Rail's date_select helper. For example:
|
61
65
|
# When I select "February 20, 1981" as the date
|
62
66
|
When /^I select "(.*)" as the date$/ do |date|
|
63
67
|
select_date(date)
|
@@ -82,18 +86,30 @@ When /^I choose "(.*)"$/ do |field|
|
|
82
86
|
choose(field)
|
83
87
|
end
|
84
88
|
|
85
|
-
When /^I attach the file at "(.*)" to "(.*)"
|
89
|
+
When /^I attach the file at "(.*)" to "(.*)"$/ do |path, field|
|
86
90
|
attach_file(field, path)
|
87
91
|
end
|
88
92
|
|
89
93
|
Then /^I should see "(.*)"$/ do |text|
|
94
|
+
<% if framework == :rspec -%>
|
90
95
|
response.should contain(text)
|
96
|
+
<% else -%>
|
97
|
+
assert_contain text
|
98
|
+
<% end -%>
|
91
99
|
end
|
92
100
|
|
93
101
|
Then /^I should not see "(.*)"$/ do |text|
|
102
|
+
<% if framework == :rspec -%>
|
94
103
|
response.should_not contain(text)
|
104
|
+
<% else -%>
|
105
|
+
assert_not_contain text
|
106
|
+
<% end -%>
|
95
107
|
end
|
96
108
|
|
97
109
|
Then /^the "(.*)" checkbox should be checked$/ do |label|
|
110
|
+
<% if framework == :rspec -%>
|
98
111
|
field_labeled(label).should be_checked
|
112
|
+
<% else -%>
|
113
|
+
assert field_labeled(label).checked?
|
114
|
+
<% end -%>
|
99
115
|
end
|
@@ -6,7 +6,7 @@ module Cucumber
|
|
6
6
|
describe Table do
|
7
7
|
before do
|
8
8
|
@table = Table.new([
|
9
|
-
%w{
|
9
|
+
%w{one four seven},
|
10
10
|
%w{4444 55555 666666}
|
11
11
|
])
|
12
12
|
@table.extend(Module.new{
|
@@ -17,11 +17,11 @@ module Cucumber
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should have rows" do
|
20
|
-
@table.cells_rows[0].map{|cell| cell.value}.should == %w{
|
20
|
+
@table.cells_rows[0].map{|cell| cell.value}.should == %w{one four seven}
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should have columns" do
|
24
|
-
@table.columns[1].map{|cell| cell.value}.should == %w{
|
24
|
+
@table.columns[1].map{|cell| cell.value}.should == %w{four 55555}
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should have same cell objects in rows and columns" do
|
@@ -35,10 +35,31 @@ module Cucumber
|
|
35
35
|
|
36
36
|
it "should be convertible to an array of hashes" do
|
37
37
|
@table.hashes.should == [
|
38
|
-
{'
|
38
|
+
{'one' => '4444', 'four' => '55555', 'seven' => '666666'}
|
39
39
|
]
|
40
40
|
end
|
41
41
|
|
42
|
+
it "should accept symbols as keys for the hashes" do
|
43
|
+
@table.hashes.first[:one].should == '4444'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should allow map'ing columns" do
|
47
|
+
@table.map_column!('one') { |v| v.to_i }
|
48
|
+
@table.hashes.first['one'].should == 4444
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should pass silently if a mapped column does not exist in non-strict mode" do
|
52
|
+
lambda {
|
53
|
+
@table.map_column!('two', false) { |v| v.to_i }
|
54
|
+
}.should_not raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should fail if a mapped column does not exist in strict mode" do
|
58
|
+
lambda {
|
59
|
+
@table.map_column!('two', true) { |v| v.to_i }
|
60
|
+
}.should raise_error('The column named "two" does not exist')
|
61
|
+
end
|
62
|
+
|
42
63
|
describe "replacing arguments" do
|
43
64
|
|
44
65
|
before(:each) do
|
@@ -54,10 +75,16 @@ module Cucumber
|
|
54
75
|
table_with_replaced_args.hashes[0]['book'].should == 'Unbearable lightness of being'
|
55
76
|
table_with_replaced_args.hashes[0]['qty'].should == '5'
|
56
77
|
end
|
57
|
-
|
78
|
+
|
79
|
+
it "should replace nil values with nil" do
|
80
|
+
table_with_replaced_args = @table.arguments_replaced({'<book>' => nil})
|
81
|
+
|
82
|
+
table_with_replaced_args.hashes[0]['book'].should == nil
|
83
|
+
end
|
84
|
+
|
58
85
|
it "should not change the original table" do
|
59
86
|
table_with_replaced_args = @table.arguments_replaced({'<book>' => 'Unbearable lightness of being'})
|
60
|
-
|
87
|
+
|
61
88
|
@table.hashes[0]['book'].should_not == 'Unbearable lightness of being'
|
62
89
|
end
|
63
90
|
|
@@ -67,9 +94,9 @@ module Cucumber
|
|
67
94
|
@table.to_sexp.should ==
|
68
95
|
[:table,
|
69
96
|
[:row,
|
70
|
-
[:cell, "
|
71
|
-
[:cell, "
|
72
|
-
[:cell, "
|
97
|
+
[:cell, "one"],
|
98
|
+
[:cell, "four"],
|
99
|
+
[:cell, "seven"]
|
73
100
|
],
|
74
101
|
[:row,
|
75
102
|
[:cell, "4444"],
|