cucumber 4.1.0 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +134 -21
- data/VERSION +1 -0
- data/lib/cucumber/cli/configuration.rb +27 -2
- data/lib/cucumber/cli/main.rb +5 -4
- data/lib/cucumber/cli/options.rb +102 -65
- data/lib/cucumber/cli/profile_loader.rb +6 -10
- data/lib/cucumber/cli/rerun_file.rb +1 -1
- data/lib/cucumber/configuration.rb +26 -13
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/deprecate.rb +6 -46
- data/lib/cucumber/errors.rb +4 -3
- 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 +2 -2
- 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 -85
- data/lib/cucumber/formatter/ast_lookup.rb +16 -10
- data/lib/cucumber/formatter/backtrace_filter.rb +3 -1
- data/lib/cucumber/formatter/console.rb +34 -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 +3 -1
- data/lib/cucumber/formatter/http_io.rb +10 -136
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
- data/lib/cucumber/formatter/interceptor.rb +4 -3
- data/lib/cucumber/formatter/io.rb +50 -12
- data/lib/cucumber/formatter/io_http_buffer.rb +88 -0
- data/lib/cucumber/formatter/json.rb +36 -37
- data/lib/cucumber/formatter/junit.rb +29 -9
- data/lib/cucumber/formatter/message.rb +3 -2
- data/lib/cucumber/formatter/message_builder.rb +32 -16
- data/lib/cucumber/formatter/pretty.rb +44 -29
- data/lib/cucumber/formatter/progress.rb +2 -1
- data/lib/cucumber/formatter/publish_banner_printer.rb +75 -0
- 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 +7 -5
- data/lib/cucumber/formatter/steps.rb +6 -3
- data/lib/cucumber/formatter/summary.rb +2 -1
- data/lib/cucumber/formatter/unicode.rb +7 -7
- data/lib/cucumber/formatter/url_reporter.rb +19 -0
- data/lib/cucumber/formatter/usage.rb +9 -7
- data/lib/cucumber/gherkin/data_table_parser.rb +2 -1
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +25 -27
- data/lib/cucumber/gherkin/steps_parser.rb +1 -1
- data/lib/cucumber/glue/dsl.rb +30 -16
- 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 +37 -57
- data/lib/cucumber/glue/registry_and_more.rb +31 -12
- data/lib/cucumber/glue/registry_wrapper.rb +31 -0
- data/lib/cucumber/glue/snippet.rb +4 -2
- data/lib/cucumber/glue/step_definition.rb +9 -7
- 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 +5 -2
- data/lib/cucumber/multiline_argument/data_table.rb +65 -79
- data/lib/cucumber/platform.rb +11 -16
- data/lib/cucumber/rake/task.rb +22 -17
- data/lib/cucumber/rspec/disable_option_parser.rb +6 -3
- data/lib/cucumber/rspec/doubles.rb +3 -5
- 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 +50 -24
- data/lib/cucumber/step_match.rb +7 -11
- data/lib/cucumber/step_match_search.rb +3 -2
- data/lib/cucumber/term/ansicolor.rb +74 -50
- data/lib/cucumber/term/banner.rb +59 -0
- data/lib/cucumber.rb +2 -1
- data/lib/simplecov_setup.rb +1 -1
- metadata +103 -229
- data/CHANGELOG.md +0 -2682
- data/CONTRIBUTING.md +0 -71
- data/lib/autotest/cucumber.rb +0 -8
- data/lib/autotest/cucumber_mixin.rb +0 -132
- 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/core_ext/string.rb +0 -11
- data/lib/cucumber/version +0 -1
@@ -2,8 +2,28 @@
|
|
2
2
|
|
3
3
|
module Cucumber
|
4
4
|
module Term
|
5
|
-
#
|
6
|
-
#
|
5
|
+
# This module allows to colorize text using ANSI escape sequences.
|
6
|
+
#
|
7
|
+
# Include the module in your class and use its methods to colorize text.
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
#
|
11
|
+
# require 'cucumber/term/ansicolor'
|
12
|
+
#
|
13
|
+
# class MyFormatter
|
14
|
+
# include Cucumber::Term::ANSIColor
|
15
|
+
#
|
16
|
+
# def initialize(config)
|
17
|
+
# $stdout.puts yellow("Initializing formatter")
|
18
|
+
# $stdout.puts green("Coloring is active \o/") if Cucumber::Term::ANSIColor.coloring?
|
19
|
+
# $stdout.puts grey("Feature path:") + blue(bold(config.feature_dirs))
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# To see what colours and effects are available, just run this in your shell:
|
24
|
+
#
|
25
|
+
# ruby -e "require 'rubygems'; require 'cucumber/term/ansicolor'; puts Cucumber::Term::ANSIColor.attributes"
|
26
|
+
#
|
7
27
|
module ANSIColor
|
8
28
|
# :stopdoc:
|
9
29
|
ATTRIBUTES = [
|
@@ -27,6 +47,7 @@ module Cucumber
|
|
27
47
|
[:magenta, 35],
|
28
48
|
[:cyan, 36],
|
29
49
|
[:white, 37],
|
50
|
+
[:grey, 90],
|
30
51
|
[:on_black, 40],
|
31
52
|
[:on_red, 41],
|
32
53
|
[:on_green, 42],
|
@@ -40,72 +61,75 @@ module Cucumber
|
|
40
61
|
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
41
62
|
# :startdoc:
|
42
63
|
|
43
|
-
#
|
44
|
-
#
|
45
|
-
|
46
|
-
@coloring
|
47
|
-
end
|
64
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
65
|
+
# uncoloring strings.
|
66
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/.freeze
|
48
67
|
|
49
|
-
|
50
|
-
# this for example:
|
51
|
-
# Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
|
52
|
-
def self.coloring=(val)
|
53
|
-
@coloring = val
|
54
|
-
end
|
55
|
-
self.coloring = true
|
68
|
+
@coloring = true
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
result << "\e[#{v}m" if Cucumber::Term::ANSIColor.coloring?
|
63
|
-
if block_given?
|
64
|
-
result << yield
|
65
|
-
elsif string
|
66
|
-
result << string
|
67
|
-
elsif respond_to?(:to_str)
|
68
|
-
result << to_str
|
69
|
-
else
|
70
|
-
return result #only switch on
|
71
|
-
end
|
72
|
-
result << "\e[0m" if Cucumber::Term::ANSIColor.coloring?
|
73
|
-
result
|
74
|
-
end
|
75
|
-
END_EVAL
|
76
|
-
end
|
77
|
-
# rubocop:enable Security/Eval
|
70
|
+
class << self
|
71
|
+
# Turns the coloring on or off globally, so you can easily do
|
72
|
+
# this for example:
|
73
|
+
# Cucumber::Term::ANSIColor::coloring = $stdout.isatty
|
74
|
+
attr_accessor :coloring
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
# Returns true, if the coloring function of this module
|
77
|
+
# is switched on, false otherwise.
|
78
|
+
alias coloring? :coloring
|
79
|
+
|
80
|
+
def included(klass)
|
81
|
+
return unless klass == String
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
ATTRIBUTE_NAMES.delete(:clear)
|
83
|
+
ATTRIBUTES.delete(:clear)
|
84
|
+
ATTRIBUTE_NAMES.delete(:clear)
|
85
|
+
end
|
87
86
|
end
|
88
87
|
|
89
|
-
|
88
|
+
ATTRIBUTES.each do |color_name, color_code|
|
89
|
+
define_method(color_name) do |text = nil, &block|
|
90
|
+
if block
|
91
|
+
colorize(block.call, color_code)
|
92
|
+
elsif text
|
93
|
+
colorize(text, color_code)
|
94
|
+
elsif respond_to?(:to_str)
|
95
|
+
colorize(to_str, color_code)
|
96
|
+
else
|
97
|
+
colorize(nil, color_code) # switch coloration on
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns an uncolored version of the string
|
90
103
|
# ANSI-sequences are stripped from the string.
|
91
|
-
def uncolored(
|
104
|
+
def uncolored(text = nil)
|
92
105
|
if block_given?
|
93
|
-
yield
|
94
|
-
elsif
|
95
|
-
|
106
|
+
uncolorize(yield)
|
107
|
+
elsif text
|
108
|
+
uncolorize(text)
|
96
109
|
elsif respond_to?(:to_str)
|
97
|
-
to_str
|
110
|
+
uncolorize(to_str)
|
98
111
|
else
|
99
112
|
''
|
100
113
|
end
|
101
114
|
end
|
102
115
|
|
103
|
-
module_function
|
104
|
-
|
105
116
|
# Returns an array of all Cucumber::Term::ANSIColor attributes as symbols.
|
106
117
|
def attributes
|
107
118
|
ATTRIBUTE_NAMES
|
108
119
|
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def colorize(text, color_code)
|
124
|
+
return String.new(text || '') unless Cucumber::Term::ANSIColor.coloring?
|
125
|
+
return "\e[#{color_code}m" unless text
|
126
|
+
|
127
|
+
"\e[#{color_code}m#{text}\e[0m"
|
128
|
+
end
|
129
|
+
|
130
|
+
def uncolorize(string)
|
131
|
+
string.gsub(COLORED_REGEXP, '')
|
132
|
+
end
|
109
133
|
end
|
110
134
|
end
|
111
135
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cucumber/term/ansicolor'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Term
|
7
|
+
module Banner
|
8
|
+
def display_banner(lines, io, border_modifiers = nil)
|
9
|
+
BannerMaker.new.display_banner(lines, io, border_modifiers || %i[green bold])
|
10
|
+
end
|
11
|
+
|
12
|
+
class BannerMaker
|
13
|
+
include Term::ANSIColor
|
14
|
+
|
15
|
+
def display_banner(lines, io, border_modifiers)
|
16
|
+
lines = lines.split("\n") if lines.is_a? String
|
17
|
+
longest_line_length = lines.map { |line| line_length(line) }.max
|
18
|
+
|
19
|
+
io.puts apply_modifiers("┌#{'─' * (longest_line_length + 2)}┐", border_modifiers)
|
20
|
+
lines.map do |line|
|
21
|
+
padding = ' ' * (longest_line_length - line_length(line))
|
22
|
+
io.puts "#{apply_modifiers('│', border_modifiers)} #{display_line(line)}#{padding} #{apply_modifiers('│', border_modifiers)}"
|
23
|
+
end
|
24
|
+
io.puts apply_modifiers("└#{'─' * (longest_line_length + 2)}┘", border_modifiers)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def display_line(line)
|
30
|
+
line.is_a?(Array) ? line.map { |span| display_span(span) }.join : line
|
31
|
+
end
|
32
|
+
|
33
|
+
def display_span(span)
|
34
|
+
return apply_modifiers(span.shift, span) if span.is_a?(Array)
|
35
|
+
|
36
|
+
span
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply_modifiers(str, modifiers)
|
40
|
+
display = str
|
41
|
+
modifiers.each { |modifier| display = send(modifier, display) }
|
42
|
+
display
|
43
|
+
end
|
44
|
+
|
45
|
+
def line_length(line)
|
46
|
+
if line.is_a?(Array)
|
47
|
+
line.map { |span| span_length(span) }.sum
|
48
|
+
else
|
49
|
+
line.length
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def span_length(span)
|
54
|
+
span.is_a?(Array) ? span[0].length : span.length
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/cucumber.rb
CHANGED
data/lib/simplecov_setup.rb
CHANGED
@@ -7,7 +7,7 @@ if ENV['SIMPLECOV']
|
|
7
7
|
|
8
8
|
require 'simplecov'
|
9
9
|
|
10
|
-
SimpleCov.root(File.expand_path(File.dirname(__FILE__)
|
10
|
+
SimpleCov.root(File.expand_path("#{File.dirname(__FILE__)}/.."))
|
11
11
|
SimpleCov.start do
|
12
12
|
add_filter 'iso-8859-1_steps.rb'
|
13
13
|
add_filter '.-ruby-core/'
|