cucumber 9.0.2 → 9.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -8
- data/VERSION +1 -1
- data/lib/cucumber/cli/main.rb +1 -1
- data/lib/cucumber/cli/options.rb +37 -37
- data/lib/cucumber/cli/profile_loader.rb +5 -5
- data/lib/cucumber/configuration.rb +1 -1
- data/lib/cucumber/deprecate.rb +6 -47
- data/lib/cucumber/formatter/ansicolor.rb +18 -26
- data/lib/cucumber/formatter/ast_lookup.rb +14 -6
- data/lib/cucumber/formatter/console.rb +14 -9
- data/lib/cucumber/formatter/json.rb +2 -6
- data/lib/cucumber/formatter/junit.rb +1 -1
- data/lib/cucumber/formatter/message_builder.rb +19 -6
- data/lib/cucumber/formatter/pretty.rb +7 -3
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +19 -20
- data/lib/cucumber/glue/invoke_in_world.rb +1 -1
- data/lib/cucumber/glue/proto_world.rb +17 -22
- data/lib/cucumber/glue/registry_and_more.rb +7 -4
- data/lib/cucumber/multiline_argument/data_table.rb +32 -33
- data/lib/cucumber/rake/task.rb +1 -5
- data/lib/cucumber/running_test_case.rb +1 -1
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
- data/lib/cucumber/runtime/meta_message_builder.rb +2 -2
- data/lib/cucumber/runtime/user_interface.rb +2 -2
- data/lib/cucumber/runtime.rb +1 -1
- metadata +35 -241
- data/lib/autotest/cucumber.rb +0 -8
- data/lib/autotest/cucumber_mixin.rb +0 -133
- 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 -14
@@ -5,8 +5,7 @@ module Cucumber
|
|
5
5
|
module Formatter
|
6
6
|
# Defines aliases for ANSI coloured output. Default colours can be overridden by defining
|
7
7
|
# a <tt>GHERKIN_COLORS</tt> variable in your shell, very much like how you can
|
8
|
-
# tweak the familiar POSIX command <tt>ls</tt> with
|
9
|
-
# $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
8
|
+
# tweak the familiar POSIX command <tt>ls</tt> with $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
10
9
|
#
|
11
10
|
# The colours that you can change are:
|
12
11
|
#
|
@@ -41,30 +40,30 @@ module Cucumber
|
|
41
40
|
# Although not listed, you can also use <tt>grey</tt>
|
42
41
|
module AnsiEscapes
|
43
42
|
COLORS = {
|
44
|
-
'black'
|
45
|
-
'red'
|
46
|
-
'green'
|
47
|
-
'yellow'
|
48
|
-
'blue'
|
43
|
+
'black' => "\e[30m",
|
44
|
+
'red' => "\e[31m",
|
45
|
+
'green' => "\e[32m",
|
46
|
+
'yellow' => "\e[33m",
|
47
|
+
'blue' => "\e[34m",
|
49
48
|
'magenta' => "\e[35m",
|
50
|
-
'cyan'
|
51
|
-
'white'
|
52
|
-
'grey'
|
53
|
-
'bold'
|
49
|
+
'cyan' => "\e[36m",
|
50
|
+
'white' => "\e[37m",
|
51
|
+
'grey' => "\e[90m",
|
52
|
+
'bold' => "\e[1m"
|
54
53
|
}.freeze
|
55
54
|
|
56
55
|
ALIASES = Hash.new do |h, k|
|
57
56
|
"#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/
|
58
57
|
end.merge(
|
59
58
|
'undefined' => 'yellow',
|
60
|
-
'pending'
|
59
|
+
'pending' => 'yellow',
|
61
60
|
'executing' => 'grey',
|
62
|
-
'failed'
|
63
|
-
'passed'
|
64
|
-
'outline'
|
65
|
-
'skipped'
|
66
|
-
'comments'
|
67
|
-
'tag'
|
61
|
+
'failed' => 'red',
|
62
|
+
'passed' => 'green',
|
63
|
+
'outline' => 'cyan',
|
64
|
+
'skipped' => 'cyan',
|
65
|
+
'comments' => 'grey',
|
66
|
+
'tag' => 'cyan'
|
68
67
|
)
|
69
68
|
|
70
69
|
# Example: export GHERKIN_COLORS="passed=red:failed=yellow"
|
@@ -87,8 +86,8 @@ module Cucumber
|
|
87
86
|
"\e[0m"
|
88
87
|
end
|
89
88
|
|
90
|
-
def up(
|
91
|
-
"\e[#{
|
89
|
+
def up(amount)
|
90
|
+
"\e[#{amount}A"
|
92
91
|
end
|
93
92
|
end
|
94
93
|
end
|
@@ -48,7 +48,7 @@ module Cucumber
|
|
48
48
|
|
49
49
|
def self.cucumber_run_with_backtrace_filtering(pseudo_method)
|
50
50
|
yield
|
51
|
-
rescue Exception => e
|
51
|
+
rescue Exception => e
|
52
52
|
instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
|
53
53
|
replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
|
54
54
|
raise e
|
@@ -7,7 +7,7 @@ require 'mini_mime'
|
|
7
7
|
|
8
8
|
module Cucumber
|
9
9
|
module Glue
|
10
|
-
# Defines the basic API methods
|
10
|
+
# Defines the basic API methods available in all Cucumber step definitions.
|
11
11
|
#
|
12
12
|
# You can, and probably should, extend this API with your own methods that
|
13
13
|
# make sense in your domain. For more on that, see {Cucumber::Glue::Dsl#World}
|
@@ -26,7 +26,7 @@ module Cucumber
|
|
26
26
|
# @example Passing a multiline string
|
27
27
|
# step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
|
28
28
|
# @param [String] name The name of the step
|
29
|
-
# @param [String, Cucumber::Test::DocString, Cucumber::Ast::Table]
|
29
|
+
# @param [String, Cucumber::Test::DocString, Cucumber::Ast::Table] raw_multiline_arg
|
30
30
|
def step(name, raw_multiline_arg = nil)
|
31
31
|
super
|
32
32
|
end
|
@@ -84,17 +84,19 @@ module Cucumber
|
|
84
84
|
|
85
85
|
# Attach a file to the output
|
86
86
|
# @param file [string|io] the file to attach.
|
87
|
-
# It can be a string containing the file content itself,
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
87
|
+
# It can be a string containing the file content itself, the file path, or an IO ready to be read.
|
88
|
+
# @param media_type [string] the media type.
|
89
|
+
# If file is a valid path, media_type can be omitted, it will then be inferred from the file name.
|
90
|
+
# @param filename [string] the name of the file you wish to specify.
|
91
|
+
# This is only needed in situations where you want to rename a PDF download e.t.c. - In most situations
|
92
|
+
# you should not need to pass a filename
|
93
|
+
def attach(file, media_type = nil, filename = nil)
|
92
94
|
return super unless File.file?(file)
|
93
95
|
|
94
96
|
content = File.read(file, mode: 'rb')
|
95
97
|
media_type = MiniMime.lookup_by_filename(file)&.content_type if media_type.nil?
|
96
98
|
|
97
|
-
super(content, media_type.to_s)
|
99
|
+
super(content, media_type.to_s, filename)
|
98
100
|
rescue StandardError
|
99
101
|
super
|
100
102
|
end
|
@@ -103,12 +105,9 @@ module Cucumber
|
|
103
105
|
def pending(message = 'TODO')
|
104
106
|
raise Pending, message unless block_given?
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
raise Pending, message
|
110
|
-
end
|
111
|
-
raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
|
108
|
+
yield
|
109
|
+
rescue Exception
|
110
|
+
raise Pending, message
|
112
111
|
end
|
113
112
|
|
114
113
|
# Skips this step and the remaining steps in the scenario
|
@@ -126,8 +125,8 @@ module Cucumber
|
|
126
125
|
inspect
|
127
126
|
end
|
128
127
|
|
129
|
-
#
|
130
|
-
def self.for(runtime, language)
|
128
|
+
# Dynamically generate the API module, closuring the dependencies
|
129
|
+
def self.for(runtime, language)
|
131
130
|
Module.new do
|
132
131
|
def self.extended(object)
|
133
132
|
# wrap the dynamically generated module so that we can document the methods
|
@@ -156,8 +155,8 @@ module Cucumber
|
|
156
155
|
runtime.ask(question, timeout_seconds)
|
157
156
|
end
|
158
157
|
|
159
|
-
define_method(:attach) do |file, media_type|
|
160
|
-
runtime.attach(file, media_type)
|
158
|
+
define_method(:attach) do |file, media_type, filename|
|
159
|
+
runtime.attach(file, media_type, filename)
|
161
160
|
end
|
162
161
|
|
163
162
|
# Prints the list of modules that are included in the World
|
@@ -172,14 +171,12 @@ module Cucumber
|
|
172
171
|
|
173
172
|
private
|
174
173
|
|
175
|
-
# @private
|
176
174
|
def add_world_modules!(modules)
|
177
175
|
modules.each do |world_module|
|
178
176
|
extend(world_module)
|
179
177
|
end
|
180
178
|
end
|
181
179
|
|
182
|
-
# @private
|
183
180
|
def add_namespaced_modules!(modules)
|
184
181
|
@__namespaced_modules = modules
|
185
182
|
modules.each do |namespace, world_modules|
|
@@ -199,7 +196,6 @@ module Cucumber
|
|
199
196
|
end
|
200
197
|
end
|
201
198
|
|
202
|
-
# @private
|
203
199
|
def stringify_namespaced_modules
|
204
200
|
return '' if @__namespaced_modules.nil?
|
205
201
|
|
@@ -208,7 +204,6 @@ module Cucumber
|
|
208
204
|
end
|
209
205
|
end
|
210
206
|
|
211
|
-
# @private
|
212
207
|
AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
|
213
208
|
end
|
214
209
|
end
|
@@ -198,16 +198,19 @@ module Cucumber
|
|
198
198
|
private
|
199
199
|
|
200
200
|
def parameter_type_envelope(parameter_type)
|
201
|
-
# TODO: should
|
201
|
+
# TODO: should this be moved to Cucumber::Expression::ParameterType#to_envelope ??
|
202
202
|
# Note: that would mean that cucumber-expression would depend on cucumber-messages
|
203
|
-
|
204
203
|
Cucumber::Messages::Envelope.new(
|
205
204
|
parameter_type: Cucumber::Messages::ParameterType.new(
|
206
205
|
id: @configuration.id_generator.new_id,
|
207
206
|
name: parameter_type.name,
|
208
207
|
regular_expressions: parameter_type.regexps.map(&:to_s),
|
209
|
-
prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match
|
210
|
-
use_for_snippets: parameter_type.use_for_snippets
|
208
|
+
prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match,
|
209
|
+
use_for_snippets: parameter_type.use_for_snippets,
|
210
|
+
source_reference: Cucumber::Messages::SourceReference.new(
|
211
|
+
uri: parameter_type.transformer.source_location[0],
|
212
|
+
location: Cucumber::Messages::Location.new(line: parameter_type.transformer.source_location[1])
|
213
|
+
)
|
211
214
|
)
|
212
215
|
)
|
213
216
|
end
|
@@ -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
|
|
@@ -194,17 +194,17 @@ module Cucumber
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
def column_names
|
197
|
+
def column_names
|
198
198
|
@column_names ||= cell_matrix[0].map(&:value)
|
199
199
|
end
|
200
200
|
|
201
201
|
def rows
|
202
202
|
hashes.map do |hash|
|
203
|
-
hash.values_at
|
203
|
+
hash.values_at(*headers)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
def each_cells_row(&proc)
|
207
|
+
def each_cells_row(&proc)
|
208
208
|
cells_rows.each(&proc)
|
209
209
|
end
|
210
210
|
|
@@ -340,7 +340,7 @@ module Cucumber
|
|
340
340
|
cells_rows.map { |cells| cells.map(&:value) }
|
341
341
|
end
|
342
342
|
|
343
|
-
def cells_to_hash(cells)
|
343
|
+
def cells_to_hash(cells)
|
344
344
|
hash = Hash.new do |hash_inner, key|
|
345
345
|
hash_inner[key.to_s] if key.is_a?(Symbol)
|
346
346
|
end
|
@@ -350,51 +350,51 @@ module Cucumber
|
|
350
350
|
hash
|
351
351
|
end
|
352
352
|
|
353
|
-
def index(cells)
|
353
|
+
def index(cells)
|
354
354
|
cells_rows.index(cells)
|
355
355
|
end
|
356
356
|
|
357
|
-
def verify_column(column_name)
|
357
|
+
def verify_column(column_name)
|
358
358
|
raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name)
|
359
359
|
end
|
360
360
|
|
361
|
-
def verify_table_width(width)
|
361
|
+
def verify_table_width(width)
|
362
362
|
raise %(The table must have exactly #{width} columns) unless raw[0].size == width
|
363
363
|
end
|
364
364
|
|
365
365
|
# TODO: remove the below function if it's not actually being used.
|
366
366
|
# Nothing else in this repo calls it.
|
367
|
-
def text?(text)
|
367
|
+
def text?(text)
|
368
368
|
raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
|
369
369
|
end
|
370
370
|
|
371
|
-
def cells_rows
|
372
|
-
@rows ||= cell_matrix.map do |cell_row|
|
371
|
+
def cells_rows
|
372
|
+
@rows ||= cell_matrix.map do |cell_row|
|
373
373
|
Cells.new(self, cell_row)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
-
def headers
|
377
|
+
def headers
|
378
378
|
raw.first
|
379
379
|
end
|
380
380
|
|
381
|
-
def header_cell(col)
|
381
|
+
def header_cell(col)
|
382
382
|
cells_rows[0][col]
|
383
383
|
end
|
384
384
|
|
385
385
|
attr_reader :cell_matrix
|
386
386
|
|
387
|
-
def col_width(col)
|
387
|
+
def col_width(col)
|
388
388
|
columns[col].__send__(:width)
|
389
389
|
end
|
390
390
|
|
391
|
-
def to_s(options = {})
|
391
|
+
def to_s(options = {})
|
392
392
|
indentation = options.key?(:indent) ? options[:indent] : 2
|
393
393
|
prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES
|
394
394
|
DataTablePrinter.new(self, indentation, prefixes).to_s
|
395
395
|
end
|
396
396
|
|
397
|
-
class DataTablePrinter
|
397
|
+
class DataTablePrinter
|
398
398
|
include Cucumber::Gherkin::Formatter::Escaping
|
399
399
|
attr_reader :data_table, :indentation, :prefixes
|
400
400
|
private :data_table, :indentation, :prefixes
|
@@ -433,7 +433,7 @@ module Cucumber
|
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
436
|
-
def columns
|
436
|
+
def columns
|
437
437
|
@columns ||= cell_matrix.transpose.map do |cell_row|
|
438
438
|
Cells.new(self, cell_row)
|
439
439
|
end
|
@@ -456,7 +456,7 @@ module Cucumber
|
|
456
456
|
cells_rows[1..].map(&:to_hash)
|
457
457
|
end
|
458
458
|
|
459
|
-
def create_cell_matrix(ast_table)
|
459
|
+
def create_cell_matrix(ast_table)
|
460
460
|
ast_table.raw.map do |raw_row|
|
461
461
|
line = begin
|
462
462
|
raw_row.line
|
@@ -469,7 +469,7 @@ module Cucumber
|
|
469
469
|
end
|
470
470
|
end
|
471
471
|
|
472
|
-
def convert_columns!
|
472
|
+
def convert_columns!
|
473
473
|
@conversion_procs.each do |column_name, conversion_proc|
|
474
474
|
verify_column(column_name) if conversion_proc[:strict]
|
475
475
|
end
|
@@ -483,7 +483,7 @@ module Cucumber
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
def convert_headers!
|
486
|
+
def convert_headers!
|
487
487
|
header_cells = cell_matrix[0]
|
488
488
|
|
489
489
|
if @header_conversion_proc
|
@@ -501,11 +501,11 @@ module Cucumber
|
|
501
501
|
end
|
502
502
|
end
|
503
503
|
|
504
|
-
def clear_cache!
|
504
|
+
def clear_cache!
|
505
505
|
@hashes = @rows_hash = @column_names = @rows = @columns = nil
|
506
506
|
end
|
507
507
|
|
508
|
-
def ensure_table(table_or_array)
|
508
|
+
def ensure_table(table_or_array)
|
509
509
|
return table_or_array if table_or_array.instance_of?(DataTable)
|
510
510
|
|
511
511
|
DataTable.from(table_or_array)
|
@@ -516,7 +516,7 @@ module Cucumber
|
|
516
516
|
end
|
517
517
|
|
518
518
|
# Represents a row of cells or columns of cells
|
519
|
-
class Cells
|
519
|
+
class Cells
|
520
520
|
include Enumerable
|
521
521
|
include Cucumber::Gherkin::Formatter::Escaping
|
522
522
|
|
@@ -536,21 +536,20 @@ module Cucumber
|
|
536
536
|
nil
|
537
537
|
end
|
538
538
|
|
539
|
-
|
540
|
-
def to_sexp # :nodoc:
|
539
|
+
def to_sexp
|
541
540
|
[:row, line, *@cells.map(&:to_sexp)]
|
542
541
|
end
|
543
542
|
|
544
|
-
def to_hash
|
543
|
+
def to_hash
|
545
544
|
@to_hash ||= @table.cells_to_hash(self)
|
546
545
|
end
|
547
546
|
|
548
|
-
def value(
|
549
|
-
self[
|
547
|
+
def value(index)
|
548
|
+
self[index].value
|
550
549
|
end
|
551
550
|
|
552
|
-
def [](
|
553
|
-
@cells[
|
551
|
+
def [](index)
|
552
|
+
@cells[index]
|
554
553
|
end
|
555
554
|
|
556
555
|
def line
|
@@ -576,7 +575,7 @@ module Cucumber
|
|
576
575
|
end
|
577
576
|
end
|
578
577
|
|
579
|
-
class Cell
|
578
|
+
class Cell
|
580
579
|
attr_reader :line, :table
|
581
580
|
attr_accessor :status, :value
|
582
581
|
|
@@ -603,12 +602,12 @@ module Cucumber
|
|
603
602
|
end
|
604
603
|
|
605
604
|
# For testing only
|
606
|
-
def to_sexp
|
605
|
+
def to_sexp
|
607
606
|
[:cell, @value]
|
608
607
|
end
|
609
608
|
end
|
610
609
|
|
611
|
-
class SurplusCell < Cell
|
610
|
+
class SurplusCell < Cell
|
612
611
|
def status
|
613
612
|
:comment
|
614
613
|
end
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -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
|
|
@@ -5,14 +5,14 @@ require 'cucumber/ci_environment'
|
|
5
5
|
|
6
6
|
module Cucumber
|
7
7
|
class Runtime
|
8
|
-
# Builder to
|
8
|
+
# Builder to instantiate a Cucumber::Messages::Meta message filled-in with
|
9
9
|
# the runtime meta-data:
|
10
10
|
# - protocol version: the version of the Cucumber::Messages protocol
|
11
11
|
# - implementation: the name and version of the implementation (e.g. cucumber-ruby 8.0.0)
|
12
12
|
# - runtime: the name and version of the runtime (e.g. ruby 3.0.1)
|
13
13
|
# - os: the name and version of the operating system (e.g. linux 3.13.0-45-generic)
|
14
14
|
# - cpu: the name of the CPU (e.g. x86_64)
|
15
|
-
# - ci:
|
15
|
+
# - ci: information about the CI environment if any, including:
|
16
16
|
# - name: the name of the CI environment (e.g. Jenkins)
|
17
17
|
# - url: the URL of the CI environment (e.g. https://ci.example.com)
|
18
18
|
# - build_number: the build number of the CI environment (e.g. 123)
|
@@ -41,8 +41,8 @@ module Cucumber
|
|
41
41
|
# be a path to a file, or if it's an image it may also be a Base64 encoded image.
|
42
42
|
# The embedded data may or may not be ignored, depending on what kind of formatter(s) are active.
|
43
43
|
#
|
44
|
-
def attach(src, media_type)
|
45
|
-
@visitor.attach(src, media_type)
|
44
|
+
def attach(src, media_type, filename)
|
45
|
+
@visitor.attach(src, media_type, filename)
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
data/lib/cucumber/runtime.rb
CHANGED
@@ -235,7 +235,7 @@ module Cucumber
|
|
235
235
|
end
|
236
236
|
|
237
237
|
require 'cucumber/core/test/filters'
|
238
|
-
def filters
|
238
|
+
def filters
|
239
239
|
tag_expressions = @configuration.tag_expressions
|
240
240
|
name_regexps = @configuration.name_regexps
|
241
241
|
tag_limits = @configuration.tag_limits
|