cucumber 3.0.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +216 -17
- data/CONTRIBUTING.md +4 -21
- data/README.md +8 -10
- data/bin/cucumber +1 -1
- data/lib/autotest/cucumber.rb +1 -0
- data/lib/autotest/cucumber_mixin.rb +35 -39
- data/lib/autotest/cucumber_rails.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
- data/lib/autotest/cucumber_rspec.rb +1 -0
- data/lib/autotest/cucumber_rspec2.rb +1 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/cucumber.rb +2 -1
- data/lib/cucumber/cli/configuration.rb +6 -5
- data/lib/cucumber/cli/main.rb +14 -14
- data/lib/cucumber/cli/options.rb +113 -116
- data/lib/cucumber/cli/profile_loader.rb +50 -29
- data/lib/cucumber/cli/rerun_file.rb +1 -0
- data/lib/cucumber/configuration.rb +38 -29
- data/lib/cucumber/constantize.rb +8 -10
- data/lib/cucumber/core_ext/string.rb +1 -0
- data/lib/cucumber/deprecate.rb +32 -8
- data/lib/cucumber/encoding.rb +2 -1
- data/lib/cucumber/errors.rb +6 -7
- data/lib/cucumber/events.rb +14 -7
- data/lib/cucumber/events/envelope.rb +9 -0
- data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
- data/lib/cucumber/events/gherkin_source_read.rb +1 -4
- data/lib/cucumber/events/hook_test_step_created.rb +13 -0
- data/lib/cucumber/events/step_activated.rb +6 -6
- data/lib/cucumber/events/step_definition_registered.rb +4 -8
- data/lib/cucumber/events/test_case_created.rb +13 -0
- data/lib/cucumber/events/test_case_finished.rb +0 -4
- data/lib/cucumber/events/test_case_ready.rb +12 -0
- data/lib/cucumber/events/test_case_started.rb +0 -4
- data/lib/cucumber/events/test_run_finished.rb +2 -3
- data/lib/cucumber/events/test_run_started.rb +2 -4
- data/lib/cucumber/events/test_step_created.rb +13 -0
- data/lib/cucumber/events/test_step_finished.rb +0 -4
- data/lib/cucumber/events/test_step_started.rb +1 -5
- data/lib/cucumber/events/undefined_parameter_type.rb +10 -0
- data/lib/cucumber/file_specs.rb +7 -6
- data/lib/cucumber/filters.rb +2 -0
- data/lib/cucumber/filters/activate_steps.rb +6 -4
- data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
- data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
- data/lib/cucumber/filters/broadcast_test_run_started_event.rb +2 -1
- data/lib/cucumber/filters/gated_receiver.rb +1 -2
- data/lib/cucumber/filters/prepare_world.rb +6 -13
- data/lib/cucumber/filters/quit.rb +3 -6
- data/lib/cucumber/filters/randomizer.rb +6 -7
- data/lib/cucumber/filters/retry.rb +2 -2
- data/lib/cucumber/filters/tag_limits.rb +2 -2
- data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -2
- data/lib/cucumber/filters/tag_limits/verifier.rb +3 -6
- data/lib/cucumber/formatter/ansicolor.rb +33 -37
- data/lib/cucumber/formatter/ast_lookup.rb +165 -0
- data/lib/cucumber/formatter/backtrace_filter.rb +10 -10
- data/lib/cucumber/formatter/console.rb +65 -74
- data/lib/cucumber/formatter/console_counts.rb +4 -9
- data/lib/cucumber/formatter/console_issues.rb +9 -6
- data/lib/cucumber/formatter/duration.rb +2 -1
- data/lib/cucumber/formatter/duration_extractor.rb +4 -2
- data/lib/cucumber/formatter/errors.rb +6 -0
- data/lib/cucumber/formatter/fail_fast.rb +9 -6
- data/lib/cucumber/formatter/fanout.rb +3 -3
- data/lib/cucumber/formatter/html.rb +11 -602
- data/lib/cucumber/formatter/http_io.rb +146 -0
- data/lib/cucumber/formatter/ignore_missing_messages.rb +2 -3
- data/lib/cucumber/formatter/interceptor.rb +11 -18
- data/lib/cucumber/formatter/io.rb +18 -11
- data/lib/cucumber/formatter/json.rb +102 -109
- data/lib/cucumber/formatter/junit.rb +73 -68
- data/lib/cucumber/formatter/message.rb +22 -0
- data/lib/cucumber/formatter/message_builder.rb +255 -0
- data/lib/cucumber/formatter/pretty.rb +360 -153
- data/lib/cucumber/formatter/progress.rb +31 -32
- data/lib/cucumber/formatter/query/hook_by_test_step.rb +31 -0
- data/lib/cucumber/formatter/query/pickle_by_test.rb +26 -0
- data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +26 -0
- data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +40 -0
- data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +40 -0
- data/lib/cucumber/formatter/rerun.rb +23 -4
- data/lib/cucumber/formatter/stepdefs.rb +2 -2
- data/lib/cucumber/formatter/steps.rb +4 -5
- data/lib/cucumber/formatter/summary.rb +17 -9
- data/lib/cucumber/formatter/unicode.rb +16 -18
- data/lib/cucumber/formatter/usage.rb +30 -26
- data/lib/cucumber/gherkin/data_table_parser.rb +18 -6
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +83 -86
- data/lib/cucumber/gherkin/formatter/escaping.rb +13 -12
- data/lib/cucumber/gherkin/i18n.rb +1 -0
- data/lib/cucumber/gherkin/steps_parser.rb +18 -8
- data/lib/cucumber/glue/dsl.rb +2 -1
- data/lib/cucumber/glue/hook.rb +35 -11
- data/lib/cucumber/glue/invoke_in_world.rb +15 -20
- data/lib/cucumber/glue/proto_world.rb +47 -39
- data/lib/cucumber/glue/registry_and_more.rb +54 -23
- data/lib/cucumber/glue/snippet.rb +24 -27
- data/lib/cucumber/glue/step_definition.rb +51 -28
- data/lib/cucumber/glue/world_factory.rb +1 -3
- data/lib/cucumber/hooks.rb +24 -14
- data/lib/cucumber/load_path.rb +1 -0
- data/lib/cucumber/multiline_argument.rb +6 -8
- data/lib/cucumber/multiline_argument/data_table.rb +106 -73
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +8 -11
- data/lib/cucumber/multiline_argument/doc_string.rb +2 -1
- data/lib/cucumber/platform.rb +4 -3
- data/lib/cucumber/project_initializer.rb +1 -1
- data/lib/cucumber/rake/task.rb +21 -18
- data/lib/cucumber/rspec/disable_option_parser.rb +10 -8
- data/lib/cucumber/rspec/doubles.rb +1 -0
- data/lib/cucumber/running_test_case.rb +4 -54
- data/lib/cucumber/runtime.rb +57 -61
- data/lib/cucumber/runtime/after_hooks.rb +9 -4
- data/lib/cucumber/runtime/before_hooks.rb +9 -4
- data/lib/cucumber/runtime/for_programming_languages.rb +12 -9
- data/lib/cucumber/runtime/step_hooks.rb +5 -2
- data/lib/cucumber/runtime/support_code.rb +16 -22
- data/lib/cucumber/runtime/user_interface.rb +8 -19
- data/lib/cucumber/step_definition_light.rb +6 -4
- data/lib/cucumber/step_definitions.rb +3 -2
- data/lib/cucumber/step_match.rb +20 -18
- data/lib/cucumber/step_match_search.rb +9 -9
- data/lib/cucumber/term/ansicolor.rb +39 -39
- data/lib/cucumber/unit.rb +1 -0
- data/lib/cucumber/version +1 -1
- data/lib/simplecov_setup.rb +1 -0
- metadata +214 -127
- data/lib/cucumber/formatter/cucumber.css +0 -286
- data/lib/cucumber/formatter/cucumber.sass +0 -247
- data/lib/cucumber/formatter/hook_query_visitor.rb +0 -41
- data/lib/cucumber/formatter/html_builder.rb +0 -120
- data/lib/cucumber/formatter/inline-js.js +0 -30
- data/lib/cucumber/formatter/jquery-min.js +0 -154
- data/lib/cucumber/formatter/json_pretty.rb +0 -10
- data/lib/cucumber/formatter/legacy_api/adapter.rb +0 -1028
- data/lib/cucumber/formatter/legacy_api/ast.rb +0 -394
- data/lib/cucumber/formatter/legacy_api/results.rb +0 -50
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +0 -32
- data/lib/cucumber/step_argument.rb +0 -24
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Require this file if you need Unicode support.
|
3
4
|
# Tips for improvement - esp. ruby 1.9: http://www.ruby-forum.com/topic/184730
|
4
5
|
require 'cucumber/platform'
|
@@ -8,40 +9,37 @@ if Cucumber::WINDOWS
|
|
8
9
|
if ENV['CUCUMBER_OUTPUT_ENCODING']
|
9
10
|
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
|
10
11
|
elsif `cmd /c chcp` =~ /(\d+)/
|
11
|
-
if [
|
12
|
-
Cucumber::CODEPAGE = 'UTF-8'
|
12
|
+
if [65_000, 65_001].include? Regexp.last_match(1).to_i
|
13
|
+
Cucumber::CODEPAGE = 'UTF-8'.freeze
|
13
14
|
ENV['ANSICON_API'] = 'ruby'
|
14
15
|
else
|
15
|
-
Cucumber::CODEPAGE = "cp#{
|
16
|
+
Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}".freeze
|
16
17
|
end
|
17
18
|
else
|
18
|
-
Cucumber::CODEPAGE = 'cp1252'
|
19
|
+
Cucumber::CODEPAGE = 'cp1252'.freeze
|
19
20
|
STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
|
20
21
|
end
|
21
22
|
|
22
23
|
module Cucumber
|
23
24
|
# @private
|
24
25
|
module WindowsOutput
|
25
|
-
def self.extended(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
STDERR.cucumber_puts("WARNING: #{e.message}")
|
33
|
-
a
|
34
|
-
end
|
26
|
+
def self.extended(output)
|
27
|
+
output.instance_eval do
|
28
|
+
def cucumber_preprocess_output(*out)
|
29
|
+
out.map { |arg| arg.to_s.encode(Encoding.default_external) }
|
30
|
+
rescue Encoding::UndefinedConversionError => e
|
31
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
32
|
+
out
|
35
33
|
end
|
36
34
|
|
37
35
|
alias cucumber_print print
|
38
|
-
def print(*
|
39
|
-
cucumber_print(*cucumber_preprocess_output(*
|
36
|
+
def print(*out)
|
37
|
+
cucumber_print(*cucumber_preprocess_output(*out))
|
40
38
|
end
|
41
39
|
|
42
40
|
alias cucumber_puts puts
|
43
|
-
def puts(*
|
44
|
-
cucumber_puts(*cucumber_preprocess_output(*
|
41
|
+
def puts(*out)
|
42
|
+
cucumber_puts(*cucumber_preprocess_output(*out))
|
45
43
|
end
|
46
44
|
end
|
47
45
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/formatter/progress'
|
3
4
|
require 'cucumber/step_definition_light'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module Formatter
|
7
8
|
class Usage < Progress
|
8
|
-
|
9
9
|
class StepDefKey < StepDefinitionLight
|
10
10
|
attr_accessor :mean_duration, :status
|
11
11
|
end
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
@matches = {}
|
18
18
|
config.on_event :step_activated do |event|
|
19
19
|
test_step, step_match = *event.attributes
|
20
|
-
@matches[test_step.
|
20
|
+
@matches[test_step.to_s] = step_match
|
21
21
|
end
|
22
22
|
config.on_event :step_definition_registered, &method(:on_step_definition_registered)
|
23
23
|
end
|
@@ -28,29 +28,34 @@ module Cucumber
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def on_step_match(event)
|
31
|
-
@matches[event.test_step.
|
31
|
+
@matches[event.test_step.to_s] = event.step_match
|
32
32
|
super
|
33
33
|
end
|
34
34
|
|
35
35
|
def on_test_step_finished(event)
|
36
|
-
return if
|
36
|
+
return if event.test_step.hook?
|
37
37
|
|
38
38
|
test_step = event.test_step
|
39
39
|
result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
40
|
-
step_match = @matches[test_step.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
keyword
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
step_match = @matches[test_step.to_s]
|
41
|
+
|
42
|
+
unless step_match.nil?
|
43
|
+
step_definition = step_match.step_definition
|
44
|
+
stepdef_key = StepDefKey.new(step_definition.expression.to_s, step_definition.location)
|
45
|
+
unless @stepdef_to_match[stepdef_key].map { |key| key[:location] }.include? test_step.location
|
46
|
+
duration = DurationExtractor.new(result).result_duration
|
47
|
+
keyword = @ast_lookup.step_source(test_step).step.keyword
|
48
|
+
|
49
|
+
@stepdef_to_match[stepdef_key] << {
|
50
|
+
keyword: keyword,
|
51
|
+
step_match: step_match,
|
52
|
+
status: result.to_sym,
|
53
|
+
location: test_step.location,
|
54
|
+
duration: duration
|
55
|
+
}
|
56
|
+
end
|
53
57
|
end
|
58
|
+
|
54
59
|
super
|
55
60
|
end
|
56
61
|
|
@@ -60,9 +65,9 @@ module Cucumber
|
|
60
65
|
aggregate_info
|
61
66
|
|
62
67
|
keys = if config.dry_run?
|
63
|
-
@stepdef_to_match.keys.
|
68
|
+
@stepdef_to_match.keys.sort_by(&:regexp_source)
|
64
69
|
else
|
65
|
-
@stepdef_to_match.keys.
|
70
|
+
@stepdef_to_match.keys.sort_by(&:mean_duration).reverse
|
66
71
|
end
|
67
72
|
|
68
73
|
keys.each do |stepdef_key|
|
@@ -79,7 +84,7 @@ module Cucumber
|
|
79
84
|
end
|
80
85
|
|
81
86
|
def print_step_definition(stepdef_key)
|
82
|
-
@io.print format_string(format('
|
87
|
+
@io.print format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run?
|
83
88
|
@io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
|
84
89
|
if config.source?
|
85
90
|
indent = max_length - stepdef_key.regexp_source.unpack('U*').length
|
@@ -92,7 +97,7 @@ module Cucumber
|
|
92
97
|
def print_steps(stepdef_key)
|
93
98
|
@stepdef_to_match[stepdef_key].each do |step|
|
94
99
|
@io.print ' '
|
95
|
-
@io.print format_string(format('
|
100
|
+
@io.print format_string(format('%<duration>.7f', duration: step[:duration]), :skipped) + ' ' unless config.dry_run?
|
96
101
|
@io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
|
97
102
|
if config.source?
|
98
103
|
indent = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
|
@@ -108,7 +113,7 @@ module Cucumber
|
|
108
113
|
end
|
109
114
|
|
110
115
|
def max_stepdef_length
|
111
|
-
@stepdef_to_match.keys.flatten.map{|key| key.regexp_source.unpack('U*').length}.max
|
116
|
+
@stepdef_to_match.keys.flatten.map { |key| key.regexp_source.unpack('U*').length }.max
|
112
117
|
end
|
113
118
|
|
114
119
|
def max_step_length
|
@@ -123,19 +128,18 @@ module Cucumber
|
|
123
128
|
key.status = :skipped
|
124
129
|
key.mean_duration = 0
|
125
130
|
else
|
126
|
-
key.status = worst_status(steps.map{ |step| step[:status] })
|
127
|
-
total_duration = steps.inject(0) {|sum, step| step[:duration] + sum}
|
131
|
+
key.status = worst_status(steps.map { |step| step[:status] })
|
132
|
+
total_duration = steps.inject(0) { |sum, step| step[:duration] + sum }
|
128
133
|
key.mean_duration = total_duration / steps.length
|
129
134
|
end
|
130
135
|
end
|
131
136
|
end
|
132
137
|
|
133
138
|
def worst_status(statuses)
|
134
|
-
[
|
139
|
+
%i[passed undefined pending skipped failed].find do |status|
|
135
140
|
statuses.include?(status)
|
136
141
|
end
|
137
142
|
end
|
138
|
-
|
139
143
|
end
|
140
144
|
end
|
141
145
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'gherkin
|
2
|
+
|
3
|
+
require 'gherkin'
|
4
4
|
require 'gherkin/dialect'
|
5
5
|
|
6
6
|
module Cucumber
|
@@ -11,15 +11,27 @@ module Cucumber
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def parse(text)
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
gherkin_document = nil
|
15
|
+
messages = ::Gherkin.from_source('dummy', feature_header + text, gherkin_options)
|
16
|
+
|
17
|
+
messages.each do |message|
|
18
|
+
gherkin_document = message.gherkin_document.to_hash unless message.gherkin_document.nil?
|
19
|
+
end
|
17
20
|
|
18
|
-
gherkin_document
|
21
|
+
return if gherkin_document.nil?
|
22
|
+
gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row|
|
19
23
|
@builder.row(row[:cells].map { |cell| cell[:value] })
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
27
|
+
def gherkin_options
|
28
|
+
{
|
29
|
+
include_source: false,
|
30
|
+
include_gherkin_document: true,
|
31
|
+
include_pickles: false
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
23
35
|
def feature_header
|
24
36
|
dialect = ::Gherkin::Dialect.for('en')
|
25
37
|
%(#{dialect.feature_keywords[0]}:
|
@@ -1,100 +1,97 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Cucumber
|
3
|
-
module Gherkin
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
4
|
+
module Gherkin
|
5
|
+
module Formatter
|
6
|
+
# Defines aliases for ANSI coloured output. Default colours can be overridden by defining
|
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
|
10
|
+
#
|
11
|
+
# The colours that you can change are:
|
12
|
+
#
|
13
|
+
# <tt>undefined</tt>:: defaults to <tt>yellow</tt>
|
14
|
+
# <tt>pending</tt>:: defaults to <tt>yellow</tt>
|
15
|
+
# <tt>pending_arg</tt>:: defaults to <tt>yellow,bold</tt>
|
16
|
+
# <tt>executing</tt>:: defaults to <tt>grey</tt>
|
17
|
+
# <tt>executing_arg</tt>:: defaults to <tt>grey,bold</tt>
|
18
|
+
# <tt>failed</tt>:: defaults to <tt>red</tt>
|
19
|
+
# <tt>failed_arg</tt>:: defaults to <tt>red,bold</tt>
|
20
|
+
# <tt>passed</tt>:: defaults to <tt>green</tt>
|
21
|
+
# <tt>passed_arg</tt>:: defaults to <tt>green,bold</tt>
|
22
|
+
# <tt>outline</tt>:: defaults to <tt>cyan</tt>
|
23
|
+
# <tt>outline_arg</tt>:: defaults to <tt>cyan,bold</tt>
|
24
|
+
# <tt>skipped</tt>:: defaults to <tt>cyan</tt>
|
25
|
+
# <tt>skipped_arg</tt>:: defaults to <tt>cyan,bold</tt>
|
26
|
+
# <tt>comment</tt>:: defaults to <tt>grey</tt>
|
27
|
+
# <tt>tag</tt>:: defaults to <tt>cyan</tt>
|
28
|
+
#
|
29
|
+
# For instance, if your shell has a black background and a green font (like the
|
30
|
+
# "Homebrew" settings for OS X' Terminal.app), you may want to override passed
|
31
|
+
# steps to be white instead of green. Examples:
|
32
|
+
#
|
33
|
+
# export GHERKIN_COLORS="passed=white"
|
34
|
+
# export GHERKIN_COLORS="passed=white,bold:passed_arg=white,bold,underline"
|
35
|
+
#
|
36
|
+
# (If you're on Windows, use SET instead of export).
|
37
|
+
# To see what colours and effects are available, just run this in your shell:
|
38
|
+
#
|
39
|
+
# ruby -e "require 'rubygems'; require 'term/ansicolor'; puts Term::ANSIColor.attributes"
|
40
|
+
#
|
41
|
+
# Although not listed, you can also use <tt>grey</tt>
|
42
|
+
module AnsiEscapes
|
43
|
+
COLORS = {
|
44
|
+
'black' => "\e[30m",
|
45
|
+
'red' => "\e[31m",
|
46
|
+
'green' => "\e[32m",
|
47
|
+
'yellow' => "\e[33m",
|
48
|
+
'blue' => "\e[34m",
|
49
|
+
'magenta' => "\e[35m",
|
50
|
+
'cyan' => "\e[36m",
|
51
|
+
'white' => "\e[37m",
|
52
|
+
'grey' => "\e[90m",
|
53
|
+
'bold' => "\e[1m"
|
54
|
+
}.freeze
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
'tag' => 'cyan'
|
69
|
-
})
|
56
|
+
ALIASES = Hash.new do |h, k|
|
57
|
+
h[Regexp.last_match(1)] + ',bold' if k.to_s =~ /(.*)_arg/
|
58
|
+
end.merge(
|
59
|
+
'undefined' => 'yellow',
|
60
|
+
'pending' => 'yellow',
|
61
|
+
'executing' => 'grey',
|
62
|
+
'failed' => 'red',
|
63
|
+
'passed' => 'green',
|
64
|
+
'outline' => 'cyan',
|
65
|
+
'skipped' => 'cyan',
|
66
|
+
'comments' => 'grey',
|
67
|
+
'tag' => 'cyan'
|
68
|
+
)
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
if ENV['GHERKIN_COLORS'] # Example: export GHERKIN_COLORS="passed=red:failed=yellow"
|
71
|
+
ENV['GHERKIN_COLORS'].split(':').each do |pair|
|
72
|
+
a = pair.split('=')
|
73
|
+
ALIASES[a[0]] = a[1]
|
74
|
+
end
|
75
75
|
end
|
76
|
-
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
ALIASES.keys.each do |key|
|
78
|
+
define_method(key) do
|
79
|
+
ALIASES[key].split(',').map { |color| COLORS[color] }.join('')
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
define_method("#{key}_arg") do
|
83
|
+
ALIASES["#{key}_arg"].split(',').map { |color| COLORS[color] }.join('')
|
84
|
+
end
|
85
85
|
end
|
86
|
-
end
|
87
86
|
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
def reset
|
88
|
+
"\e[0m"
|
89
|
+
end
|
91
90
|
|
92
|
-
|
93
|
-
|
91
|
+
def up(n)
|
92
|
+
"\e[#{n}A"
|
93
|
+
end
|
94
94
|
end
|
95
|
-
|
96
|
-
extend self
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
100
|
-
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Cucumber
|
3
|
-
module Gherkin
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
module Gherkin
|
5
|
+
module Formatter
|
6
|
+
module Escaping
|
7
|
+
# Escapes a pipes and backslashes:
|
8
|
+
#
|
9
|
+
# * | becomes \|
|
10
|
+
# * \ becomes \\
|
11
|
+
#
|
12
|
+
# This is used in the pretty formatter.
|
13
|
+
def escape_cell(sym)
|
14
|
+
sym.gsub(/\\(?!\|)/, '\\\\\\\\').gsub(/\n/, '\\n').gsub(/\|/, '\\|')
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
18
|
-
end
|