cucumber 7.1.0 → 9.2.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.
- checksums.yaml +4 -4
- data/README.md +17 -27
- data/VERSION +1 -0
- data/lib/cucumber/cli/configuration.rb +4 -1
- data/lib/cucumber/cli/main.rb +5 -4
- data/lib/cucumber/cli/options.rb +73 -67
- data/lib/cucumber/cli/profile_loader.rb +6 -10
- data/lib/cucumber/cli/rerun_file.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -6
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/deprecate.rb +6 -46
- data/lib/cucumber/errors.rb +3 -2
- data/lib/cucumber/events/envelope.rb +2 -0
- data/lib/cucumber/events/gherkin_source_parsed.rb +2 -0
- data/lib/cucumber/events/gherkin_source_read.rb +2 -0
- data/lib/cucumber/events/hook_test_step_created.rb +1 -2
- data/lib/cucumber/events/step_activated.rb +0 -6
- data/lib/cucumber/events/step_definition_registered.rb +0 -5
- data/lib/cucumber/events/test_case_created.rb +1 -2
- data/lib/cucumber/events/test_case_finished.rb +2 -0
- data/lib/cucumber/events/test_case_started.rb +2 -0
- data/lib/cucumber/events/test_run_finished.rb +2 -1
- data/lib/cucumber/events/test_step_created.rb +1 -2
- data/lib/cucumber/events/test_step_finished.rb +2 -0
- data/lib/cucumber/events/test_step_started.rb +2 -0
- data/lib/cucumber/events/undefined_parameter_type.rb +3 -2
- data/lib/cucumber/events.rb +1 -1
- data/lib/cucumber/file_specs.rb +2 -1
- data/lib/cucumber/filters/activate_steps.rb +1 -0
- data/lib/cucumber/filters/retry.rb +20 -1
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -3
- data/lib/cucumber/filters/tag_limits.rb +1 -3
- data/lib/cucumber/formatter/ansicolor.rb +70 -78
- data/lib/cucumber/formatter/ast_lookup.rb +16 -8
- data/lib/cucumber/formatter/backtrace_filter.rb +2 -1
- data/lib/cucumber/formatter/console.rb +26 -16
- data/lib/cucumber/formatter/console_counts.rb +3 -1
- data/lib/cucumber/formatter/console_issues.rb +10 -3
- data/lib/cucumber/formatter/curl_option_parser.rb +49 -0
- data/lib/cucumber/formatter/duration_extractor.rb +1 -0
- data/lib/cucumber/formatter/errors.rb +3 -0
- data/lib/cucumber/formatter/fail_fast.rb +1 -1
- data/lib/cucumber/formatter/fanout.rb +1 -1
- data/lib/cucumber/formatter/html.rb +2 -0
- data/lib/cucumber/formatter/http_io.rb +10 -137
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
- data/lib/cucumber/formatter/io.rb +5 -3
- data/lib/cucumber/formatter/io_http_buffer.rb +88 -0
- data/lib/cucumber/formatter/json.rb +10 -12
- data/lib/cucumber/formatter/junit.rb +10 -7
- data/lib/cucumber/formatter/message_builder.rb +24 -8
- data/lib/cucumber/formatter/pretty.rb +24 -10
- data/lib/cucumber/formatter/progress.rb +1 -0
- data/lib/cucumber/formatter/publish_banner_printer.rb +0 -2
- data/lib/cucumber/formatter/query/hook_by_test_step.rb +3 -0
- data/lib/cucumber/formatter/query/pickle_by_test.rb +2 -0
- data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +4 -0
- data/lib/cucumber/formatter/rerun.rb +5 -3
- data/lib/cucumber/formatter/summary.rb +1 -0
- data/lib/cucumber/formatter/unicode.rb +7 -7
- data/lib/cucumber/formatter/url_reporter.rb +3 -1
- data/lib/cucumber/formatter/usage.rb +3 -3
- data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +25 -27
- data/lib/cucumber/glue/dsl.rb +20 -25
- data/lib/cucumber/glue/hook.rb +6 -3
- data/lib/cucumber/glue/invoke_in_world.rb +5 -5
- data/lib/cucumber/glue/proto_world.rb +30 -34
- data/lib/cucumber/glue/registry_and_more.rb +15 -25
- data/lib/cucumber/glue/snippet.rb +4 -2
- data/lib/cucumber/glue/step_definition.rb +6 -3
- data/lib/cucumber/glue/world_factory.rb +2 -0
- data/lib/cucumber/hooks.rb +1 -0
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -1
- data/lib/cucumber/multiline_argument/data_table.rb +68 -80
- data/lib/cucumber/platform.rb +11 -16
- data/lib/cucumber/rake/task.rb +22 -15
- data/lib/cucumber/rspec/disable_option_parser.rb +6 -3
- data/lib/cucumber/running_test_case.rb +2 -1
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
- data/lib/cucumber/runtime/meta_message_builder.rb +108 -0
- data/lib/cucumber/runtime/support_code.rb +3 -0
- data/lib/cucumber/runtime/user_interface.rb +7 -6
- data/lib/cucumber/runtime.rb +22 -38
- data/lib/cucumber/step_match.rb +6 -4
- data/lib/cucumber/step_match_search.rb +3 -2
- data/lib/cucumber/term/ansicolor.rb +74 -50
- data/lib/cucumber/term/banner.rb +3 -0
- data/lib/cucumber.rb +2 -1
- data/lib/simplecov_setup.rb +1 -1
- metadata +95 -244
- data/CHANGELOG.md +0 -3131
- data/CONTRIBUTING.md +0 -250
- data/lib/autotest/cucumber.rb +0 -8
- data/lib/autotest/cucumber_mixin.rb +0 -130
- data/lib/autotest/cucumber_rails.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec2.rb +0 -8
- data/lib/autotest/cucumber_rspec.rb +0 -8
- data/lib/autotest/cucumber_rspec2.rb +0 -8
- data/lib/autotest/discover.rb +0 -13
- data/lib/cucumber/version +0 -1
@@ -27,7 +27,7 @@ module Cucumber
|
|
27
27
|
# This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
|
28
28
|
#
|
29
29
|
class DataTable
|
30
|
-
def self.default_arg_name
|
30
|
+
def self.default_arg_name
|
31
31
|
'table'
|
32
32
|
end
|
33
33
|
|
@@ -75,14 +75,17 @@ module Cucumber
|
|
75
75
|
def eof; end
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
# This is a Hash being initialized with a default value of a Hash, DO NOT REFORMAT TO REMOVE {}
|
79
|
+
# Future versions [3.4.0+] of ruby will interpret these as keywords and break.
|
80
|
+
NULL_CONVERSIONS = Hash.new({ strict: false, proc: ->(cell_value) { cell_value } }).freeze
|
79
81
|
|
80
82
|
# @param data [Core::Test::DataTable] the data for the table
|
81
|
-
# @param conversion_procs [Hash] see
|
82
|
-
# @param header_mappings [Hash] see map_headers
|
83
|
-
# @param header_conversion_proc [Proc] see map_headers
|
83
|
+
# @param conversion_procs [Hash] see map_column
|
84
|
+
# @param header_mappings [Hash] see map_headers
|
85
|
+
# @param header_conversion_proc [Proc] see map_headers
|
84
86
|
def initialize(data, conversion_procs = NULL_CONVERSIONS.dup, header_mappings = {}, header_conversion_proc = nil)
|
85
87
|
raise ArgumentError, 'data must be a Core::Test::DataTable' unless data.is_a? Core::Test::DataTable
|
88
|
+
|
86
89
|
ast_table = data
|
87
90
|
# Verify that it's square
|
88
91
|
ast_table.transpose
|
@@ -107,13 +110,6 @@ module Cucumber
|
|
107
110
|
@ast_table.location
|
108
111
|
end
|
109
112
|
|
110
|
-
# Creates a copy of this table, inheriting any column and header mappings
|
111
|
-
# registered with #map_column! and #map_headers!.
|
112
|
-
#
|
113
|
-
def dup
|
114
|
-
self.class.new(Core::Test::DataTable.new(raw), @conversion_procs.dup, @header_mappings.dup, @header_conversion_proc)
|
115
|
-
end
|
116
|
-
|
117
113
|
# Returns a new, transposed table. Example:
|
118
114
|
#
|
119
115
|
# | a | 7 | 4 |
|
@@ -141,7 +137,7 @@ module Cucumber
|
|
141
137
|
#
|
142
138
|
# [{'a' => '2', 'b' => '3', 'sum' => '5'}, {'a' => '7', 'b' => '9', 'sum' => '16'}]
|
143
139
|
#
|
144
|
-
# Use #map_column
|
140
|
+
# Use #map_column to specify how values in a column are converted.
|
145
141
|
#
|
146
142
|
def hashes
|
147
143
|
@hashes ||= build_hashes
|
@@ -161,7 +157,7 @@ module Cucumber
|
|
161
157
|
def symbolic_hashes
|
162
158
|
@symbolic_hashes ||=
|
163
159
|
hashes.map do |string_hash|
|
164
|
-
|
160
|
+
string_hash.transform_keys { |a| symbolize_key(a) }
|
165
161
|
end
|
166
162
|
end
|
167
163
|
|
@@ -179,6 +175,7 @@ module Cucumber
|
|
179
175
|
#
|
180
176
|
def rows_hash
|
181
177
|
return @rows_hash if @rows_hash
|
178
|
+
|
182
179
|
verify_table_width(2)
|
183
180
|
@rows_hash = transpose.hashes[0]
|
184
181
|
end
|
@@ -199,17 +196,17 @@ module Cucumber
|
|
199
196
|
end
|
200
197
|
end
|
201
198
|
|
202
|
-
def column_names
|
199
|
+
def column_names
|
203
200
|
@column_names ||= cell_matrix[0].map(&:value)
|
204
201
|
end
|
205
202
|
|
206
203
|
def rows
|
207
204
|
hashes.map do |hash|
|
208
|
-
hash.values_at
|
205
|
+
hash.values_at(*headers)
|
209
206
|
end
|
210
207
|
end
|
211
208
|
|
212
|
-
def each_cells_row(&proc)
|
209
|
+
def each_cells_row(&proc)
|
213
210
|
cells_rows.each(&proc)
|
214
211
|
end
|
215
212
|
|
@@ -228,7 +225,8 @@ module Cucumber
|
|
228
225
|
pattern.match(header_to_match)
|
229
226
|
end
|
230
227
|
|
231
|
-
#
|
228
|
+
# Returns a new Table where the headers are redefined.
|
229
|
+
# This makes it possible to use
|
232
230
|
# prettier and more flexible header names in the features. The
|
233
231
|
# keys of +mappings+ are Strings or regular expressions
|
234
232
|
# (anything that responds to #=== will work) that may match
|
@@ -244,54 +242,41 @@ module Cucumber
|
|
244
242
|
# A StepDefinition receiving this table can then map the columns
|
245
243
|
# with both Regexp and String:
|
246
244
|
#
|
247
|
-
# table.map_headers
|
245
|
+
# table.map_headers(/phone( number)?/i => :phone, 'Address' => :address)
|
248
246
|
# table.hashes
|
249
247
|
# # => [{:phone => '123456', :address => 'xyz'}, {:phone => '345678', :address => 'abc'}]
|
250
248
|
#
|
251
249
|
# You may also pass in a block if you wish to convert all of the headers:
|
252
250
|
#
|
253
|
-
# table.map_headers
|
251
|
+
# table.map_headers { |header| header.downcase }
|
254
252
|
# table.hashes.keys
|
255
253
|
# # => ['phone number', 'address']
|
256
254
|
#
|
257
255
|
# When a block is passed in along with a hash then the mappings in the hash take precendence:
|
258
256
|
#
|
259
|
-
# table.map_headers
|
257
|
+
# table.map_headers('Address' => 'ADDRESS') { |header| header.downcase }
|
260
258
|
# table.hashes.keys
|
261
259
|
# # => ['phone number', 'ADDRESS']
|
262
260
|
#
|
263
|
-
def map_headers!(mappings = {}, &block)
|
264
|
-
# TODO: Remove this method for 2.0
|
265
|
-
clear_cache!
|
266
|
-
@header_mappings = mappings
|
267
|
-
@header_conversion_proc = block
|
268
|
-
end
|
269
|
-
|
270
|
-
# Returns a new Table where the headers are redefined. See #map_headers!
|
271
261
|
def map_headers(mappings = {}, &block)
|
272
262
|
self.class.new(Core::Test::DataTable.new(raw), @conversion_procs.dup, mappings, block)
|
273
263
|
end
|
274
264
|
|
265
|
+
# Returns a new Table with an additional column mapping.
|
266
|
+
#
|
275
267
|
# Change how #hashes converts column values. The +column_name+ argument identifies the column
|
276
268
|
# and +conversion_proc+ performs the conversion for each cell in that column. If +strict+ is
|
277
269
|
# true, an error will be raised if the column named +column_name+ is not found. If +strict+
|
278
270
|
# is false, no error will be raised. Example:
|
279
271
|
#
|
280
272
|
# Given /^an expense report for (.*) with the following posts:$/ do |table|
|
281
|
-
# posts_table.map_column
|
273
|
+
# posts_table = posts_table.map_column('amount') { |a| a.to_i }
|
282
274
|
# posts_table.hashes.each do |post|
|
283
275
|
# # post['amount'] is a Fixnum, rather than a String
|
284
276
|
# end
|
285
277
|
# end
|
286
278
|
#
|
287
|
-
def map_column
|
288
|
-
# TODO: Remove this method for 2.0
|
289
|
-
@conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc }
|
290
|
-
self
|
291
|
-
end
|
292
|
-
|
293
|
-
# Returns a new Table with an additional column mapping. See #map_column!
|
294
|
-
def map_column(column_name, strict = true, &conversion_proc)
|
279
|
+
def map_column(column_name, strict: true, &conversion_proc)
|
295
280
|
conversion_procs = @conversion_procs.dup
|
296
281
|
conversion_procs[column_name.to_s] = { strict: strict, proc: conversion_proc }
|
297
282
|
self.class.new(Core::Test::DataTable.new(raw), conversion_procs, @header_mappings.dup, @header_conversion_proc)
|
@@ -312,8 +297,8 @@ module Cucumber
|
|
312
297
|
# where the difference actually is.
|
313
298
|
#
|
314
299
|
# Since all tables that are passed to StepDefinitions always have String
|
315
|
-
# objects in their cells, you may want to use #map_column
|
316
|
-
# #diff!. You can use #map_column
|
300
|
+
# objects in their cells, you may want to use #map_column before calling
|
301
|
+
# #diff!. You can use #map_column on either of the tables.
|
317
302
|
#
|
318
303
|
# A Different error is raised if there are missing rows or columns, or
|
319
304
|
# surplus rows. An error is <em>not</em> raised for surplus columns. An
|
@@ -346,6 +331,7 @@ module Cucumber
|
|
346
331
|
|
347
332
|
class Different < StandardError
|
348
333
|
attr_reader :table
|
334
|
+
|
349
335
|
def initialize(table)
|
350
336
|
@table = table
|
351
337
|
super("Tables were not identical:\n#{table}")
|
@@ -356,7 +342,7 @@ module Cucumber
|
|
356
342
|
cells_rows.map { |cells| cells.map(&:value) }
|
357
343
|
end
|
358
344
|
|
359
|
-
def cells_to_hash(cells)
|
345
|
+
def cells_to_hash(cells)
|
360
346
|
hash = Hash.new do |hash_inner, key|
|
361
347
|
hash_inner[key.to_s] if key.is_a?(Symbol)
|
362
348
|
end
|
@@ -366,51 +352,51 @@ module Cucumber
|
|
366
352
|
hash
|
367
353
|
end
|
368
354
|
|
369
|
-
def index(cells)
|
355
|
+
def index(cells)
|
370
356
|
cells_rows.index(cells)
|
371
357
|
end
|
372
358
|
|
373
|
-
def verify_column(column_name)
|
359
|
+
def verify_column(column_name)
|
374
360
|
raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name)
|
375
361
|
end
|
376
362
|
|
377
|
-
def verify_table_width(width)
|
363
|
+
def verify_table_width(width)
|
378
364
|
raise %(The table must have exactly #{width} columns) unless raw[0].size == width
|
379
365
|
end
|
380
366
|
|
381
367
|
# TODO: remove the below function if it's not actually being used.
|
382
368
|
# Nothing else in this repo calls it.
|
383
|
-
def text?(text)
|
369
|
+
def text?(text)
|
384
370
|
raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
|
385
371
|
end
|
386
372
|
|
387
|
-
def cells_rows
|
388
|
-
@rows ||= cell_matrix.map do |cell_row|
|
373
|
+
def cells_rows
|
374
|
+
@rows ||= cell_matrix.map do |cell_row|
|
389
375
|
Cells.new(self, cell_row)
|
390
376
|
end
|
391
377
|
end
|
392
378
|
|
393
|
-
def headers
|
379
|
+
def headers
|
394
380
|
raw.first
|
395
381
|
end
|
396
382
|
|
397
|
-
def header_cell(col)
|
383
|
+
def header_cell(col)
|
398
384
|
cells_rows[0][col]
|
399
385
|
end
|
400
386
|
|
401
387
|
attr_reader :cell_matrix
|
402
388
|
|
403
|
-
def col_width(col)
|
389
|
+
def col_width(col)
|
404
390
|
columns[col].__send__(:width)
|
405
391
|
end
|
406
392
|
|
407
|
-
def to_s(options = {})
|
393
|
+
def to_s(options = {})
|
408
394
|
indentation = options.key?(:indent) ? options[:indent] : 2
|
409
395
|
prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES
|
410
396
|
DataTablePrinter.new(self, indentation, prefixes).to_s
|
411
397
|
end
|
412
398
|
|
413
|
-
class DataTablePrinter
|
399
|
+
class DataTablePrinter
|
414
400
|
include Cucumber::Gherkin::Formatter::Escaping
|
415
401
|
attr_reader :data_table, :indentation, :prefixes
|
416
402
|
private :data_table, :indentation, :prefixes
|
@@ -424,7 +410,7 @@ module Cucumber
|
|
424
410
|
def to_s
|
425
411
|
leading_row = "\n"
|
426
412
|
end_indentation = indentation - 2
|
427
|
-
trailing_row = "\n
|
413
|
+
trailing_row = "\n#{' ' * end_indentation}"
|
428
414
|
table_rows = data_table.cell_matrix.map { |row| format_row(row) }
|
429
415
|
leading_row + table_rows.join("\n") + trailing_row
|
430
416
|
end
|
@@ -432,7 +418,7 @@ module Cucumber
|
|
432
418
|
private
|
433
419
|
|
434
420
|
def format_row(row)
|
435
|
-
row_start =
|
421
|
+
row_start = "#{' ' * indentation}| "
|
436
422
|
row_end = '|'
|
437
423
|
cells = row.map.with_index do |cell, i|
|
438
424
|
format_cell(cell, data_table.col_width(i))
|
@@ -449,7 +435,7 @@ module Cucumber
|
|
449
435
|
end
|
450
436
|
end
|
451
437
|
|
452
|
-
def columns
|
438
|
+
def columns
|
453
439
|
@columns ||= cell_matrix.transpose.map do |cell_row|
|
454
440
|
Cells.new(self, cell_row)
|
455
441
|
end
|
@@ -469,23 +455,23 @@ module Cucumber
|
|
469
455
|
def build_hashes
|
470
456
|
convert_headers!
|
471
457
|
convert_columns!
|
472
|
-
cells_rows[1
|
458
|
+
cells_rows[1..].map(&:to_hash)
|
473
459
|
end
|
474
460
|
|
475
|
-
def create_cell_matrix(ast_table)
|
461
|
+
def create_cell_matrix(ast_table)
|
476
462
|
ast_table.raw.map do |raw_row|
|
477
463
|
line = begin
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
464
|
+
raw_row.line
|
465
|
+
rescue StandardError
|
466
|
+
-1
|
467
|
+
end
|
482
468
|
raw_row.map do |raw_cell|
|
483
469
|
Cell.new(raw_cell, self, line)
|
484
470
|
end
|
485
471
|
end
|
486
472
|
end
|
487
473
|
|
488
|
-
def convert_columns!
|
474
|
+
def convert_columns!
|
489
475
|
@conversion_procs.each do |column_name, conversion_proc|
|
490
476
|
verify_column(column_name) if conversion_proc[:strict]
|
491
477
|
end
|
@@ -493,13 +479,13 @@ module Cucumber
|
|
493
479
|
cell_matrix.transpose.each do |col|
|
494
480
|
column_name = col[0].value
|
495
481
|
conversion_proc = @conversion_procs[column_name][:proc]
|
496
|
-
col[1
|
482
|
+
col[1..].each do |cell|
|
497
483
|
cell.value = conversion_proc.call(cell.value)
|
498
484
|
end
|
499
485
|
end
|
500
486
|
end
|
501
487
|
|
502
|
-
def convert_headers!
|
488
|
+
def convert_headers!
|
503
489
|
header_cells = cell_matrix[0]
|
504
490
|
|
505
491
|
if @header_conversion_proc
|
@@ -508,20 +494,22 @@ module Cucumber
|
|
508
494
|
end
|
509
495
|
|
510
496
|
@header_mappings.each_pair do |pre, post|
|
511
|
-
mapped_cells = header_cells.
|
497
|
+
mapped_cells = header_cells.select { |cell| pre.is_a?(Regexp) ? cell.value.match?(pre) : cell.value == pre }
|
512
498
|
raise "No headers matched #{pre.inspect}" if mapped_cells.empty?
|
513
499
|
raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map(&:value).inspect}" if mapped_cells.length > 1
|
500
|
+
|
514
501
|
mapped_cells[0].value = post
|
515
502
|
@conversion_procs[post] = @conversion_procs.delete(pre) if @conversion_procs.key?(pre)
|
516
503
|
end
|
517
504
|
end
|
518
505
|
|
519
|
-
def clear_cache!
|
506
|
+
def clear_cache!
|
520
507
|
@hashes = @rows_hash = @column_names = @rows = @columns = nil
|
521
508
|
end
|
522
509
|
|
523
|
-
def ensure_table(table_or_array)
|
524
|
-
return table_or_array if
|
510
|
+
def ensure_table(table_or_array)
|
511
|
+
return table_or_array if table_or_array.instance_of?(DataTable)
|
512
|
+
|
525
513
|
DataTable.from(table_or_array)
|
526
514
|
end
|
527
515
|
|
@@ -530,7 +518,7 @@ module Cucumber
|
|
530
518
|
end
|
531
519
|
|
532
520
|
# Represents a row of cells or columns of cells
|
533
|
-
class Cells
|
521
|
+
class Cells
|
534
522
|
include Enumerable
|
535
523
|
include Cucumber::Gherkin::Formatter::Escaping
|
536
524
|
|
@@ -543,27 +531,27 @@ module Cucumber
|
|
543
531
|
|
544
532
|
def accept(visitor)
|
545
533
|
return if Cucumber.wants_to_quit
|
534
|
+
|
546
535
|
each do |cell|
|
547
536
|
visitor.visit_table_cell(cell)
|
548
537
|
end
|
549
538
|
nil
|
550
539
|
end
|
551
540
|
|
552
|
-
|
553
|
-
def to_sexp #:nodoc:
|
541
|
+
def to_sexp
|
554
542
|
[:row, line, *@cells.map(&:to_sexp)]
|
555
543
|
end
|
556
544
|
|
557
|
-
def to_hash
|
545
|
+
def to_hash
|
558
546
|
@to_hash ||= @table.cells_to_hash(self)
|
559
547
|
end
|
560
548
|
|
561
|
-
def value(
|
562
|
-
self[
|
549
|
+
def value(index)
|
550
|
+
self[index].value
|
563
551
|
end
|
564
552
|
|
565
|
-
def [](
|
566
|
-
@cells[
|
553
|
+
def [](index)
|
554
|
+
@cells[index]
|
567
555
|
end
|
568
556
|
|
569
557
|
def line
|
@@ -589,7 +577,7 @@ module Cucumber
|
|
589
577
|
end
|
590
578
|
end
|
591
579
|
|
592
|
-
class Cell
|
580
|
+
class Cell
|
593
581
|
attr_reader :line, :table
|
594
582
|
attr_accessor :status, :value
|
595
583
|
|
@@ -604,7 +592,7 @@ module Cucumber
|
|
604
592
|
end
|
605
593
|
|
606
594
|
def ==(other)
|
607
|
-
|
595
|
+
other.class == SurplusCell || value == other.value
|
608
596
|
end
|
609
597
|
|
610
598
|
def eql?(other)
|
@@ -616,12 +604,12 @@ module Cucumber
|
|
616
604
|
end
|
617
605
|
|
618
606
|
# For testing only
|
619
|
-
def to_sexp
|
607
|
+
def to_sexp
|
620
608
|
[:cell, @value]
|
621
609
|
end
|
622
610
|
end
|
623
611
|
|
624
|
-
class SurplusCell < Cell
|
612
|
+
class SurplusCell < Cell
|
625
613
|
def status
|
626
614
|
:comment
|
627
615
|
end
|
data/lib/cucumber/platform.rb
CHANGED
@@ -1,27 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Detect the platform we're running on so we can tweak behaviour
|
4
|
-
# in various places.
|
3
|
+
# Detect the platform we're running on so we can tweak behaviour in various places.
|
5
4
|
require 'rbconfig'
|
6
5
|
require 'cucumber/core/platform'
|
7
6
|
|
8
7
|
module Cucumber
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
RAILS = defined?(Rails)
|
14
|
-
RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
15
|
-
RUBY = defined? RUBY_VERSION
|
8
|
+
VERSION = File.read(File.expand_path('../../VERSION', __dir__)).strip
|
9
|
+
BINARY = File.expand_path("#{File.dirname(__FILE__)}/../../bin/cucumber")
|
10
|
+
LIBDIR = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
|
11
|
+
RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
16
12
|
|
17
|
-
|
18
|
-
|
13
|
+
class << self
|
14
|
+
attr_accessor :use_full_backtrace
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
16
|
+
# @private
|
17
|
+
def file_mode(mode, encoding = 'UTF-8')
|
18
|
+
"#{mode}:#{encoding}"
|
24
19
|
end
|
25
|
-
self.use_full_backtrace = false
|
26
20
|
end
|
21
|
+
self.use_full_backtrace = false
|
27
22
|
end
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -2,11 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'cucumber/platform'
|
4
4
|
require 'cucumber/gherkin/formatter/ansi_escapes'
|
5
|
-
|
6
|
-
# Support Rake > 0.8.7
|
7
|
-
require 'rake/dsl_definition'
|
8
|
-
rescue LoadError
|
9
|
-
end
|
5
|
+
require 'rake/dsl_definition'
|
10
6
|
|
11
7
|
module Cucumber
|
12
8
|
module Rake
|
@@ -30,13 +26,14 @@ module Cucumber
|
|
30
26
|
include Cucumber::Gherkin::Formatter::AnsiEscapes
|
31
27
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
32
28
|
|
33
|
-
class InProcessCucumberRunner
|
29
|
+
class InProcessCucumberRunner # :nodoc:
|
34
30
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
35
31
|
|
36
32
|
attr_reader :args
|
37
33
|
|
38
34
|
def initialize(libs, cucumber_opts, feature_files)
|
39
|
-
raise 'libs must be an Array when running in-process' unless
|
35
|
+
raise 'libs must be an Array when running in-process' unless libs.instance_of? Array
|
36
|
+
|
40
37
|
libs.reverse_each { |lib| $LOAD_PATH.unshift(lib) }
|
41
38
|
@args = (
|
42
39
|
cucumber_opts +
|
@@ -51,7 +48,7 @@ module Cucumber
|
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
54
|
-
class ForkedCucumberRunner
|
51
|
+
class ForkedCucumberRunner # :nodoc:
|
55
52
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
56
53
|
|
57
54
|
def initialize(libs, cucumber_bin, cucumber_opts, bundler, feature_files)
|
@@ -110,8 +107,17 @@ module Cucumber
|
|
110
107
|
# Extra options to pass to the cucumber binary. Can be overridden by the CUCUMBER_OPTS environment variable.
|
111
108
|
# It's recommended to pass an Array, but if it's a String it will be #split by ' '.
|
112
109
|
attr_reader :cucumber_opts
|
113
|
-
|
114
|
-
|
110
|
+
|
111
|
+
def cucumber_opts=(opts) # :nodoc:
|
112
|
+
unless opts.instance_of? String
|
113
|
+
@cucumber_opts = opts
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
@cucumber_opts = opts.split(' ')
|
118
|
+
return if @cucumber_opts.length <= 1
|
119
|
+
|
120
|
+
$stderr.puts 'WARNING: consider using an array rather than a space-delimited string with cucumber_opts to avoid undesired behavior.'
|
115
121
|
end
|
116
122
|
|
117
123
|
# Whether or not to fork a new ruby interpreter. Defaults to true. You may gain
|
@@ -145,24 +151,25 @@ module Cucumber
|
|
145
151
|
define_task
|
146
152
|
end
|
147
153
|
|
148
|
-
def define_task
|
154
|
+
def define_task # :nodoc:
|
149
155
|
desc @desc
|
150
156
|
task @task_name do
|
151
157
|
runner.run
|
152
158
|
end
|
153
159
|
end
|
154
160
|
|
155
|
-
def runner(_task_args = nil)
|
156
|
-
cucumber_opts = [
|
161
|
+
def runner(_task_args = nil) # :nodoc:
|
162
|
+
cucumber_opts = [ENV['CUCUMBER_OPTS']&.split(/\s+/) || cucumber_opts_with_profile]
|
157
163
|
return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if fork
|
164
|
+
|
158
165
|
InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
|
159
166
|
end
|
160
167
|
|
161
|
-
def cucumber_opts_with_profile
|
168
|
+
def cucumber_opts_with_profile # :nodoc:
|
162
169
|
Array(cucumber_opts).concat(Array(@profile).flat_map { |p| ['--profile', p] })
|
163
170
|
end
|
164
171
|
|
165
|
-
def feature_files
|
172
|
+
def feature_files # :nodoc:
|
166
173
|
make_command_line_safe(FileList[ENV['FEATURE'] || []])
|
167
174
|
end
|
168
175
|
|
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
module Spec
|
6
|
-
module Runner
|
5
|
+
module Spec # :nodoc:
|
6
|
+
module Runner # :nodoc:
|
7
7
|
# Neuters RSpec's option parser.
|
8
8
|
# (RSpec's option parser tries to parse ARGV, which
|
9
9
|
# will fail when running cucumber)
|
10
|
-
class OptionParser < ::OptionParser
|
10
|
+
class OptionParser < ::OptionParser # :nodoc:
|
11
11
|
NEUTERED_RSPEC = Object.new
|
12
12
|
def NEUTERED_RSPEC.method_missing(_method, *_args) # rubocop:disable Style/MissingRespondToMissing
|
13
13
|
self || super
|
@@ -15,11 +15,14 @@ module Spec #:nodoc:
|
|
15
15
|
|
16
16
|
def self.method_added(method)
|
17
17
|
return if @__neutering_rspec
|
18
|
+
|
18
19
|
@__neutering_rspec = true
|
19
20
|
define_method(method) do |*_a|
|
20
21
|
NEUTERED_RSPEC
|
21
22
|
end
|
22
23
|
@__neutering_rspec = false
|
24
|
+
|
25
|
+
super
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -33,6 +33,7 @@ module Cucumber
|
|
33
33
|
|
34
34
|
def exception
|
35
35
|
return unless @result.failed?
|
36
|
+
|
36
37
|
@result.exception
|
37
38
|
end
|
38
39
|
|
@@ -49,7 +50,7 @@ module Cucumber
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def source_tag_names
|
52
|
-
tags.map
|
53
|
+
tags.map(&:name)
|
53
54
|
end
|
54
55
|
|
55
56
|
def with_result(result)
|
@@ -7,8 +7,7 @@ module Cucumber
|
|
7
7
|
class Runtime
|
8
8
|
# This is what a programming language will consider to be a runtime.
|
9
9
|
#
|
10
|
-
# It's a thin class that directs the
|
11
|
-
# programming languages to the right place.
|
10
|
+
# It's a thin class that directs the handful of methods needed by the programming languages to the right place
|
12
11
|
class ForProgrammingLanguages
|
13
12
|
extend Forwardable
|
14
13
|
|