aslakhellesoy-cucumber 0.2.3 → 0.2.3.1
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 +10 -1
- data/Manifest.txt +8 -0
- data/examples/i18n/sk/Rakefile +6 -0
- data/examples/i18n/sk/features/addition.feature +16 -0
- data/examples/i18n/sk/features/division.feature +9 -0
- data/examples/i18n/sk/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/sk/lib/calculator.rb +14 -0
- data/examples/self_test/features/background/background_with_name.feature +7 -0
- data/examples/self_test/features/step_definitions/sample_steps.rb +6 -0
- data/examples/self_test/features/undefined_multiline_args.feature +12 -0
- data/features/background.feature +17 -0
- data/features/cucumber_cli.feature +18 -5
- data/features/snippet.feature +23 -0
- data/features/step_definitions/cucumber_steps.rb +6 -2
- data/features/usage.feature +5 -0
- data/lib/cucumber/ast/background.rb +3 -3
- data/lib/cucumber/ast/py_string.rb +5 -1
- data/lib/cucumber/ast/step_invocation.rb +4 -0
- data/lib/cucumber/ast/table.rb +4 -0
- data/lib/cucumber/core_ext/instance_exec.rb +17 -4
- data/lib/cucumber/formatter/console.rb +2 -1
- data/lib/cucumber/formatter/html.rb +5 -1
- data/lib/cucumber/formatter/pretty.rb +0 -4
- data/lib/cucumber/formatter/usage.rb +16 -0
- data/lib/cucumber/parser/feature.rb +93 -79
- data/lib/cucumber/parser/feature.tt +3 -2
- data/lib/cucumber/step_definition.rb +4 -2
- data/lib/cucumber/step_mother.rb +17 -2
- data/lib/cucumber/version.rb +1 -1
- data/specs/cucumber/ast/background_spec.rb +1 -0
- data/specs/cucumber/ast/feature_factory.rb +1 -1
- data/specs/cucumber/core_ext/proc_spec.rb +25 -8
- data/specs/cucumber/step_mother_spec.rb +13 -0
- data/specs/spec_helper.rb +2 -11
- metadata +10 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.2.4 (In Git)
|
2
|
+
|
3
|
+
=== New features
|
4
|
+
* The usage formatter also prints unused step definitions (Aslak Hellesøy)
|
5
|
+
* Better exception if a World proc returns nil. (Aslak Hellesøy)
|
6
|
+
* Allow Step Definitions to use |*varargs|, but only on Ruby 1.9. (Aslak Hellesøy)
|
7
|
+
* Snippets for steps that use Step Tables or Pystrings include block param and object type hint comment (#247 Joseph Wilk)
|
8
|
+
* Support description string for Backgrounds (#271 Joseph Wilk)
|
9
|
+
|
1
10
|
== 0.2.3 2009-03-30
|
2
11
|
|
3
12
|
This release sports 4 updated languages, slightly better help with snippets if you "quote" arguments
|
@@ -16,7 +25,7 @@ in your steps. Windows/JRuby users can enjoy colours and you get some more sugar
|
|
16
25
|
|
17
26
|
=== Bugfixes
|
18
27
|
* Fixed step name after step keyword without space (#265 Aslak Hellesøy)
|
19
|
-
* Backtrace is back in HTML reports
|
28
|
+
* Backtrace is back in HTML reports (Aslak Hellesøy)
|
20
29
|
|
21
30
|
== 0.2.2 2009-03-25
|
22
31
|
|
data/Manifest.txt
CHANGED
@@ -108,6 +108,11 @@ examples/i18n/se/Rakefile
|
|
108
108
|
examples/i18n/se/features/step_definitons/kalkulator_steps.rb
|
109
109
|
examples/i18n/se/features/summering.feature
|
110
110
|
examples/i18n/se/lib/kalkulator.rb
|
111
|
+
examples/i18n/sk/Rakefile
|
112
|
+
examples/i18n/sk/features/addition.feature
|
113
|
+
examples/i18n/sk/features/division.feature
|
114
|
+
examples/i18n/sk/features/step_definitons/calculator_steps.rb
|
115
|
+
examples/i18n/sk/lib/calculator.rb
|
111
116
|
examples/i18n/zh-CN/Rakefile
|
112
117
|
examples/i18n/zh-CN/features/addition.feature
|
113
118
|
examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb
|
@@ -135,6 +140,7 @@ examples/selenium_webrat/features/step_definitons/search_steps.rb
|
|
135
140
|
examples/selenium_webrat/features/support/env.rb
|
136
141
|
examples/self_test/README.textile
|
137
142
|
examples/self_test/Rakefile
|
143
|
+
examples/self_test/features/background/background_with_name.feature
|
138
144
|
examples/self_test/features/background/failing_background.feature
|
139
145
|
examples/self_test/features/background/failing_background_after_success.feature
|
140
146
|
examples/self_test/features/background/multiline_args_background.feature
|
@@ -151,6 +157,7 @@ examples/self_test/features/step_definitions/sample_steps.rb
|
|
151
157
|
examples/self_test/features/support/env.rb
|
152
158
|
examples/self_test/features/support/tag_count_formatter.rb
|
153
159
|
examples/self_test/features/tons_of_cukes.feature
|
160
|
+
examples/self_test/features/undefined_multiline_args.feature
|
154
161
|
examples/sinatra/Rakefile
|
155
162
|
examples/sinatra/app.rb
|
156
163
|
examples/sinatra/features/add.feature
|
@@ -191,6 +198,7 @@ features/cucumber_cli_diff_disabled.feature
|
|
191
198
|
features/cucumber_cli_outlines.feature
|
192
199
|
features/custom_formatter.feature
|
193
200
|
features/report_called_undefined_steps.feature
|
201
|
+
features/snippet.feature
|
194
202
|
features/step_definitions/cucumber_steps.rb
|
195
203
|
features/step_definitions/extra_steps.rb
|
196
204
|
features/support/env.rb
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Požiadavka: Sčítavanie
|
2
|
+
Aby som sa vyhol hlúpym chybám
|
3
|
+
Ako matematický idiot
|
4
|
+
Chcem vedieť ako sa sčítavajú dve čísla
|
5
|
+
|
6
|
+
Náčrt Scenáru: Sčítanie dvoch čísel
|
7
|
+
Pokiaľ Zadám číslo <vstup_1> do kalkulačky
|
8
|
+
A Zadám číslo <vstup_2> do kalkulačky
|
9
|
+
Keď Stlačím tlačidlo <tlačidlo>
|
10
|
+
Tak Výsledok by mal byť <výstup>
|
11
|
+
|
12
|
+
Príklady:
|
13
|
+
| vstup_1 | vstup_2 | tlačidlo | výstup |
|
14
|
+
| 20 | 30 | add | 50 |
|
15
|
+
| 2 | 5 | add | 7 |
|
16
|
+
| 0 | 40 | add | 40 |
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec/expectations'
|
3
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
|
4
|
+
require 'cucumber/formatter/unicode'
|
5
|
+
require 'calculator'
|
6
|
+
|
7
|
+
Before do
|
8
|
+
@calc = Calculator.new
|
9
|
+
end
|
10
|
+
|
11
|
+
After do
|
12
|
+
end
|
13
|
+
|
14
|
+
Given /Zadám číslo (\d+) do kalkulačky/ do |n|
|
15
|
+
@calc.push n.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
When /Stlačím tlačidlo (\w+)/ do |op|
|
19
|
+
@result = @calc.send op
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /Výsledok by mal byť (.*)/ do |result|
|
23
|
+
@result.should == result.to_f
|
24
|
+
end
|
data/features/background.feature
CHANGED
@@ -217,5 +217,22 @@ Feature: backgrounds
|
|
217
217
|
|
218
218
|
"""
|
219
219
|
|
220
|
+
Scenario: background with name
|
221
|
+
When I run cucumber -q features/background/background_with_name.feature --require features
|
222
|
+
Then it should pass with
|
223
|
+
"""
|
224
|
+
Feature: background with name
|
225
|
+
|
226
|
+
Background: I'm a background and I'm ok
|
227
|
+
Given '10' cukes
|
228
|
+
|
229
|
+
Scenario: example
|
230
|
+
Then I should have '10' cukes
|
231
|
+
|
232
|
+
1 scenario
|
233
|
+
2 passed steps
|
234
|
+
|
235
|
+
"""
|
236
|
+
|
220
237
|
@josephwilk
|
221
238
|
Scenario: run a scenario showing explicit background steps --explicit-background
|
@@ -229,15 +229,28 @@ Feature: Cucumber command line
|
|
229
229
|
hello
|
230
230
|
\"\"\"
|
231
231
|
|
232
|
-
|
232
|
+
Feature: undefined multiline args
|
233
|
+
|
234
|
+
Scenario: pystring
|
235
|
+
Given a pystring
|
236
|
+
\"\"\"
|
237
|
+
example
|
238
|
+
\"\"\"
|
239
|
+
|
240
|
+
Scenario: table
|
241
|
+
Given a table
|
242
|
+
| table |
|
243
|
+
| example |
|
244
|
+
|
245
|
+
14 scenarios
|
233
246
|
12 skipped steps
|
234
|
-
|
247
|
+
9 undefined steps
|
235
248
|
|
236
249
|
"""
|
237
250
|
|
238
251
|
Scenario: Multiple formatters and outputs
|
239
252
|
When I run cucumber --format progress --out tmp/progress.txt --format pretty --out tmp/pretty.txt --dry-run features/lots_of_undefined.feature
|
240
|
-
And examples/self_test/tmp/progress.txt should contain
|
253
|
+
And "examples/self_test/tmp/progress.txt" should contain
|
241
254
|
"""
|
242
255
|
UUUUU
|
243
256
|
|
@@ -245,7 +258,7 @@ Feature: Cucumber command line
|
|
245
258
|
5 undefined steps
|
246
259
|
|
247
260
|
"""
|
248
|
-
And examples/self_test/tmp/pretty.txt should match
|
261
|
+
And "examples/self_test/tmp/pretty.txt" should match
|
249
262
|
"""
|
250
263
|
Feature: Lots of undefined
|
251
264
|
|
@@ -362,7 +375,7 @@ Feature: Cucumber command line
|
|
362
375
|
|
363
376
|
Scenario: Reformat files with --autoformat
|
364
377
|
When I run cucumber --autoformat tmp/formatted features
|
365
|
-
Then examples/self_test/tmp/formatted/features/sample.feature should contain
|
378
|
+
Then "examples/self_test/tmp/formatted/features/sample.feature" should contain
|
366
379
|
"""
|
367
380
|
@one
|
368
381
|
Feature: Sample
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Feature: Snippets
|
2
|
+
In order to help speed up writing step definitions
|
3
|
+
As a feature editor
|
4
|
+
I want snippet suggestions for undefined step definitions
|
5
|
+
|
6
|
+
Scenario: Snippet for undefined step with a pystring
|
7
|
+
When I run cucumber features/undefined_multiline_args.feature:3 -n
|
8
|
+
Then the output should contain
|
9
|
+
"""
|
10
|
+
Given /^a pystring$/ do |string|
|
11
|
+
# string is a Cucumber::Ast::PyString
|
12
|
+
pending
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
Scenario: Snippet for undefined step with a step table
|
16
|
+
When I run cucumber features/undefined_multiline_args.feature:9 -n
|
17
|
+
Then the output should contain
|
18
|
+
"""
|
19
|
+
Given /^a table$/ do |table|
|
20
|
+
# table is a Cucumber::Ast::Table
|
21
|
+
pending
|
22
|
+
end
|
23
|
+
"""
|
@@ -21,10 +21,14 @@ Then /^it should (fail|pass) with$/ do |success, output|
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
Then /^
|
24
|
+
Then /^the output should contain$/ do |text|
|
25
|
+
@out.should include(text)
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^"(.*)" should contain$/ do |file, text|
|
25
29
|
IO.read(file).should == text
|
26
30
|
end
|
27
31
|
|
28
|
-
Then /^(.*) should match$/ do |file, text|
|
32
|
+
Then /^"(.*)" should match$/ do |file, text|
|
29
33
|
IO.read(file).should =~ Regexp.new(text)
|
30
34
|
end
|
data/features/usage.feature
CHANGED
@@ -19,6 +19,7 @@ Feature: Cucumber command line
|
|
19
19
|
/^call step "(.*)"$/ # features/step_definitions/sample_steps.rb:23
|
20
20
|
Given call step "a step definition that calls an undefined step" # features/call_undefined_step_from_step_def.feature:7
|
21
21
|
/^'(.+)' cukes$/ # features/step_definitions/sample_steps.rb:27
|
22
|
+
Given '10' cukes # features/background/background_with_name.feature:4
|
22
23
|
And '10' cukes # features/background/failing_background.feature:5
|
23
24
|
Given '10' cukes # features/background/passing_background.feature:4
|
24
25
|
Given '10' cukes # features/background/scenario_outline_passing_background.feature:4
|
@@ -72,6 +73,7 @@ Feature: Cucumber command line
|
|
72
73
|
Given '2' cukes # features/tons_of_cukes.feature:51
|
73
74
|
Given '2' cukes # features/tons_of_cukes.feature:52
|
74
75
|
/^I should have '(.+)' cukes$/ # features/step_definitions/sample_steps.rb:31
|
76
|
+
Then I should have '10' cukes # features/background/background_with_name.feature:7
|
75
77
|
Then I should have '10' cukes # features/background/failing_background.feature:8
|
76
78
|
Then I should have '10' cukes # features/background/failing_background.feature:11
|
77
79
|
Then I should have '10' cukes # features/background/passing_background.feature:7
|
@@ -103,6 +105,9 @@ Feature: Cucumber command line
|
|
103
105
|
Given failing expectation # features/failing_expectation.feature:4
|
104
106
|
/^failing$/ # features/step_definitions/sample_steps.rb:8
|
105
107
|
Given failing # features/sample.feature:16
|
108
|
+
(::) UNUSED (::)
|
109
|
+
/^unused$/ # features/step_definitions/sample_steps.rb:66
|
110
|
+
/^another unused$/ # features/step_definitions/sample_steps.rb:69
|
106
111
|
|
107
112
|
"""
|
108
113
|
|
@@ -6,8 +6,8 @@ module Cucumber
|
|
6
6
|
include FeatureElement
|
7
7
|
attr_writer :feature
|
8
8
|
|
9
|
-
def initialize(comment, line, keyword, steps)
|
10
|
-
@comment, @line, @keyword, @steps = comment, line, keyword, StepCollection.new(steps)
|
9
|
+
def initialize(comment, line, keyword, name, steps)
|
10
|
+
@comment, @line, @keyword, @name, @steps = comment, line, keyword, name, StepCollection.new(steps)
|
11
11
|
attach_steps(steps)
|
12
12
|
@step_invocations = @steps.step_invocations(true)
|
13
13
|
end
|
@@ -23,7 +23,7 @@ module Cucumber
|
|
23
23
|
|
24
24
|
def accept(visitor)
|
25
25
|
visitor.visit_comment(@comment)
|
26
|
-
visitor.visit_background_name(@keyword,
|
26
|
+
visitor.visit_background_name(@keyword, @name, file_colon_line(@line), source_indent(text_length))
|
27
27
|
visitor.step_mother.before_and_after(self)
|
28
28
|
visitor.visit_steps(@step_invocations)
|
29
29
|
@failed = @step_invocations.detect{|step_invocation| step_invocation.exception}
|
@@ -17,6 +17,11 @@ module Cucumber
|
|
17
17
|
# Note how the indentation from the source is stripped away.
|
18
18
|
#
|
19
19
|
class PyString
|
20
|
+
|
21
|
+
def self.default_arg_name
|
22
|
+
"string"
|
23
|
+
end
|
24
|
+
|
20
25
|
def initialize(start_line, end_line, string, quotes_indent)
|
21
26
|
@start_line, @end_line = start_line, end_line
|
22
27
|
@string, @quotes_indent = string.gsub(/\\"/, '"'), quotes_indent
|
@@ -52,7 +57,6 @@ module Cucumber
|
|
52
57
|
def to_sexp #:nodoc:
|
53
58
|
[:py_string, to_s]
|
54
59
|
end
|
55
|
-
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
data/lib/cucumber/ast/table.rb
CHANGED
@@ -7,12 +7,14 @@ end
|
|
7
7
|
|
8
8
|
class Object
|
9
9
|
def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
|
10
|
-
arity = block.arity
|
11
|
-
arity = 0 if arity == -1
|
12
10
|
cucumber_run_with_backtrace_filtering(pseudo_method) do
|
13
|
-
if check_arity && args
|
11
|
+
if check_arity && !cucumber_compatible_arity?(args, block)
|
14
12
|
instance_exec do
|
15
|
-
|
13
|
+
s1 = cucumber_arity(block) == 1 ? "" : "s"
|
14
|
+
s2 = args.length == 1 ? "" : "s"
|
15
|
+
raise Cucumber::ArityMismatchError.new(
|
16
|
+
"Your block takes #{cucumber_arity(block)} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
|
17
|
+
)
|
16
18
|
end
|
17
19
|
else
|
18
20
|
instance_exec(*args, &block)
|
@@ -20,6 +22,17 @@ class Object
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
25
|
+
def cucumber_arity(block)
|
26
|
+
a = block.arity
|
27
|
+
Cucumber::RUBY_1_9 ? a : (a == -1 ? 0 : a)
|
28
|
+
end
|
29
|
+
|
30
|
+
def cucumber_compatible_arity?(args, block)
|
31
|
+
a = cucumber_arity(block)
|
32
|
+
return true if (a == -1) && Cucumber::RUBY_1_9
|
33
|
+
a == args.length
|
34
|
+
end
|
35
|
+
|
23
36
|
def cucumber_run_with_backtrace_filtering(pseudo_method)
|
24
37
|
begin
|
25
38
|
yield
|
@@ -74,7 +74,8 @@ module Cucumber
|
|
74
74
|
return if undefined.empty?
|
75
75
|
snippets = undefined.map do |step|
|
76
76
|
step_name = Undefined === step.exception ? step.exception.step_name : step.name
|
77
|
-
|
77
|
+
step_multiline_class = step.multiline_arg ? step.multiline_arg.class : nil
|
78
|
+
snippet = @step_mother.snippet_text(step.actual_keyword, step_name, step_multiline_class)
|
78
79
|
snippet
|
79
80
|
end.compact.uniq
|
80
81
|
|
@@ -74,9 +74,11 @@ module Cucumber
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def visit_outline_table(outline_table)
|
77
|
+
@outline_row = 0
|
77
78
|
@builder.table do
|
78
79
|
super(outline_table)
|
79
80
|
end
|
81
|
+
@outline_row = nil
|
80
82
|
end
|
81
83
|
|
82
84
|
def visit_examples_name(keyword, name)
|
@@ -145,10 +147,12 @@ module Cucumber
|
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end
|
150
|
+
@outline_row += 1 if @outline_row
|
148
151
|
end
|
149
152
|
|
150
153
|
def visit_table_cell_value(value, width, status)
|
151
|
-
@
|
154
|
+
cell_type = @outline_row == 0 ? :th : :td
|
155
|
+
@builder.__send__(cell_type, value, :class => status, :id => "#{@row_id}_#{@col_index}")
|
152
156
|
@col_index += 1
|
153
157
|
end
|
154
158
|
|
@@ -157,10 +157,6 @@ module Cucumber
|
|
157
157
|
@io.flush
|
158
158
|
end
|
159
159
|
|
160
|
-
def visit_table_cell(table_cell)
|
161
|
-
super
|
162
|
-
end
|
163
|
-
|
164
160
|
def visit_table_cell_value(value, width, status)
|
165
161
|
@io.print(' ' + format_string((value.to_s || '').ljust(width), status) + " #{@delim}")
|
166
162
|
@io.flush
|
@@ -10,6 +10,7 @@ module Cucumber
|
|
10
10
|
@io = io
|
11
11
|
@options = options
|
12
12
|
@step_definitions = Hash.new { |h,step_definition| h[step_definition] = [] }
|
13
|
+
@all_step_definitions = step_mother.step_definitions.dup
|
13
14
|
@locations = []
|
14
15
|
end
|
15
16
|
|
@@ -32,6 +33,7 @@ module Cucumber
|
|
32
33
|
description = format_step(keyword, step_match, status, nil)
|
33
34
|
length = (keyword + step_match.format_args).jlength
|
34
35
|
@step_definitions[step_match.step_definition] << [step_match, description, length, location]
|
36
|
+
@all_step_definitions.delete(step_match.step_definition)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
@@ -63,6 +65,20 @@ module Cucumber
|
|
63
65
|
@io.puts format_string(" # #{file_colon_line}".indent(max_length - length), :comment)
|
64
66
|
end
|
65
67
|
end
|
68
|
+
|
69
|
+
print_unused_step_definitions
|
70
|
+
end
|
71
|
+
|
72
|
+
def print_unused_step_definitions
|
73
|
+
if @all_step_definitions.any?
|
74
|
+
max_length = @all_step_definitions.map{|step_definition| step_definition.text_length}.max
|
75
|
+
|
76
|
+
@io.puts format_string("(::) UNUSED (::)", :failed)
|
77
|
+
@all_step_definitions.each do |step_definition|
|
78
|
+
@io.print format_string(step_definition.regexp.inspect, :failed)
|
79
|
+
@io.puts format_string(" # #{step_definition.file_colon_line}".indent(max_length - step_definition.text_length), :comment)
|
80
|
+
end
|
81
|
+
end
|
66
82
|
end
|
67
83
|
end
|
68
84
|
end
|
@@ -118,12 +118,12 @@ module Cucumber
|
|
118
118
|
r8 = nil
|
119
119
|
else
|
120
120
|
self.index = i8
|
121
|
-
r8 = SyntaxNode
|
121
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
122
122
|
end
|
123
123
|
s7 << r8
|
124
124
|
if r8
|
125
125
|
if index < input_length
|
126
|
-
r13 = (SyntaxNode
|
126
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
127
127
|
@index += 1
|
128
128
|
else
|
129
129
|
terminal_parse_failure("any character")
|
@@ -132,7 +132,7 @@ module Cucumber
|
|
132
132
|
s7 << r13
|
133
133
|
end
|
134
134
|
if s7.last
|
135
|
-
r7 = (SyntaxNode
|
135
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
136
136
|
r7.extend(Feature0)
|
137
137
|
else
|
138
138
|
self.index = i7
|
@@ -144,14 +144,14 @@ module Cucumber
|
|
144
144
|
break
|
145
145
|
end
|
146
146
|
end
|
147
|
-
r6 = SyntaxNode
|
147
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
148
148
|
s0 << r6
|
149
149
|
if r6
|
150
150
|
r15 = _nt_background
|
151
151
|
if r15
|
152
152
|
r14 = r15
|
153
153
|
else
|
154
|
-
r14 = SyntaxNode
|
154
|
+
r14 = instantiate_node(SyntaxNode,input, index...index)
|
155
155
|
end
|
156
156
|
s0 << r14
|
157
157
|
if r14
|
@@ -162,7 +162,7 @@ module Cucumber
|
|
162
162
|
if r18
|
163
163
|
r17 = r18
|
164
164
|
else
|
165
|
-
r17 = SyntaxNode
|
165
|
+
r17 = instantiate_node(SyntaxNode,input, index...index)
|
166
166
|
end
|
167
167
|
s0 << r17
|
168
168
|
end
|
@@ -174,7 +174,7 @@ module Cucumber
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
if s0.last
|
177
|
-
r0 = (SyntaxNode
|
177
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
178
178
|
r0.extend(Feature1)
|
179
179
|
r0.extend(Feature2)
|
180
180
|
else
|
@@ -254,12 +254,12 @@ module Cucumber
|
|
254
254
|
self.index = i5
|
255
255
|
r5 = nil
|
256
256
|
else
|
257
|
-
r5 = SyntaxNode
|
257
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
258
258
|
end
|
259
259
|
s3 << r5
|
260
260
|
end
|
261
261
|
if s3.last
|
262
|
-
r3 = (SyntaxNode
|
262
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
263
263
|
r3.extend(Tags0)
|
264
264
|
else
|
265
265
|
self.index = i3
|
@@ -271,11 +271,11 @@ module Cucumber
|
|
271
271
|
break
|
272
272
|
end
|
273
273
|
end
|
274
|
-
r2 = SyntaxNode
|
274
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
275
275
|
s0 << r2
|
276
276
|
end
|
277
277
|
if s0.last
|
278
|
-
r0 = (SyntaxNode
|
278
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
279
279
|
r0.extend(Tags1)
|
280
280
|
r0.extend(Tags2)
|
281
281
|
else
|
@@ -304,7 +304,7 @@ module Cucumber
|
|
304
304
|
|
305
305
|
i0, s0 = index, []
|
306
306
|
if input.index('@', index) == index
|
307
|
-
r1 = (SyntaxNode
|
307
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
308
308
|
@index += 1
|
309
309
|
else
|
310
310
|
terminal_parse_failure('@')
|
@@ -315,7 +315,7 @@ module Cucumber
|
|
315
315
|
s2, i2 = [], index
|
316
316
|
loop do
|
317
317
|
if input.index(Regexp.new('[^@\\r\\n\\t ]'), index) == index
|
318
|
-
r3 = (SyntaxNode
|
318
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
319
319
|
@index += 1
|
320
320
|
else
|
321
321
|
r3 = nil
|
@@ -330,12 +330,12 @@ module Cucumber
|
|
330
330
|
self.index = i2
|
331
331
|
r2 = nil
|
332
332
|
else
|
333
|
-
r2 = SyntaxNode
|
333
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
334
334
|
end
|
335
335
|
s0 << r2
|
336
336
|
end
|
337
337
|
if s0.last
|
338
|
-
r0 = (SyntaxNode
|
338
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
339
339
|
r0.extend(Tag0)
|
340
340
|
else
|
341
341
|
self.index = i0
|
@@ -381,7 +381,7 @@ module Cucumber
|
|
381
381
|
s1 << r3
|
382
382
|
end
|
383
383
|
if s1.last
|
384
|
-
r1 = (SyntaxNode
|
384
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
385
385
|
r1.extend(Comment0)
|
386
386
|
else
|
387
387
|
self.index = i1
|
@@ -393,7 +393,7 @@ module Cucumber
|
|
393
393
|
break
|
394
394
|
end
|
395
395
|
end
|
396
|
-
r0 = SyntaxNode
|
396
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
397
397
|
r0.extend(Comment1)
|
398
398
|
|
399
399
|
node_cache[:comment][start_index] = r0
|
@@ -417,7 +417,7 @@ module Cucumber
|
|
417
417
|
|
418
418
|
i0, s0 = index, []
|
419
419
|
if input.index('#', index) == index
|
420
|
-
r1 = (SyntaxNode
|
420
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
421
421
|
@index += 1
|
422
422
|
else
|
423
423
|
terminal_parse_failure('#')
|
@@ -429,7 +429,7 @@ module Cucumber
|
|
429
429
|
s0 << r2
|
430
430
|
end
|
431
431
|
if s0.last
|
432
|
-
r0 = (SyntaxNode
|
432
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
433
433
|
r0.extend(CommentLine0)
|
434
434
|
else
|
435
435
|
self.index = i0
|
@@ -454,8 +454,12 @@ module Cucumber
|
|
454
454
|
elements[2]
|
455
455
|
end
|
456
456
|
|
457
|
+
def name
|
458
|
+
elements[4]
|
459
|
+
end
|
460
|
+
|
457
461
|
def steps
|
458
|
-
elements[
|
462
|
+
elements[6]
|
459
463
|
end
|
460
464
|
end
|
461
465
|
|
@@ -464,7 +468,8 @@ module Cucumber
|
|
464
468
|
Ast::Background.new(
|
465
469
|
comment.build,
|
466
470
|
background_keyword.line,
|
467
|
-
background_keyword.text_value,
|
471
|
+
background_keyword.text_value,
|
472
|
+
name.text_value,
|
468
473
|
steps.build
|
469
474
|
)
|
470
475
|
end
|
@@ -497,47 +502,56 @@ module Cucumber
|
|
497
502
|
break
|
498
503
|
end
|
499
504
|
end
|
500
|
-
r4 = SyntaxNode
|
505
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
501
506
|
s0 << r4
|
502
507
|
if r4
|
503
|
-
|
504
|
-
s7, i7 = [], index
|
505
|
-
loop do
|
506
|
-
r8 = _nt_eol
|
507
|
-
if r8
|
508
|
-
s7 << r8
|
509
|
-
else
|
510
|
-
break
|
511
|
-
end
|
512
|
-
end
|
513
|
-
if s7.empty?
|
514
|
-
self.index = i7
|
515
|
-
r7 = nil
|
516
|
-
else
|
517
|
-
r7 = SyntaxNode.new(input, i7...index, s7)
|
518
|
-
end
|
508
|
+
r7 = _nt_line_to_eol
|
519
509
|
if r7
|
520
510
|
r6 = r7
|
521
511
|
else
|
522
|
-
|
523
|
-
if r9
|
524
|
-
r6 = r9
|
525
|
-
else
|
526
|
-
self.index = i6
|
527
|
-
r6 = nil
|
528
|
-
end
|
512
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
529
513
|
end
|
530
514
|
s0 << r6
|
531
515
|
if r6
|
532
|
-
|
533
|
-
|
516
|
+
i8 = index
|
517
|
+
s9, i9 = [], index
|
518
|
+
loop do
|
519
|
+
r10 = _nt_eol
|
520
|
+
if r10
|
521
|
+
s9 << r10
|
522
|
+
else
|
523
|
+
break
|
524
|
+
end
|
525
|
+
end
|
526
|
+
if s9.empty?
|
527
|
+
self.index = i9
|
528
|
+
r9 = nil
|
529
|
+
else
|
530
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
531
|
+
end
|
532
|
+
if r9
|
533
|
+
r8 = r9
|
534
|
+
else
|
535
|
+
r11 = _nt_eof
|
536
|
+
if r11
|
537
|
+
r8 = r11
|
538
|
+
else
|
539
|
+
self.index = i8
|
540
|
+
r8 = nil
|
541
|
+
end
|
542
|
+
end
|
543
|
+
s0 << r8
|
544
|
+
if r8
|
545
|
+
r12 = _nt_steps
|
546
|
+
s0 << r12
|
547
|
+
end
|
534
548
|
end
|
535
549
|
end
|
536
550
|
end
|
537
551
|
end
|
538
552
|
end
|
539
553
|
if s0.last
|
540
|
-
r0 = (SyntaxNode
|
554
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
541
555
|
r0.extend(Background0)
|
542
556
|
r0.extend(Background1)
|
543
557
|
else
|
@@ -585,7 +599,7 @@ module Cucumber
|
|
585
599
|
break
|
586
600
|
end
|
587
601
|
end
|
588
|
-
r0 = SyntaxNode
|
602
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
589
603
|
r0.extend(FeatureElements0)
|
590
604
|
|
591
605
|
node_cache[:feature_elements][start_index] = r0
|
@@ -671,7 +685,7 @@ module Cucumber
|
|
671
685
|
break
|
672
686
|
end
|
673
687
|
end
|
674
|
-
r5 = SyntaxNode
|
688
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
675
689
|
s0 << r5
|
676
690
|
if r5
|
677
691
|
r7 = _nt_line_to_eol
|
@@ -694,7 +708,7 @@ module Cucumber
|
|
694
708
|
end
|
695
709
|
end
|
696
710
|
if s0.last
|
697
|
-
r0 = (SyntaxNode
|
711
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
698
712
|
r0.extend(Scenario0)
|
699
713
|
r0.extend(Scenario1)
|
700
714
|
else
|
@@ -790,7 +804,7 @@ module Cucumber
|
|
790
804
|
break
|
791
805
|
end
|
792
806
|
end
|
793
|
-
r5 = SyntaxNode
|
807
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
794
808
|
s0 << r5
|
795
809
|
if r5
|
796
810
|
r7 = _nt_line_to_eol
|
@@ -817,7 +831,7 @@ module Cucumber
|
|
817
831
|
end
|
818
832
|
end
|
819
833
|
if s0.last
|
820
|
-
r0 = (SyntaxNode
|
834
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
821
835
|
r0.extend(ScenarioOutline0)
|
822
836
|
r0.extend(ScenarioOutline1)
|
823
837
|
else
|
@@ -853,7 +867,7 @@ module Cucumber
|
|
853
867
|
break
|
854
868
|
end
|
855
869
|
end
|
856
|
-
r0 = SyntaxNode
|
870
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
857
871
|
r0.extend(Steps0)
|
858
872
|
|
859
873
|
node_cache[:steps][start_index] = r0
|
@@ -918,7 +932,7 @@ module Cucumber
|
|
918
932
|
break
|
919
933
|
end
|
920
934
|
end
|
921
|
-
r2 = SyntaxNode
|
935
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
922
936
|
s0 << r2
|
923
937
|
if r2
|
924
938
|
r4 = _nt_step_keyword
|
@@ -944,7 +958,7 @@ module Cucumber
|
|
944
958
|
self.index = i8
|
945
959
|
r8 = nil
|
946
960
|
else
|
947
|
-
r8 = SyntaxNode
|
961
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
948
962
|
end
|
949
963
|
if r8
|
950
964
|
r7 = r8
|
@@ -963,7 +977,7 @@ module Cucumber
|
|
963
977
|
if r12
|
964
978
|
r11 = r12
|
965
979
|
else
|
966
|
-
r11 = SyntaxNode
|
980
|
+
r11 = instantiate_node(SyntaxNode,input, index...index)
|
967
981
|
end
|
968
982
|
s0 << r11
|
969
983
|
if r11
|
@@ -977,7 +991,7 @@ module Cucumber
|
|
977
991
|
end
|
978
992
|
end
|
979
993
|
if s0.last
|
980
|
-
r0 = (SyntaxNode
|
994
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
981
995
|
r0.extend(Step0)
|
982
996
|
r0.extend(Step1)
|
983
997
|
else
|
@@ -1013,7 +1027,7 @@ module Cucumber
|
|
1013
1027
|
break
|
1014
1028
|
end
|
1015
1029
|
end
|
1016
|
-
r0 = SyntaxNode
|
1030
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1017
1031
|
r0.extend(ExamplesSections0)
|
1018
1032
|
|
1019
1033
|
node_cache[:examples_sections][start_index] = r0
|
@@ -1067,7 +1081,7 @@ module Cucumber
|
|
1067
1081
|
break
|
1068
1082
|
end
|
1069
1083
|
end
|
1070
|
-
r1 = SyntaxNode
|
1084
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1071
1085
|
s0 << r1
|
1072
1086
|
if r1
|
1073
1087
|
r3 = _nt_examples_keyword
|
@@ -1082,14 +1096,14 @@ module Cucumber
|
|
1082
1096
|
break
|
1083
1097
|
end
|
1084
1098
|
end
|
1085
|
-
r4 = SyntaxNode
|
1099
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1086
1100
|
s0 << r4
|
1087
1101
|
if r4
|
1088
1102
|
r7 = _nt_line_to_eol
|
1089
1103
|
if r7
|
1090
1104
|
r6 = r7
|
1091
1105
|
else
|
1092
|
-
r6 = SyntaxNode
|
1106
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
1093
1107
|
end
|
1094
1108
|
s0 << r6
|
1095
1109
|
if r6
|
@@ -1108,7 +1122,7 @@ module Cucumber
|
|
1108
1122
|
end
|
1109
1123
|
end
|
1110
1124
|
if s0.last
|
1111
|
-
r0 = (SyntaxNode
|
1125
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1112
1126
|
r0.extend(Examples0)
|
1113
1127
|
r0.extend(Examples1)
|
1114
1128
|
else
|
@@ -1168,12 +1182,12 @@ module Cucumber
|
|
1168
1182
|
r2 = nil
|
1169
1183
|
else
|
1170
1184
|
self.index = i2
|
1171
|
-
r2 = SyntaxNode
|
1185
|
+
r2 = instantiate_node(SyntaxNode,input, index...index)
|
1172
1186
|
end
|
1173
1187
|
s1 << r2
|
1174
1188
|
if r2
|
1175
1189
|
if index < input_length
|
1176
|
-
r4 = (SyntaxNode
|
1190
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1177
1191
|
@index += 1
|
1178
1192
|
else
|
1179
1193
|
terminal_parse_failure("any character")
|
@@ -1182,7 +1196,7 @@ module Cucumber
|
|
1182
1196
|
s1 << r4
|
1183
1197
|
end
|
1184
1198
|
if s1.last
|
1185
|
-
r1 = (SyntaxNode
|
1199
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1186
1200
|
r1.extend(LineToEol0)
|
1187
1201
|
else
|
1188
1202
|
self.index = i1
|
@@ -1194,7 +1208,7 @@ module Cucumber
|
|
1194
1208
|
break
|
1195
1209
|
end
|
1196
1210
|
end
|
1197
|
-
r0 = SyntaxNode
|
1211
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1198
1212
|
|
1199
1213
|
node_cache[:line_to_eol][start_index] = r0
|
1200
1214
|
|
@@ -1245,12 +1259,12 @@ module Cucumber
|
|
1245
1259
|
r4 = nil
|
1246
1260
|
else
|
1247
1261
|
self.index = i4
|
1248
|
-
r4 = SyntaxNode
|
1262
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1249
1263
|
end
|
1250
1264
|
s3 << r4
|
1251
1265
|
if r4
|
1252
1266
|
if index < input_length
|
1253
|
-
r6 = (SyntaxNode
|
1267
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1254
1268
|
@index += 1
|
1255
1269
|
else
|
1256
1270
|
terminal_parse_failure("any character")
|
@@ -1259,7 +1273,7 @@ module Cucumber
|
|
1259
1273
|
s3 << r6
|
1260
1274
|
end
|
1261
1275
|
if s3.last
|
1262
|
-
r3 = (SyntaxNode
|
1276
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1263
1277
|
r3.extend(PyString0)
|
1264
1278
|
else
|
1265
1279
|
self.index = i3
|
@@ -1271,7 +1285,7 @@ module Cucumber
|
|
1271
1285
|
break
|
1272
1286
|
end
|
1273
1287
|
end
|
1274
|
-
r2 = SyntaxNode
|
1288
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1275
1289
|
s0 << r2
|
1276
1290
|
if r2
|
1277
1291
|
r7 = _nt_close_py_string
|
@@ -1279,7 +1293,7 @@ module Cucumber
|
|
1279
1293
|
end
|
1280
1294
|
end
|
1281
1295
|
if s0.last
|
1282
|
-
r0 = (SyntaxNode
|
1296
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1283
1297
|
r0.extend(PyString1)
|
1284
1298
|
r0.extend(PyString2)
|
1285
1299
|
else
|
@@ -1325,7 +1339,7 @@ module Cucumber
|
|
1325
1339
|
s0 << r1
|
1326
1340
|
if r1
|
1327
1341
|
if input.index('"""', index) == index
|
1328
|
-
r2 = (SyntaxNode
|
1342
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
1329
1343
|
@index += 3
|
1330
1344
|
else
|
1331
1345
|
terminal_parse_failure('"""')
|
@@ -1342,7 +1356,7 @@ module Cucumber
|
|
1342
1356
|
break
|
1343
1357
|
end
|
1344
1358
|
end
|
1345
|
-
r3 = SyntaxNode
|
1359
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1346
1360
|
s0 << r3
|
1347
1361
|
if r3
|
1348
1362
|
r5 = _nt_eol
|
@@ -1351,7 +1365,7 @@ module Cucumber
|
|
1351
1365
|
end
|
1352
1366
|
end
|
1353
1367
|
if s0.last
|
1354
|
-
r0 = (SyntaxNode
|
1368
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1355
1369
|
r0.extend(OpenPyString0)
|
1356
1370
|
r0.extend(OpenPyString1)
|
1357
1371
|
else
|
@@ -1405,11 +1419,11 @@ module Cucumber
|
|
1405
1419
|
break
|
1406
1420
|
end
|
1407
1421
|
end
|
1408
|
-
r2 = SyntaxNode
|
1422
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1409
1423
|
s0 << r2
|
1410
1424
|
if r2
|
1411
1425
|
if input.index('"""', index) == index
|
1412
|
-
r4 = (SyntaxNode
|
1426
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
1413
1427
|
@index += 3
|
1414
1428
|
else
|
1415
1429
|
terminal_parse_failure('"""')
|
@@ -1423,7 +1437,7 @@ module Cucumber
|
|
1423
1437
|
end
|
1424
1438
|
end
|
1425
1439
|
if s0.last
|
1426
|
-
r0 = (SyntaxNode
|
1440
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1427
1441
|
r0.extend(ClosePyString0)
|
1428
1442
|
r0.extend(ClosePyString1)
|
1429
1443
|
else
|
@@ -1465,7 +1479,7 @@ module Cucumber
|
|
1465
1479
|
break
|
1466
1480
|
end
|
1467
1481
|
end
|
1468
|
-
r0 = SyntaxNode
|
1482
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1469
1483
|
|
1470
1484
|
node_cache[:white][start_index] = r0
|
1471
1485
|
|
@@ -59,12 +59,13 @@ module Cucumber
|
|
59
59
|
end
|
60
60
|
|
61
61
|
rule background
|
62
|
-
comment white background_keyword space* (eol+ / eof) steps {
|
62
|
+
comment white background_keyword space* name:line_to_eol? (eol+ / eof) steps {
|
63
63
|
def build
|
64
64
|
Ast::Background.new(
|
65
65
|
comment.build,
|
66
66
|
background_keyword.line,
|
67
|
-
background_keyword.text_value,
|
67
|
+
background_keyword.text_value,
|
68
|
+
name.text_value,
|
68
69
|
steps.build
|
69
70
|
)
|
70
71
|
end
|
@@ -59,7 +59,7 @@ module Cucumber
|
|
59
59
|
PARAM_PATTERN = /"([^\"]*)"/
|
60
60
|
ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
|
61
61
|
|
62
|
-
def self.snippet_text(step_keyword, step_name)
|
62
|
+
def self.snippet_text(step_keyword, step_name, multiline_arg_class = nil)
|
63
63
|
escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
|
64
64
|
escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)
|
65
65
|
|
@@ -68,9 +68,11 @@ module Cucumber
|
|
68
68
|
n += 1
|
69
69
|
"arg#{n}"
|
70
70
|
end
|
71
|
+
block_args << multiline_arg_class.default_arg_name unless multiline_arg_class.nil?
|
71
72
|
block_arg_string = block_args.empty? ? "" : " |#{block_args.join(", ")}|"
|
73
|
+
multiline_class_string = multiline_arg_class ? "# #{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n " : ""
|
72
74
|
|
73
|
-
"#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n pending\nend"
|
75
|
+
"#{step_keyword} /^#{escaped}$/ do#{block_arg_string}\n #{multiline_class_string}pending\nend"
|
74
76
|
end
|
75
77
|
|
76
78
|
class MissingProc < StandardError
|
data/lib/cucumber/step_mother.rb
CHANGED
@@ -45,6 +45,12 @@ module Cucumber
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
class NilWorld < StandardError
|
49
|
+
def initialize
|
50
|
+
super("World procs should never return nil")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
48
54
|
# This is the main interface for registering step definitions, which is done
|
49
55
|
# from <tt>*_steps.rb</tt> files. This module is included right at the top-level
|
50
56
|
# so #register_step_definition (and more interestingly - its aliases) are
|
@@ -139,8 +145,8 @@ module Cucumber
|
|
139
145
|
@step_definitions ||= []
|
140
146
|
end
|
141
147
|
|
142
|
-
def snippet_text(step_keyword, step_name)
|
143
|
-
@snippet_generator.snippet_text(step_keyword, step_name)
|
148
|
+
def snippet_text(step_keyword, step_name, multiline_arg_class)
|
149
|
+
@snippet_generator.snippet_text(step_keyword, step_name, multiline_arg_class)
|
144
150
|
end
|
145
151
|
|
146
152
|
def before_and_after(scenario, skip=false)
|
@@ -171,6 +177,15 @@ module Cucumber
|
|
171
177
|
@current_world = Object.new
|
172
178
|
(@world_procs ||= []).each do |proc|
|
173
179
|
@current_world = proc.call(@current_world)
|
180
|
+
if @current_world.nil?
|
181
|
+
begin
|
182
|
+
raise NilWorld.new
|
183
|
+
rescue NilWorld => e
|
184
|
+
e.backtrace.clear
|
185
|
+
e.backtrace.push(proc.backtrace_line("World"))
|
186
|
+
raise e
|
187
|
+
end
|
188
|
+
end
|
174
189
|
end
|
175
190
|
|
176
191
|
@current_world.extend(World)
|
data/lib/cucumber/version.rb
CHANGED
@@ -2,36 +2,53 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
require 'cucumber/core_ext/instance_exec'
|
3
3
|
|
4
4
|
describe Proc do
|
5
|
+
it "should remove extraneous path info for file" do
|
6
|
+
proc = lambda {|a,b|}
|
7
|
+
proc.file_colon_line.should =~ /^specs\/cucumber\/core_ext\/proc_spec\.rb:6/
|
8
|
+
end
|
9
|
+
|
5
10
|
it "should raise ArityMismatchError for too many args (expecting 0)" do
|
6
11
|
lambda {
|
7
12
|
Object.new.cucumber_instance_exec(true, 'foo', 1) do
|
8
13
|
end
|
9
|
-
}.should raise_error(Cucumber::ArityMismatchError, "
|
14
|
+
}.should raise_error(Cucumber::ArityMismatchError, "Your block takes 0 arguments, but the Regexp matched 1 argument.")
|
10
15
|
end
|
11
16
|
|
12
17
|
it "should raise ArityMismatchError for too many args (expecting 1)" do
|
13
18
|
lambda {
|
14
19
|
Object.new.cucumber_instance_exec(true, 'foo', 1,2) do |a|
|
15
20
|
end
|
16
|
-
}.should raise_error(Cucumber::ArityMismatchError, "
|
21
|
+
}.should raise_error(Cucumber::ArityMismatchError, "Your block takes 1 argument, but the Regexp matched 2 arguments.")
|
17
22
|
end
|
18
23
|
|
19
24
|
it "should raise ArityMismatchError for too few args (expecting 1)" do
|
20
25
|
lambda {
|
21
26
|
Object.new.cucumber_instance_exec(true, 'foo') do |a|
|
22
27
|
end
|
23
|
-
}.should raise_error(Cucumber::ArityMismatchError, "
|
28
|
+
}.should raise_error(Cucumber::ArityMismatchError, "Your block takes 1 argument, but the Regexp matched 0 arguments.")
|
24
29
|
end
|
25
30
|
|
26
31
|
it "should raise ArityMismatchError for too few args (expecting 2)" do
|
27
32
|
lambda {
|
28
33
|
Object.new.cucumber_instance_exec(true, 'foo', 1) do |a,b|
|
29
34
|
end
|
30
|
-
}.should raise_error(Cucumber::ArityMismatchError, "
|
35
|
+
}.should raise_error(Cucumber::ArityMismatchError, "Your block takes 2 arguments, but the Regexp matched 1 argument.")
|
31
36
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
|
38
|
+
if Cucumber::RUBY_1_9
|
39
|
+
it "should allow varargs" do
|
40
|
+
lambda {
|
41
|
+
Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|
|
42
|
+
end
|
43
|
+
}.should_not raise_error(Cucumber::ArityMismatchError)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
# Ruby 1.8
|
47
|
+
it "should not allow varargs because Ruby 1.8 reports same arity as with no args, so we can't really tell the difference." do
|
48
|
+
lambda {
|
49
|
+
Object.new.cucumber_instance_exec(true, 'foo', 1) do |*args|
|
50
|
+
end
|
51
|
+
}.should raise_error(Cucumber::ArityMismatchError, "Your block takes 0 arguments, but the Regexp matched 1 argument.")
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
@@ -85,5 +85,18 @@ specs/cucumber/step_mother_spec.rb:40:in `/Three cute (.*)/'
|
|
85
85
|
@step_mother.Given(/Three (.*) mice/) {|disability|}
|
86
86
|
end.should raise_error(Redundant)
|
87
87
|
end
|
88
|
+
|
89
|
+
it "should raise an error if the world is nil" do
|
90
|
+
@step_mother.World do
|
91
|
+
end
|
92
|
+
|
93
|
+
begin
|
94
|
+
@step_mother.before_and_after(nil)
|
95
|
+
raise "Should fail"
|
96
|
+
rescue => e
|
97
|
+
e.message.should == "World procs should never return nil"
|
98
|
+
e.backtrace.should == ["specs/cucumber/step_mother_spec.rb:90:in `World'"]
|
99
|
+
end
|
100
|
+
end
|
88
101
|
end
|
89
102
|
end
|
data/specs/spec_helper.rb
CHANGED
@@ -1,21 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
gem 'rspec'
|
3
|
-
require 'spec
|
3
|
+
require 'spec'
|
4
|
+
require 'spec/autorun'
|
4
5
|
|
5
6
|
ENV['CUCUMBER_COLORS']=nil
|
6
|
-
$KCODE='u'
|
7
7
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
8
8
|
require 'cucumber'
|
9
9
|
Cucumber.load_language('en')
|
10
10
|
$:.unshift(File.dirname(__FILE__))
|
11
11
|
|
12
12
|
::Term::ANSIColor.coloring = true
|
13
|
-
|
14
|
-
# Open up the tree classes a little for easier inspection.
|
15
|
-
module Cucumber
|
16
|
-
module Tree
|
17
|
-
class Feature
|
18
|
-
attr_reader :header, :scenarios
|
19
|
-
end
|
20
|
-
end
|
21
|
-
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.2.3
|
4
|
+
version: 0.2.3.1
|
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-
|
12
|
+
date: 2009-04-02 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -195,6 +195,11 @@ files:
|
|
195
195
|
- examples/i18n/se/features/step_definitons/kalkulator_steps.rb
|
196
196
|
- examples/i18n/se/features/summering.feature
|
197
197
|
- examples/i18n/se/lib/kalkulator.rb
|
198
|
+
- examples/i18n/sk/Rakefile
|
199
|
+
- examples/i18n/sk/features/addition.feature
|
200
|
+
- examples/i18n/sk/features/division.feature
|
201
|
+
- examples/i18n/sk/features/step_definitons/calculator_steps.rb
|
202
|
+
- examples/i18n/sk/lib/calculator.rb
|
198
203
|
- examples/i18n/zh-CN/Rakefile
|
199
204
|
- examples/i18n/zh-CN/features/addition.feature
|
200
205
|
- examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb
|
@@ -222,6 +227,7 @@ files:
|
|
222
227
|
- examples/selenium_webrat/features/support/env.rb
|
223
228
|
- examples/self_test/README.textile
|
224
229
|
- examples/self_test/Rakefile
|
230
|
+
- examples/self_test/features/background/background_with_name.feature
|
225
231
|
- examples/self_test/features/background/failing_background.feature
|
226
232
|
- examples/self_test/features/background/failing_background_after_success.feature
|
227
233
|
- examples/self_test/features/background/multiline_args_background.feature
|
@@ -238,6 +244,7 @@ files:
|
|
238
244
|
- examples/self_test/features/support/env.rb
|
239
245
|
- examples/self_test/features/support/tag_count_formatter.rb
|
240
246
|
- examples/self_test/features/tons_of_cukes.feature
|
247
|
+
- examples/self_test/features/undefined_multiline_args.feature
|
241
248
|
- examples/sinatra/Rakefile
|
242
249
|
- examples/sinatra/app.rb
|
243
250
|
- examples/sinatra/features/add.feature
|
@@ -278,6 +285,7 @@ files:
|
|
278
285
|
- features/cucumber_cli_outlines.feature
|
279
286
|
- features/custom_formatter.feature
|
280
287
|
- features/report_called_undefined_steps.feature
|
288
|
+
- features/snippet.feature
|
281
289
|
- features/step_definitions/cucumber_steps.rb
|
282
290
|
- features/step_definitions/extra_steps.rb
|
283
291
|
- features/support/env.rb
|