cucumber 2.0.0.rc.1 → 2.0.0.rc.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0985b78183dd2c31d3b7671da6d567042ea9eb6d
|
4
|
+
data.tar.gz: 6237bcc06c38dba04dea5bbbf5b3bdc05c50420a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6af997a1ae5f1f41dab2088c00a850ad103c54a256060d2a5db82edd192e51012c8725afe4208a56932f92df907f1eae4e42d6fdd9e79ec023c959838b046c52
|
7
|
+
data.tar.gz: 2215dffd827dca1de84a88d14375e3540a0d6ff797a59951054dcf341e27bf3baddbebaee8359ae84c6a5b64d0649079105ffdf5770013c85b6d07ee3bbaffc7
|
data/History.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [In Git](https://github.com/cucumber/cucumber/compare/v2.0.0.rc.1...master)
|
2
2
|
|
3
|
+
### Bugfixes
|
4
|
+
|
5
|
+
* World#table no longer creates invalid table objects when using an Array (@tooky, @mattwynne)
|
6
|
+
|
3
7
|
## [v2.0.0.rc.1](https://github.com/cucumber/cucumber/compare/v2.0.0.beta.5...v2.0.0.rc.1)
|
4
8
|
|
5
9
|
### Removed Features
|
@@ -46,34 +46,50 @@ module Cucumber
|
|
46
46
|
|
47
47
|
include Enumerable
|
48
48
|
include Core::Ast::DescribesItself
|
49
|
+
extend Forwardable
|
49
50
|
|
50
51
|
NULL_CONVERSIONS = Hash.new({ :strict => false, :proc => lambda{ |cell_value| cell_value } }).freeze
|
51
52
|
|
52
53
|
attr_accessor :file
|
54
|
+
def_delegator :@ast_table, :location
|
53
55
|
|
54
56
|
def self.default_arg_name #:nodoc:
|
55
57
|
"table"
|
56
58
|
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
class << self
|
61
|
+
def from(data, location = Core::Ast::Location.of_caller)
|
62
|
+
case data
|
63
|
+
when Array
|
64
|
+
from_array(data, location)
|
65
|
+
when String
|
66
|
+
parse(data, location)
|
67
|
+
else
|
68
|
+
raise ArgumentError, "expected data to be a String or an Array."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
def parse(text, location = Core::Ast::Location.of_caller)
|
74
|
+
builder = Builder.new
|
75
|
+
lexer = Gherkin::Lexer::I18nLexer.new(builder)
|
76
|
+
lexer.scan(text)
|
77
|
+
from_array(builder.rows, location)
|
78
|
+
end
|
79
|
+
|
80
|
+
def from_array(data, location = Core::Ast::Location.of_caller)
|
81
|
+
new Core::Ast::DataTable.new(data, location)
|
82
|
+
end
|
63
83
|
end
|
64
84
|
|
65
|
-
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
85
|
+
|
86
|
+
# @param data [Core::Ast::DataTable] the data for the table
|
87
|
+
# @param conversion_procs [Hash] see map_columns!
|
88
|
+
# @param header_mappings [Hash] see map_headers!
|
89
|
+
# @param header_conversion_proc [Proc] see map_headers!
|
70
90
|
def initialize(data, conversion_procs = NULL_CONVERSIONS.dup, header_mappings = {}, header_conversion_proc = nil)
|
71
|
-
|
72
|
-
|
73
|
-
data
|
74
|
-
when Array
|
75
|
-
Core::Ast::DataTable.new(data, Core::Ast::Location.of_caller)
|
76
|
-
end
|
91
|
+
raise ArgumentError, "data must be a Core::Ast::DataTable" unless data.kind_of? Core::Ast::DataTable
|
92
|
+
ast_table = data
|
77
93
|
# Verify that it's square
|
78
94
|
ast_table.transpose
|
79
95
|
@cell_matrix = create_cell_matrix(ast_table)
|
@@ -95,7 +111,7 @@ module Cucumber
|
|
95
111
|
# registered with #map_column! and #map_headers!.
|
96
112
|
#
|
97
113
|
def dup
|
98
|
-
self.class.new(raw
|
114
|
+
self.class.new(Core::Ast::DataTable.new(raw, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
|
99
115
|
end
|
100
116
|
|
101
117
|
# Returns a new, transposed table. Example:
|
@@ -110,7 +126,7 @@ module Cucumber
|
|
110
126
|
# | 4 | 2 |
|
111
127
|
#
|
112
128
|
def transpose
|
113
|
-
self.class.new(raw.transpose, @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
|
129
|
+
self.class.new(Core::Ast::DataTable.new(raw.transpose, location), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
|
114
130
|
end
|
115
131
|
|
116
132
|
# Converts this table into an Array of Hash where the keys of each
|
@@ -237,7 +253,7 @@ module Cucumber
|
|
237
253
|
|
238
254
|
# Returns a new Table where the headers are redefined. See #map_headers!
|
239
255
|
def map_headers(mappings={}, &block)
|
240
|
-
self.class.new
|
256
|
+
self.class.new(Core::Ast::DataTable.new(raw, location), @conversion_procs.dup, mappings, block)
|
241
257
|
end
|
242
258
|
|
243
259
|
# Change how #hashes converts column values. The +column_name+ argument identifies the column
|
@@ -262,7 +278,7 @@ module Cucumber
|
|
262
278
|
def map_column(column_name, strict=true, &conversion_proc)
|
263
279
|
conversion_procs = @conversion_procs.dup
|
264
280
|
conversion_procs[column_name.to_s] = { :strict => strict, :proc => conversion_proc }
|
265
|
-
self.class.new(raw
|
281
|
+
self.class.new(Core::Ast::DataTable.new(raw, location), conversion_procs, @header_mappings.dup, @header_conversion_proc)
|
266
282
|
end
|
267
283
|
|
268
284
|
# Compares +other_table+ to self. If +other_table+ contains columns
|
@@ -444,10 +460,6 @@ module Cucumber
|
|
444
460
|
s
|
445
461
|
end
|
446
462
|
|
447
|
-
def location
|
448
|
-
@ast_table.location
|
449
|
-
end
|
450
|
-
|
451
463
|
def description_for_visitors
|
452
464
|
:legacy_table
|
453
465
|
end
|
data/lib/cucumber/platform.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rbconfig'
|
|
4
4
|
|
5
5
|
module Cucumber
|
6
6
|
unless defined?(Cucumber::VERSION)
|
7
|
-
VERSION = '2.0.0.rc.
|
7
|
+
VERSION = '2.0.0.rc.2'
|
8
8
|
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
|
9
9
|
LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
10
10
|
JRUBY = defined?(JRUBY_VERSION)
|
@@ -44,17 +44,13 @@ module Cucumber
|
|
44
44
|
# %w{ CUC-101 Peeler 22 }
|
45
45
|
# ])
|
46
46
|
#
|
47
|
-
def table(text_or_table, file=nil,
|
47
|
+
def table(text_or_table, file=nil, line=0)
|
48
48
|
if !file
|
49
49
|
location = Core::Ast::Location.of_caller
|
50
50
|
else
|
51
51
|
location = Core::Ast::Location.new(file, line)
|
52
52
|
end
|
53
|
-
|
54
|
-
MultilineArgument::DataTable.new(text_or_table, location)
|
55
|
-
else
|
56
|
-
MultilineArgument::DataTable.parse(text_or_table, file, location)
|
57
|
-
end
|
53
|
+
MultilineArgument::DataTable.from(text_or_table, location)
|
58
54
|
end
|
59
55
|
|
60
56
|
# Returns a Cucumber::MultilineArgument::DocString for +body+.
|
@@ -6,7 +6,7 @@ module Cucumber
|
|
6
6
|
module MultilineArgument
|
7
7
|
describe DataTable do
|
8
8
|
before do
|
9
|
-
@table = DataTable.
|
9
|
+
@table = DataTable.from([
|
10
10
|
%w{one four seven},
|
11
11
|
%w{4444 55555 666666}
|
12
12
|
])
|
@@ -48,7 +48,7 @@ module Cucumber
|
|
48
48
|
it "applies the block once to each value" do
|
49
49
|
headers = ['header']
|
50
50
|
rows = ['value']
|
51
|
-
table = DataTable.
|
51
|
+
table = DataTable.from [headers, rows]
|
52
52
|
count = 0
|
53
53
|
table.map_column!('header') { |value| count +=1 }
|
54
54
|
table.rows
|
@@ -94,7 +94,7 @@ module Cucumber
|
|
94
94
|
it "applies the block once to each value" do
|
95
95
|
headers = ['header']
|
96
96
|
rows = ['value']
|
97
|
-
table = DataTable.
|
97
|
+
table = DataTable.from [headers, rows]
|
98
98
|
count = 0
|
99
99
|
new_table = table.map_column('header') { |value| count +=1 }
|
100
100
|
new_table.rows
|
@@ -133,7 +133,7 @@ module Cucumber
|
|
133
133
|
|
134
134
|
describe "#match" do
|
135
135
|
before(:each) do
|
136
|
-
@table = DataTable.
|
136
|
+
@table = DataTable.from([
|
137
137
|
%w{one four seven},
|
138
138
|
%w{4444 55555 666666}
|
139
139
|
])
|
@@ -152,7 +152,7 @@ module Cucumber
|
|
152
152
|
|
153
153
|
describe "#transpose" do
|
154
154
|
before(:each) do
|
155
|
-
@table = DataTable.
|
155
|
+
@table = DataTable.from([
|
156
156
|
%w{one 1111},
|
157
157
|
%w{two 22222}
|
158
158
|
])
|
@@ -166,7 +166,7 @@ module Cucumber
|
|
166
166
|
describe "#rows_hash" do
|
167
167
|
|
168
168
|
it "should return a hash of the rows" do
|
169
|
-
table = DataTable.
|
169
|
+
table = DataTable.from([
|
170
170
|
%w{one 1111},
|
171
171
|
%w{two 22222}
|
172
172
|
])
|
@@ -174,7 +174,7 @@ module Cucumber
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should fail if the table doesn't have two columns" do
|
177
|
-
faulty_table = DataTable.
|
177
|
+
faulty_table = DataTable.from([
|
178
178
|
%w{one 1111 abc},
|
179
179
|
%w{two 22222 def}
|
180
180
|
])
|
@@ -184,7 +184,7 @@ module Cucumber
|
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should support header and column mapping" do
|
187
|
-
table = DataTable.
|
187
|
+
table = DataTable.from([
|
188
188
|
%w{one 1111},
|
189
189
|
%w{two 22222}
|
190
190
|
])
|
@@ -196,7 +196,7 @@ module Cucumber
|
|
196
196
|
|
197
197
|
describe '#map_headers!' do
|
198
198
|
let(:table) do
|
199
|
-
DataTable.
|
199
|
+
DataTable.from([
|
200
200
|
%w{HELLO WORLD},
|
201
201
|
%w{4444 55555}
|
202
202
|
])
|
@@ -236,7 +236,7 @@ module Cucumber
|
|
236
236
|
|
237
237
|
describe '#map_headers' do
|
238
238
|
let(:table) do
|
239
|
-
DataTable.
|
239
|
+
DataTable.from([
|
240
240
|
%w{HELLO WORLD},
|
241
241
|
%w{4444 55555}
|
242
242
|
])
|
@@ -277,20 +277,20 @@ module Cucumber
|
|
277
277
|
|
278
278
|
describe "diff!" do
|
279
279
|
it "should detect a complex diff" do
|
280
|
-
t1 =
|
280
|
+
t1 = DataTable.from(%{
|
281
281
|
| 1 | 22 | 333 | 4444 |
|
282
282
|
| 55555 | 666666 | 7777777 | 88888888 |
|
283
283
|
| 999999999 | 0000000000 | 01010101010 | 121212121212 |
|
284
284
|
| 4000 | ABC | DEF | 50000 |
|
285
|
-
}
|
285
|
+
})
|
286
286
|
|
287
|
-
t2 =
|
287
|
+
t2 = DataTable.from(%{
|
288
288
|
| a | 4444 | 1 |
|
289
289
|
| bb | 88888888 | 55555 |
|
290
290
|
| ccc | xxxxxxxx | 999999999 |
|
291
291
|
| dddd | 4000 | 300 |
|
292
292
|
| e | 50000 | 4000 |
|
293
|
-
}
|
293
|
+
})
|
294
294
|
expect { t1.diff!(t2) }.to raise_error
|
295
295
|
expect( t1.to_s(:indent => 12, :color => false) ).to eq %{
|
296
296
|
| 1 | (-) 22 | (-) 333 | 4444 | (+) a |
|
@@ -303,11 +303,11 @@ module Cucumber
|
|
303
303
|
end
|
304
304
|
|
305
305
|
it "should not change table when diffed with identical" do
|
306
|
-
t =
|
306
|
+
t = DataTable.from(%{
|
307
307
|
|a|b|c|
|
308
308
|
|d|e|f|
|
309
309
|
|g|h|i|
|
310
|
-
}
|
310
|
+
})
|
311
311
|
t.diff!(t.dup)
|
312
312
|
expect( t.to_s(:indent => 12, :color => false) ).to eq %{
|
313
313
|
| a | b | c |
|
@@ -317,11 +317,11 @@ module Cucumber
|
|
317
317
|
end
|
318
318
|
|
319
319
|
it "should inspect missing and surplus cells" do
|
320
|
-
t1 = DataTable.
|
320
|
+
t1 = DataTable.from([
|
321
321
|
['name', 'male', 'lastname', 'swedish'],
|
322
322
|
['aslak', 'true', 'hellesøy', 'false']
|
323
323
|
])
|
324
|
-
t2 = DataTable.
|
324
|
+
t2 = DataTable.from([
|
325
325
|
['name', 'male', 'lastname', 'swedish'],
|
326
326
|
['aslak', true, 'hellesøy', false]
|
327
327
|
])
|
@@ -335,12 +335,12 @@ module Cucumber
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "should allow column mapping of target before diffing" do
|
338
|
-
t1 = DataTable.
|
338
|
+
t1 = DataTable.from([
|
339
339
|
['name', 'male'],
|
340
340
|
['aslak', 'true']
|
341
341
|
])
|
342
342
|
t1.map_column!('male') { |m| m == 'true' }
|
343
|
-
t2 = DataTable.
|
343
|
+
t2 = DataTable.from([
|
344
344
|
['name', 'male'],
|
345
345
|
['aslak', true]
|
346
346
|
])
|
@@ -352,14 +352,14 @@ module Cucumber
|
|
352
352
|
end
|
353
353
|
|
354
354
|
it "should allow column mapping of argument before diffing" do
|
355
|
-
t1 = DataTable.
|
355
|
+
t1 = DataTable.from([
|
356
356
|
['name', 'male'],
|
357
357
|
['aslak', true]
|
358
358
|
])
|
359
359
|
t1.map_column!('male') {
|
360
360
|
'true'
|
361
361
|
}
|
362
|
-
t2 = DataTable.
|
362
|
+
t2 = DataTable.from([
|
363
363
|
['name', 'male'],
|
364
364
|
['aslak', 'true']
|
365
365
|
])
|
@@ -371,13 +371,13 @@ module Cucumber
|
|
371
371
|
end
|
372
372
|
|
373
373
|
it "should allow header mapping before diffing" do
|
374
|
-
t1 = DataTable.
|
374
|
+
t1 = DataTable.from([
|
375
375
|
['Name', 'Male'],
|
376
376
|
['aslak', 'true']
|
377
377
|
])
|
378
378
|
t1.map_headers!('Name' => 'name', 'Male' => 'male')
|
379
379
|
t1.map_column!('male') { |m| m == 'true' }
|
380
|
-
t2 = DataTable.
|
380
|
+
t2 = DataTable.from([
|
381
381
|
['name', 'male'],
|
382
382
|
['aslak', true]
|
383
383
|
])
|
@@ -389,11 +389,11 @@ module Cucumber
|
|
389
389
|
end
|
390
390
|
|
391
391
|
it "should detect seemingly identical tables as different" do
|
392
|
-
t1 = DataTable.
|
392
|
+
t1 = DataTable.from([
|
393
393
|
['X', 'Y'],
|
394
394
|
['2', '1']
|
395
395
|
])
|
396
|
-
t2 = DataTable.
|
396
|
+
t2 = DataTable.from([
|
397
397
|
['X', 'Y'],
|
398
398
|
[2, 1]
|
399
399
|
])
|
@@ -406,7 +406,7 @@ module Cucumber
|
|
406
406
|
end
|
407
407
|
|
408
408
|
it "should not allow mappings that match more than 1 column" do
|
409
|
-
t1 = DataTable.
|
409
|
+
t1 = DataTable.from([
|
410
410
|
['Cuke', 'Duke'],
|
411
411
|
['Foo', 'Bar']
|
412
412
|
])
|
@@ -418,85 +418,82 @@ module Cucumber
|
|
418
418
|
|
419
419
|
describe "raising" do
|
420
420
|
before do
|
421
|
-
@t =
|
421
|
+
@t = DataTable.from(%{
|
422
422
|
| a | b |
|
423
423
|
| c | d |
|
424
|
-
}
|
424
|
+
})
|
425
425
|
expect( @t ).not_to eq nil
|
426
426
|
end
|
427
427
|
|
428
428
|
it "should raise on missing rows" do
|
429
|
-
t =
|
429
|
+
t = DataTable.from(%{
|
430
430
|
| a | b |
|
431
|
-
}
|
431
|
+
})
|
432
432
|
expect( lambda { @t.dup.diff!(t) } ).to raise_error
|
433
433
|
expect { @t.dup.diff!(t, :missing_row => false) }.not_to raise_error
|
434
434
|
end
|
435
435
|
|
436
436
|
it "should not raise on surplus rows when surplus is at the end" do
|
437
|
-
t =
|
437
|
+
t = DataTable.from(%{
|
438
438
|
| a | b |
|
439
439
|
| c | d |
|
440
440
|
| e | f |
|
441
|
-
}
|
441
|
+
})
|
442
442
|
expect { @t.dup.diff!(t) }.to raise_error
|
443
443
|
expect { @t.dup.diff!(t, :surplus_row => false) }.not_to raise_error
|
444
444
|
end
|
445
445
|
|
446
446
|
it "should not raise on surplus rows when surplus is interleaved" do
|
447
|
-
t1 =
|
447
|
+
t1 = DataTable.from(%{
|
448
448
|
| row_1 | row_2 |
|
449
449
|
| four | 4 |
|
450
|
-
}
|
451
|
-
t2 =
|
450
|
+
})
|
451
|
+
t2 = DataTable.from(%{
|
452
452
|
| row_1 | row_2 |
|
453
453
|
| one | 1 |
|
454
454
|
| two | 2 |
|
455
455
|
| three | 3 |
|
456
456
|
| four | 4 |
|
457
457
|
| five | 5 |
|
458
|
-
}
|
458
|
+
})
|
459
459
|
expect { t1.dup.diff!(t2) }.to raise_error
|
460
460
|
|
461
461
|
expect { t1.dup.diff!(t2, :surplus_row => false) }.not_to raise_error
|
462
462
|
end
|
463
463
|
|
464
464
|
it "should raise on missing columns" do
|
465
|
-
t =
|
465
|
+
t = DataTable.from(%{
|
466
466
|
| a |
|
467
467
|
| c |
|
468
|
-
}
|
468
|
+
})
|
469
469
|
expect { @t.dup.diff!(t) }.to raise_error
|
470
470
|
expect { @t.dup.diff!(t, :missing_col => false) }.not_to raise_error
|
471
471
|
end
|
472
472
|
|
473
473
|
it "should not raise on surplus columns" do
|
474
|
-
t =
|
474
|
+
t = DataTable.from(%{
|
475
475
|
| a | b | x |
|
476
476
|
| c | d | y |
|
477
|
-
}
|
477
|
+
})
|
478
478
|
expect { @t.dup.diff!(t) }.not_to raise_error
|
479
479
|
expect { @t.dup.diff!(t, :surplus_col => true) }.to raise_error
|
480
480
|
end
|
481
481
|
|
482
482
|
it "should not raise on misplaced columns" do
|
483
|
-
t =
|
483
|
+
t = DataTable.from(%{
|
484
484
|
| b | a |
|
485
485
|
| d | c |
|
486
|
-
}
|
486
|
+
})
|
487
487
|
expect { @t.dup.diff!(t) }.not_to raise_error
|
488
488
|
expect { @t.dup.diff!(t, :misplaced_col => true) }.to raise_error
|
489
489
|
end
|
490
490
|
end
|
491
491
|
|
492
|
-
def table(text, file, offset)
|
493
|
-
DataTable.parse(text, file, offset)
|
494
|
-
end
|
495
492
|
end
|
496
493
|
|
497
|
-
describe "#
|
494
|
+
describe "#from" do
|
498
495
|
it "should allow Array of Hash" do
|
499
|
-
t1 = DataTable.
|
496
|
+
t1 = DataTable.from([{'name' => 'aslak', 'male' => 'true'}])
|
500
497
|
expect( t1.to_s(:indent => 12, :color => false) ).to eq %{
|
501
498
|
| male | name |
|
502
499
|
| true | aslak |
|
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: 2.0.0.rc.
|
4
|
+
version: 2.0.0.rc.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
@@ -818,7 +818,7 @@ rubyforge_project:
|
|
818
818
|
rubygems_version: 2.2.2
|
819
819
|
signing_key:
|
820
820
|
specification_version: 4
|
821
|
-
summary: cucumber-2.0.0.rc.
|
821
|
+
summary: cucumber-2.0.0.rc.2
|
822
822
|
test_files:
|
823
823
|
- features/docs/api/list_step_defs_as_json.feature
|
824
824
|
- features/docs/api/run_cli_main_with_existing_runtime.feature
|