cucumber-core 1.0.0.beta.2 → 1.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cucumber/core.rb +0 -1
- data/lib/cucumber/core/ast.rb +0 -1
- data/lib/cucumber/core/ast/data_table.rb +8 -223
- data/lib/cucumber/core/ast/examples_table.rb +2 -6
- data/lib/cucumber/core/ast/feature.rb +3 -8
- data/lib/cucumber/core/ast/location.rb +12 -8
- data/lib/cucumber/core/ast/outline_step.rb +4 -11
- data/lib/cucumber/core/ast/scenario_outline.rb +2 -6
- data/lib/cucumber/core/ast/step.rb +28 -7
- data/lib/cucumber/core/gherkin/ast_builder.rb +36 -23
- data/lib/cucumber/core/test/{mapping.rb → action.rb} +10 -11
- data/lib/cucumber/core/test/mapper.rb +3 -3
- data/lib/cucumber/core/test/runner.rb +2 -2
- data/lib/cucumber/core/test/step.rb +7 -7
- data/lib/cucumber/core/version.rb +1 -1
- data/spec/cucumber/core/ast/data_table_spec.rb +5 -92
- data/spec/cucumber/core/ast/location_spec.rb +8 -0
- data/spec/cucumber/core/ast/outline_step_spec.rb +4 -9
- data/spec/cucumber/core/ast/step_spec.rb +70 -3
- data/spec/cucumber/core/test/{mapping_spec.rb → action_spec.rb} +36 -27
- data/spec/cucumber/core/test/mapper_spec.rb +13 -12
- data/spec/cucumber/core/test/runner_spec.rb +14 -0
- data/spec/cucumber/core/test/step_spec.rb +4 -3
- data/spec/cucumber/core_spec.rb +4 -4
- metadata +6 -8
- data/lib/cucumber/core/ast/multiline_argument.rb +0 -34
- data/lib/cucumber/core/test/filters/debug_filter.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216ba512564acf2ba3726b04c0c8a59cee4a10fc
|
4
|
+
data.tar.gz: 7ce2adb926a31742c55b1e2956e6e7a4173a00a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbfeff310db927f86e1660216fab2960e21020dc926e8279b56b860834b79351c40764f47594309137646cc1267ac115205c6b50b405f7d1528cb592b3a8709
|
7
|
+
data.tar.gz: ad2d596044985b3c7e7679af0933a7a4cc9e92d5f72d3509a9089b516a866bfbf2afc76e9ba1b82c482e7b096c9dde3d1f2661833856bd2bcb8ef507f6707338
|
data/lib/cucumber/core.rb
CHANGED
data/lib/cucumber/core/ast.rb
CHANGED
@@ -6,7 +6,6 @@ require 'cucumber/core/ast/empty_multiline_argument'
|
|
6
6
|
require 'cucumber/core/ast/background'
|
7
7
|
require 'cucumber/core/ast/scenario'
|
8
8
|
require 'cucumber/core/ast/step'
|
9
|
-
require 'cucumber/core/ast/multiline_argument'
|
10
9
|
require 'cucumber/core/ast/doc_string'
|
11
10
|
require 'cucumber/core/ast/data_table'
|
12
11
|
require 'cucumber/core/ast/scenario_outline'
|
@@ -30,48 +30,20 @@ module Cucumber
|
|
30
30
|
include DescribesItself
|
31
31
|
include HasLocation
|
32
32
|
|
33
|
-
class Builder
|
34
|
-
attr_reader :rows
|
35
|
-
|
36
|
-
def initialize
|
37
|
-
@rows = []
|
38
|
-
end
|
39
|
-
|
40
|
-
def row(row, line_number)
|
41
|
-
@rows << row
|
42
|
-
end
|
43
|
-
|
44
|
-
def eof
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
33
|
include ::Gherkin::Rubify
|
49
34
|
|
50
|
-
NULL_CONVERSIONS = Hash.new({ :strict => false, :proc => lambda{ |cell_value| cell_value } }).freeze
|
51
|
-
|
52
|
-
attr_accessor :file
|
53
|
-
|
54
|
-
def self.parse(text, uri, location)
|
55
|
-
builder = Builder.new
|
56
|
-
lexer = ::Gherkin::Lexer::I18nLexer.new(builder)
|
57
|
-
lexer.scan(text)
|
58
|
-
new(builder.rows, location)
|
59
|
-
end
|
60
|
-
|
61
35
|
# Creates a new instance. +raw+ should be an Array of Array of String
|
62
36
|
# or an Array of Hash
|
63
37
|
# You don't typically create your own DataTable objects - Cucumber will do
|
64
38
|
# it internally and pass them to your Step Definitions.
|
65
39
|
#
|
66
40
|
def initialize(raw, location)
|
67
|
-
@cells_class = Cells
|
68
|
-
@cell_class = Cell
|
69
41
|
raw = ensure_array_of_array(rubify(raw))
|
70
|
-
|
71
|
-
raw.
|
72
|
-
create_cell_matrix(raw)
|
42
|
+
verify_rows_are_same_length(raw)
|
43
|
+
@raw = raw.freeze
|
73
44
|
@location = location
|
74
45
|
end
|
46
|
+
attr_reader :raw
|
75
47
|
|
76
48
|
def to_step_definition_arg
|
77
49
|
dup
|
@@ -106,108 +78,6 @@ module Cucumber
|
|
106
78
|
self.class.new(new_raw, location)
|
107
79
|
end
|
108
80
|
|
109
|
-
# Converts this table into an Array of Hash where the keys of each
|
110
|
-
# Hash are the headers in the table. For example, a DataTable built from
|
111
|
-
# the following plain text:
|
112
|
-
#
|
113
|
-
# | a | b | sum |
|
114
|
-
# | 2 | 3 | 5 |
|
115
|
-
# | 7 | 9 | 16 |
|
116
|
-
#
|
117
|
-
# Gets converted into the following:
|
118
|
-
#
|
119
|
-
# [{'a' => '2', 'b' => '3', 'sum' => '5'}, {'a' => '7', 'b' => '9', 'sum' => '16'}]
|
120
|
-
#
|
121
|
-
def hashes
|
122
|
-
build_hashes
|
123
|
-
end
|
124
|
-
|
125
|
-
# Converts this table into a Hash where the first column is
|
126
|
-
# used as keys and the second column is used as values
|
127
|
-
#
|
128
|
-
# | a | 2 |
|
129
|
-
# | b | 3 |
|
130
|
-
#
|
131
|
-
# Gets converted into the following:
|
132
|
-
#
|
133
|
-
# {'a' => '2', 'b' => '3'}
|
134
|
-
#
|
135
|
-
# The table must be exactly two columns wide
|
136
|
-
#
|
137
|
-
def rows_hash
|
138
|
-
verify_table_width(2)
|
139
|
-
self.transpose.hashes[0]
|
140
|
-
end
|
141
|
-
|
142
|
-
# Gets the raw data of this table. For example, a DataTable built from
|
143
|
-
# the following plain text:
|
144
|
-
#
|
145
|
-
# | a | b |
|
146
|
-
# | c | d |
|
147
|
-
#
|
148
|
-
# gets converted into the following:
|
149
|
-
#
|
150
|
-
# [['a', 'b'], ['c', 'd']]
|
151
|
-
#
|
152
|
-
def raw
|
153
|
-
cell_matrix.map do |row|
|
154
|
-
row.map do |cell|
|
155
|
-
cell.value
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def column_names #:nodoc:
|
161
|
-
cell_matrix[0].map { |cell| cell.value }
|
162
|
-
end
|
163
|
-
|
164
|
-
def rows
|
165
|
-
hashes.map do |hash|
|
166
|
-
hash.values_at(*headers)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# For testing only
|
171
|
-
def to_sexp #:nodoc:
|
172
|
-
[:table, *cells_rows.map{|row| row.to_sexp}]
|
173
|
-
end
|
174
|
-
|
175
|
-
def to_hash(cells) #:nodoc:
|
176
|
-
hash = Hash.new do |the_hash, key|
|
177
|
-
the_hash[key.to_s] if key.is_a?(Symbol)
|
178
|
-
end
|
179
|
-
column_names.each_with_index do |column_name, column_index|
|
180
|
-
hash[column_name] = cells.value(column_index)
|
181
|
-
end
|
182
|
-
hash
|
183
|
-
end
|
184
|
-
|
185
|
-
def verify_table_width(width) #:nodoc:
|
186
|
-
raise %{The table must have exactly #{width} columns} unless raw[0].size == width
|
187
|
-
end
|
188
|
-
|
189
|
-
def cells_rows #:nodoc:
|
190
|
-
cell_matrix.map do |cell_row|
|
191
|
-
@cells_class.new(self, cell_row)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def headers #:nodoc:
|
196
|
-
raw.first
|
197
|
-
end
|
198
|
-
|
199
|
-
def cell_matrix #:nodoc:
|
200
|
-
@cell_matrix
|
201
|
-
end
|
202
|
-
|
203
|
-
def col_width(col) #:nodoc:
|
204
|
-
columns[col].__send__(:width)
|
205
|
-
end
|
206
|
-
|
207
|
-
def each_cell(&proc)
|
208
|
-
cell_matrix.each{ |row| row.each(&proc) }
|
209
|
-
end
|
210
|
-
|
211
81
|
def ==(other)
|
212
82
|
other.class == self.class && raw == other.raw
|
213
83
|
end
|
@@ -218,35 +88,14 @@ module Cucumber
|
|
218
88
|
|
219
89
|
private
|
220
90
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
cells_rows[1..-1].map do |row|
|
227
|
-
row.to_hash
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
def create_cell_matrix(raw) #:nodoc:
|
232
|
-
@cell_matrix = raw.map do |raw_row|
|
233
|
-
line = raw_row.line rescue -1
|
234
|
-
raw_row.map do |raw_cell|
|
235
|
-
new_cell(raw_cell, line)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
def columns #:nodoc:
|
241
|
-
cell_matrix.transpose.map do |cell_row|
|
242
|
-
@cells_class.new(self, cell_row)
|
91
|
+
def verify_rows_are_same_length(raw)
|
92
|
+
begin
|
93
|
+
raw.transpose
|
94
|
+
rescue IndexError
|
95
|
+
raise ArgumentError, "Rows must all be the same length"
|
243
96
|
end
|
244
97
|
end
|
245
98
|
|
246
|
-
def new_cell(raw_cell, line) #:nodoc:
|
247
|
-
@cell_class.new(raw_cell, self, line)
|
248
|
-
end
|
249
|
-
|
250
99
|
def ensure_array_of_array(array)
|
251
100
|
Hash === array[0] ? hashes_to_array(array) : array
|
252
101
|
end
|
@@ -260,70 +109,6 @@ module Cucumber
|
|
260
109
|
:data_table
|
261
110
|
end
|
262
111
|
|
263
|
-
# Represents a row of cells or columns of cells
|
264
|
-
class Cells #:nodoc:
|
265
|
-
include Enumerable
|
266
|
-
include Gherkin::Formatter::Escaping
|
267
|
-
|
268
|
-
attr_reader :exception
|
269
|
-
|
270
|
-
def initialize(table, cells)
|
271
|
-
@table, @cells = table, cells
|
272
|
-
end
|
273
|
-
|
274
|
-
# For testing only
|
275
|
-
def to_sexp #:nodoc:
|
276
|
-
[:row, line, *@cells.map{|cell| cell.to_sexp}]
|
277
|
-
end
|
278
|
-
|
279
|
-
def to_hash #:nodoc:
|
280
|
-
@to_hash ||= @table.to_hash(self)
|
281
|
-
end
|
282
|
-
|
283
|
-
def value(n) #:nodoc:
|
284
|
-
self[n].value
|
285
|
-
end
|
286
|
-
|
287
|
-
def [](n)
|
288
|
-
@cells[n]
|
289
|
-
end
|
290
|
-
|
291
|
-
def line
|
292
|
-
@cells[0].line
|
293
|
-
end
|
294
|
-
|
295
|
-
private
|
296
|
-
|
297
|
-
def width
|
298
|
-
map{|cell| cell.value ? escape_cell(cell.value.to_s).unpack('U*').length : 0}.max
|
299
|
-
end
|
300
|
-
|
301
|
-
def each(&proc)
|
302
|
-
@cells.each(&proc)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
class Cell #:nodoc:
|
307
|
-
attr_reader :line, :table
|
308
|
-
attr_accessor :status, :value
|
309
|
-
|
310
|
-
def initialize(value, table, line)
|
311
|
-
@value, @table, @line = value, table, line
|
312
|
-
end
|
313
|
-
|
314
|
-
def inspect!
|
315
|
-
@value = "(i) #{value.inspect}"
|
316
|
-
end
|
317
|
-
|
318
|
-
def ==(o)
|
319
|
-
value == o.value
|
320
|
-
end
|
321
|
-
|
322
|
-
# For testing only
|
323
|
-
def to_sexp #:nodoc:
|
324
|
-
[:cell, @value]
|
325
|
-
end
|
326
|
-
end
|
327
112
|
end
|
328
113
|
end
|
329
114
|
end
|
@@ -12,16 +12,12 @@ module Cucumber
|
|
12
12
|
include HasLocation
|
13
13
|
include DescribesItself
|
14
14
|
|
15
|
-
attr_reader :header, :keyword, :tags, :comments, :location
|
15
|
+
attr_reader :header, :keyword, :tags, :comments, :location, :gherkin_statement
|
16
16
|
|
17
17
|
include Cucumber.initializer(
|
18
|
-
:location, :comments, :tags, :keyword, :title, :description, :header, :example_rows
|
18
|
+
:gherkin_statement, :location, :comments, :tags, :keyword, :title, :description, :header, :example_rows
|
19
19
|
)
|
20
20
|
|
21
|
-
def gherkin_statement(node=nil)
|
22
|
-
@gherkin_statement ||= node
|
23
|
-
end
|
24
|
-
|
25
21
|
private
|
26
22
|
|
27
23
|
def description_for_visitors
|
@@ -12,19 +12,14 @@ module Cucumber
|
|
12
12
|
include HasLocation
|
13
13
|
include DescribesItself
|
14
14
|
|
15
|
-
|
16
|
-
attr_reader :
|
17
|
-
attr_reader :comments, :background, :tags, :keyword, :location, :title
|
15
|
+
attr_reader :feature_elements, :language
|
16
|
+
attr_reader :comments, :background, :tags, :keyword, :location, :title, :gherkin_statement
|
18
17
|
|
19
|
-
include Cucumber.initializer(:location, :background, :comments, :tags, :keyword, :title, :description, :feature_elements)
|
18
|
+
include Cucumber.initializer(:gherkin_statement, :language, :location, :background, :comments, :tags, :keyword, :title, :description, :feature_elements)
|
20
19
|
def initialize(*)
|
21
20
|
super
|
22
21
|
end
|
23
22
|
|
24
|
-
def gherkin_statement(node = nil)
|
25
|
-
@gherkin_statement ||= node
|
26
|
-
end
|
27
|
-
|
28
23
|
def children
|
29
24
|
[background] + @feature_elements
|
30
25
|
end
|
@@ -13,10 +13,14 @@ module Cucumber
|
|
13
13
|
def_delegator :filepath, :same_as?
|
14
14
|
def_delegator :filepath, :filename, :file
|
15
15
|
|
16
|
-
def
|
16
|
+
def self.of_caller
|
17
|
+
file, raw_line = *caller[1].split(':')[0..1]
|
18
|
+
new(file, raw_line.to_i)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(filepath, raw_lines=WILDCARD)
|
17
22
|
filepath || raise(ArgumentError, "file is mandatory")
|
18
|
-
|
19
|
-
super(FilePath.new(filepath), Lines.new(lines))
|
23
|
+
super(FilePath.new(filepath), Lines.new(raw_lines))
|
20
24
|
end
|
21
25
|
|
22
26
|
def match?(other)
|
@@ -58,12 +62,12 @@ module Cucumber
|
|
58
62
|
protected :data
|
59
63
|
attr_reader :line
|
60
64
|
|
61
|
-
def initialize(
|
62
|
-
if Cucumber::JRUBY &&
|
63
|
-
|
65
|
+
def initialize(raw_data)
|
66
|
+
if Cucumber::JRUBY && raw_data.is_a?(::Java::GherkinFormatterModel::Range)
|
67
|
+
raw_data = Range.new(raw_data.first, raw_data.last)
|
64
68
|
end
|
65
|
-
|
66
|
-
|
69
|
+
super Array(raw_data).to_set
|
70
|
+
@line = data.first
|
67
71
|
end
|
68
72
|
|
69
73
|
def include?(other)
|
@@ -10,22 +10,15 @@ module Cucumber
|
|
10
10
|
include HasLocation
|
11
11
|
include DescribesItself
|
12
12
|
|
13
|
-
attr_reader :language, :location, :keyword, :name, :multiline_arg
|
13
|
+
attr_reader :gherkin_statement, :language, :location, :keyword, :name, :multiline_arg
|
14
14
|
|
15
|
-
def initialize(language, location, keyword, name, multiline_arg)
|
16
|
-
@language, @location, @keyword, @name, @multiline_arg = language, location, keyword, name, multiline_arg
|
15
|
+
def initialize(gherkin_statement, language, location, keyword, name, multiline_arg)
|
16
|
+
@gherkin_statement, @language, @location, @keyword, @name, @multiline_arg = gherkin_statement, language, location, keyword, name, multiline_arg
|
17
17
|
@language || raise("Language is required!")
|
18
|
-
@gherkin_statement = nil
|
19
|
-
end
|
20
|
-
|
21
|
-
def gherkin_statement(node = nil)
|
22
|
-
@gherkin_statement ||= node
|
23
18
|
end
|
24
19
|
|
25
20
|
def to_step(row)
|
26
|
-
|
27
|
-
step.gherkin_statement(@gherkin_statement)
|
28
|
-
step
|
21
|
+
Ast::ExpandedOutlineStep.new(self, gherkin_statement, language, row.location, keyword, row.expand(name), replace_multiline_arg(row))
|
29
22
|
end
|
30
23
|
|
31
24
|
private
|
@@ -18,13 +18,9 @@ module Cucumber
|
|
18
18
|
attr_reader :line
|
19
19
|
private :line
|
20
20
|
|
21
|
-
include Cucumber.initializer(:language, :location, :background, :comments, :tags, :feature_tags, :keyword, :title, :description, :steps, :examples_tables)
|
21
|
+
include Cucumber.initializer(:gherkin_statement, :language, :location, :background, :comments, :tags, :feature_tags, :keyword, :title, :description, :steps, :examples_tables)
|
22
22
|
|
23
|
-
attr_reader :comments, :tags, :keyword, :background, :location
|
24
|
-
|
25
|
-
def gherkin_statement(node = nil)
|
26
|
-
@gherkin_statement ||= node
|
27
|
-
end
|
23
|
+
attr_reader :comments, :tags, :keyword, :background, :location, :gherkin_statement
|
28
24
|
|
29
25
|
private
|
30
26
|
|
@@ -8,20 +8,20 @@ module Cucumber
|
|
8
8
|
include HasLocation
|
9
9
|
include DescribesItself
|
10
10
|
|
11
|
-
attr_reader :keyword, :name, :language, :exception, :multiline_arg
|
11
|
+
attr_reader :keyword, :name, :language, :exception, :multiline_arg, :gherkin_statement
|
12
12
|
|
13
|
-
def initialize(language, location, keyword, name, multiline_arg)
|
14
|
-
@location, @keyword, @name, @multiline_arg = location, keyword, name, multiline_arg
|
15
|
-
end
|
16
|
-
|
17
|
-
def gherkin_statement(node = nil)
|
18
|
-
@gherkin_statement ||= node
|
13
|
+
def initialize(gherkin_statement, language, location, keyword, name, multiline_arg)
|
14
|
+
@gherkin_statement, @location, @keyword, @name, @multiline_arg = gherkin_statement, location, keyword, name, multiline_arg
|
19
15
|
end
|
20
16
|
|
21
17
|
def to_sexp
|
22
18
|
[:step, line, keyword, name, @multiline_arg.to_sexp]
|
23
19
|
end
|
24
20
|
|
21
|
+
def backtrace_line
|
22
|
+
"#{location}:in `#{keyword}#{name}'"
|
23
|
+
end
|
24
|
+
|
25
25
|
private
|
26
26
|
|
27
27
|
def children
|
@@ -32,6 +32,27 @@ module Cucumber
|
|
32
32
|
:step
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
class ExpandedOutlineStep < Step #:nodoc:
|
37
|
+
|
38
|
+
def initialize(outline_step, gherkin_statement, language, location, keyword, name, multiline_arg)
|
39
|
+
@outline_step, @gherkin_statement, @location, @keyword, @name, @multiline_arg = outline_step, gherkin_statement, location, keyword, name, multiline_arg
|
40
|
+
end
|
41
|
+
|
42
|
+
alias :self_match_locations? :match_locations?
|
43
|
+
|
44
|
+
def match_locations?(queried_locations)
|
45
|
+
self_match_locations?(queried_locations) or @outline_step.match_locations?(queried_locations)
|
46
|
+
end
|
47
|
+
|
48
|
+
alias :step_backtrace_line :backtrace_line
|
49
|
+
|
50
|
+
def backtrace_line
|
51
|
+
"#{step_backtrace_line}\n" +
|
52
|
+
"#{@outline_step.location}:in `#{@outline_step.keyword}#{@outline_step.name}'"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
35
56
|
end
|
36
57
|
end
|
37
58
|
end
|