cucumber 3.2.0 → 4.1.0
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/CHANGELOG.md +192 -19
- data/CONTRIBUTING.md +2 -18
- data/README.md +4 -5
- data/bin/cucumber +1 -1
- data/lib/autotest/cucumber_mixin.rb +34 -39
- data/lib/cucumber/cli/configuration.rb +5 -5
- data/lib/cucumber/cli/main.rb +12 -12
- data/lib/cucumber/cli/options.rb +62 -71
- data/lib/cucumber/cli/profile_loader.rb +49 -26
- data/lib/cucumber/configuration.rb +31 -23
- data/lib/cucumber/constantize.rb +2 -5
- data/lib/cucumber/deprecate.rb +31 -7
- data/lib/cucumber/errors.rb +5 -7
- data/lib/cucumber/events/envelope.rb +9 -0
- data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
- data/lib/cucumber/events/hook_test_step_created.rb +13 -0
- data/lib/cucumber/events/step_activated.rb +2 -1
- data/lib/cucumber/events/test_case_created.rb +13 -0
- data/lib/cucumber/events/test_case_ready.rb +12 -0
- data/lib/cucumber/events/test_step_created.rb +13 -0
- data/lib/cucumber/events/undefined_parameter_type.rb +10 -0
- data/lib/cucumber/events.rb +13 -6
- data/lib/cucumber/file_specs.rb +6 -6
- data/lib/cucumber/filters/activate_steps.rb +5 -3
- data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
- data/lib/cucumber/filters/prepare_world.rb +5 -9
- data/lib/cucumber/filters/quit.rb +1 -3
- data/lib/cucumber/filters/tag_limits/verifier.rb +2 -4
- data/lib/cucumber/filters.rb +1 -0
- data/lib/cucumber/formatter/ansicolor.rb +40 -45
- data/lib/cucumber/formatter/ast_lookup.rb +165 -0
- data/lib/cucumber/formatter/backtrace_filter.rb +9 -8
- data/lib/cucumber/formatter/console.rb +58 -66
- data/lib/cucumber/formatter/console_counts.rb +4 -9
- data/lib/cucumber/formatter/console_issues.rb +6 -3
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/duration_extractor.rb +3 -1
- data/lib/cucumber/formatter/errors.rb +6 -0
- data/lib/cucumber/formatter/fanout.rb +2 -0
- data/lib/cucumber/formatter/html.rb +11 -598
- data/lib/cucumber/formatter/http_io.rb +1 -1
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
- data/lib/cucumber/formatter/interceptor.rb +8 -28
- data/lib/cucumber/formatter/io.rb +1 -1
- data/lib/cucumber/formatter/json.rb +101 -115
- data/lib/cucumber/formatter/junit.rb +56 -56
- data/lib/cucumber/formatter/message.rb +22 -0
- data/lib/cucumber/formatter/message_builder.rb +255 -0
- data/lib/cucumber/formatter/pretty.rb +359 -153
- data/lib/cucumber/formatter/progress.rb +30 -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 +22 -4
- data/lib/cucumber/formatter/stepdefs.rb +1 -2
- data/lib/cucumber/formatter/steps.rb +2 -3
- data/lib/cucumber/formatter/summary.rb +16 -8
- data/lib/cucumber/formatter/unicode.rb +15 -17
- data/lib/cucumber/formatter/usage.rb +11 -10
- data/lib/cucumber/gherkin/data_table_parser.rb +17 -6
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +13 -17
- data/lib/cucumber/gherkin/formatter/escaping.rb +2 -2
- data/lib/cucumber/gherkin/steps_parser.rb +17 -8
- data/lib/cucumber/glue/dsl.rb +1 -1
- data/lib/cucumber/glue/hook.rb +34 -11
- data/lib/cucumber/glue/invoke_in_world.rb +13 -18
- data/lib/cucumber/glue/proto_world.rb +42 -33
- data/lib/cucumber/glue/registry_and_more.rb +42 -12
- data/lib/cucumber/glue/snippet.rb +23 -22
- data/lib/cucumber/glue/step_definition.rb +42 -19
- data/lib/cucumber/glue/world_factory.rb +1 -1
- data/lib/cucumber/hooks.rb +11 -11
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +1 -1
- data/lib/cucumber/multiline_argument/data_table.rb +97 -64
- data/lib/cucumber/multiline_argument/doc_string.rb +1 -1
- data/lib/cucumber/multiline_argument.rb +4 -6
- data/lib/cucumber/platform.rb +3 -3
- data/lib/cucumber/rake/task.rb +16 -16
- data/lib/cucumber/rspec/disable_option_parser.rb +9 -8
- data/lib/cucumber/running_test_case.rb +2 -53
- data/lib/cucumber/runtime/after_hooks.rb +8 -4
- data/lib/cucumber/runtime/before_hooks.rb +8 -4
- data/lib/cucumber/runtime/for_programming_languages.rb +4 -2
- data/lib/cucumber/runtime/step_hooks.rb +6 -2
- data/lib/cucumber/runtime/support_code.rb +13 -15
- data/lib/cucumber/runtime/user_interface.rb +6 -16
- data/lib/cucumber/runtime.rb +34 -58
- data/lib/cucumber/step_definition_light.rb +4 -3
- data/lib/cucumber/step_definitions.rb +2 -2
- data/lib/cucumber/step_match.rb +12 -11
- data/lib/cucumber/step_match_search.rb +2 -1
- data/lib/cucumber/term/ansicolor.rb +9 -9
- data/lib/cucumber/version +1 -1
- data/lib/cucumber.rb +1 -1
- metadata +251 -81
- 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 -42
- data/lib/cucumber/formatter/html_builder.rb +0 -121
- 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 -11
- 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 -25
@@ -3,23 +3,27 @@
|
|
3
3
|
module Cucumber
|
4
4
|
class Runtime
|
5
5
|
class AfterHooks
|
6
|
-
def initialize(hooks, scenario)
|
6
|
+
def initialize(id_generator, hooks, scenario, event_bus)
|
7
7
|
@hooks = hooks
|
8
8
|
@scenario = scenario
|
9
|
+
@id_generator = id_generator
|
10
|
+
@event_bus = event_bus
|
9
11
|
end
|
10
12
|
|
11
13
|
def apply_to(test_case)
|
12
14
|
test_case.with_steps(
|
13
|
-
test_case.test_steps + after_hooks
|
15
|
+
test_case.test_steps + after_hooks.reverse
|
14
16
|
)
|
15
17
|
end
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def after_hooks
|
21
|
+
def after_hooks
|
20
22
|
@hooks.map do |hook|
|
21
23
|
action = ->(result) { hook.invoke('After', @scenario.with_result(result)) }
|
22
|
-
Hooks.after_hook(
|
24
|
+
hook_step = Hooks.after_hook(@id_generator.new_id, hook.location, &action)
|
25
|
+
@event_bus.hook_test_step_created(hook_step, hook)
|
26
|
+
hook_step
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -5,23 +5,27 @@ require 'cucumber/hooks'
|
|
5
5
|
module Cucumber
|
6
6
|
class Runtime
|
7
7
|
class BeforeHooks
|
8
|
-
def initialize(hooks, scenario)
|
8
|
+
def initialize(id_generator, hooks, scenario, event_bus)
|
9
9
|
@hooks = hooks
|
10
10
|
@scenario = scenario
|
11
|
+
@id_generator = id_generator
|
12
|
+
@event_bus = event_bus
|
11
13
|
end
|
12
14
|
|
13
15
|
def apply_to(test_case)
|
14
16
|
test_case.with_steps(
|
15
|
-
before_hooks
|
17
|
+
before_hooks + test_case.test_steps
|
16
18
|
)
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
20
22
|
|
21
|
-
def before_hooks
|
23
|
+
def before_hooks
|
22
24
|
@hooks.map do |hook|
|
23
25
|
action_block = ->(result) { hook.invoke('Before', @scenario.with_result(result)) }
|
24
|
-
Hooks.before_hook(
|
26
|
+
hook_step = Hooks.before_hook(@id_generator.new_id, hook.location, &action_block)
|
27
|
+
@event_bus.hook_test_step_created(hook_step, hook)
|
28
|
+
hook_step
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
|
-
require 'cucumber/core/
|
4
|
+
require 'cucumber/core/test/doc_string'
|
5
5
|
|
6
6
|
module Cucumber
|
7
7
|
class Runtime
|
@@ -15,11 +15,13 @@ module Cucumber
|
|
15
15
|
attr_reader :support_code
|
16
16
|
|
17
17
|
def initialize(support_code, user_interface)
|
18
|
-
@support_code
|
18
|
+
@support_code = support_code
|
19
|
+
@user_interface = user_interface
|
19
20
|
end
|
20
21
|
|
21
22
|
def_delegators :@user_interface,
|
22
23
|
:embed,
|
24
|
+
:attach,
|
23
25
|
:ask,
|
24
26
|
:puts,
|
25
27
|
:features_paths,
|
@@ -3,8 +3,10 @@
|
|
3
3
|
module Cucumber
|
4
4
|
class Runtime
|
5
5
|
class StepHooks
|
6
|
-
def initialize(hooks)
|
6
|
+
def initialize(id_generator, hooks, event_bus)
|
7
7
|
@hooks = hooks
|
8
|
+
@id_generator = id_generator
|
9
|
+
@event_bus = event_bus
|
8
10
|
end
|
9
11
|
|
10
12
|
def apply(test_steps)
|
@@ -18,7 +20,9 @@ module Cucumber
|
|
18
20
|
def after_step_hooks(test_step)
|
19
21
|
@hooks.map do |hook|
|
20
22
|
action = ->(*args) { hook.invoke('AfterStep', [args, test_step]) }
|
21
|
-
Hooks.after_step_hook(
|
23
|
+
hook_step = Hooks.after_step_hook(@id_generator.new_id, test_step, hook.location, &action)
|
24
|
+
@event_bus.hook_test_step_created(hook_step, hook)
|
25
|
+
hook_step
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -22,19 +22,15 @@ module Cucumber
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def step(step)
|
25
|
-
location = Core::
|
25
|
+
location = Core::Test::Location.of_caller
|
26
26
|
@support_code.invoke_dynamic_step(step[:text], multiline_arg(step, location))
|
27
27
|
end
|
28
28
|
|
29
29
|
def multiline_arg(step, location)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
MultilineArgument.from(argument[:content], location, argument[:content_type])
|
35
|
-
else
|
36
|
-
MultilineArgument::DataTable.from(argument[:rows].map { |row| row[:cells].map { |cell| cell[:value] } })
|
37
|
-
end
|
30
|
+
if !step[:doc_string].nil?
|
31
|
+
MultilineArgument.from(step[:doc_string][:content], location, step[:doc_string][:content_type])
|
32
|
+
elsif !step[:data_table].nil?
|
33
|
+
MultilineArgument::DataTable.from(step[:data_table][:rows].map { |row| row[:cells].map { |cell| cell[:value] } })
|
38
34
|
else
|
39
35
|
MultilineArgument.from(nil)
|
40
36
|
end
|
@@ -62,8 +58,8 @@ module Cucumber
|
|
62
58
|
# Given I have 8 cukes in my belly
|
63
59
|
# Then I should not be thirsty
|
64
60
|
# })
|
65
|
-
def invoke_dynamic_steps(steps_text,
|
66
|
-
parser = Cucumber::Gherkin::StepsParser.new(StepInvoker.new(self),
|
61
|
+
def invoke_dynamic_steps(steps_text, iso_code, _location)
|
62
|
+
parser = Cucumber::Gherkin::StepsParser.new(StepInvoker.new(self), iso_code)
|
67
63
|
parser.parse(steps_text)
|
68
64
|
end
|
69
65
|
|
@@ -108,26 +104,28 @@ module Cucumber
|
|
108
104
|
def find_after_step_hooks(test_case)
|
109
105
|
scenario = RunningTestCase.new(test_case)
|
110
106
|
hooks = registry.hooks_for(:after_step, scenario)
|
111
|
-
StepHooks.new hooks
|
107
|
+
StepHooks.new(@configuration.id_generator, hooks, @configuration.event_bus)
|
112
108
|
end
|
113
109
|
|
114
110
|
def apply_before_hooks(test_case)
|
111
|
+
return test_case if test_case.test_steps.empty?
|
115
112
|
scenario = RunningTestCase.new(test_case)
|
116
113
|
hooks = registry.hooks_for(:before, scenario)
|
117
|
-
BeforeHooks.new(hooks, scenario).apply_to(test_case)
|
114
|
+
BeforeHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
|
118
115
|
end
|
119
116
|
|
120
117
|
def apply_after_hooks(test_case)
|
118
|
+
return test_case if test_case.test_steps.empty?
|
121
119
|
scenario = RunningTestCase.new(test_case)
|
122
120
|
hooks = registry.hooks_for(:after, scenario)
|
123
|
-
AfterHooks.new(hooks, scenario).apply_to(test_case)
|
121
|
+
AfterHooks.new(@configuration.id_generator, hooks, scenario, @configuration.event_bus).apply_to(test_case)
|
124
122
|
end
|
125
123
|
|
126
124
|
def find_around_hooks(test_case)
|
127
125
|
scenario = RunningTestCase.new(test_case)
|
128
126
|
|
129
127
|
registry.hooks_for(:around, scenario).map do |hook|
|
130
|
-
Hooks.around_hook
|
128
|
+
Hooks.around_hook do |run_scenario|
|
131
129
|
hook.invoke('Around', scenario, &run_scenario)
|
132
130
|
end
|
133
131
|
end
|
@@ -7,14 +7,6 @@ module Cucumber
|
|
7
7
|
module UserInterface
|
8
8
|
attr_writer :visitor
|
9
9
|
|
10
|
-
# Output +messages+ alongside the formatted output.
|
11
|
-
# This is an alternative to using Kernel#puts - it will display
|
12
|
-
# nicer, and in all outputs (in case you use several formatters)
|
13
|
-
#
|
14
|
-
def puts(*messages)
|
15
|
-
@visitor.puts(*messages)
|
16
|
-
end
|
17
|
-
|
18
10
|
# Suspends execution and prompts +question+ to the console (STDOUT).
|
19
11
|
# An operator (manual tester) can then enter a line of text and hit
|
20
12
|
# <ENTER>. The entered text is returned, and both +question+ and
|
@@ -48,20 +40,18 @@ module Cucumber
|
|
48
40
|
# be a path to a file, or if it's an image it may also be a Base64 encoded image.
|
49
41
|
# The embedded data may or may not be ignored, depending on what kind of formatter(s) are active.
|
50
42
|
#
|
51
|
-
def
|
52
|
-
@visitor.
|
43
|
+
def attach(src, media_type)
|
44
|
+
@visitor.attach(src, media_type)
|
53
45
|
end
|
54
46
|
|
55
47
|
private
|
56
48
|
|
57
49
|
def mri_gets(timeout_seconds)
|
58
|
-
|
59
|
-
|
60
|
-
STDIN.gets
|
61
|
-
end
|
62
|
-
rescue Timeout::Error
|
63
|
-
nil
|
50
|
+
Timeout.timeout(timeout_seconds) do
|
51
|
+
STDIN.gets
|
64
52
|
end
|
53
|
+
rescue Timeout::Error
|
54
|
+
nil
|
65
55
|
end
|
66
56
|
|
67
57
|
def jruby_gets(timeout_seconds)
|
data/lib/cucumber/runtime.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'fileutils'
|
5
|
-
require 'multi_json'
|
6
4
|
require 'cucumber/configuration'
|
5
|
+
require 'cucumber/create_meta'
|
7
6
|
require 'cucumber/load_path'
|
8
7
|
require 'cucumber/formatter/duration'
|
9
8
|
require 'cucumber/file_specs'
|
@@ -11,6 +10,8 @@ require 'cucumber/filters'
|
|
11
10
|
require 'cucumber/formatter/fanout'
|
12
11
|
require 'cucumber/gherkin/i18n'
|
13
12
|
require 'cucumber/step_match_search'
|
13
|
+
require 'cucumber/messages'
|
14
|
+
require 'sys/uname'
|
14
15
|
|
15
16
|
module Cucumber
|
16
17
|
module FixRuby21Bug9285
|
@@ -19,8 +20,8 @@ module Cucumber
|
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
class FileException <
|
23
|
-
|
23
|
+
class FileException < RuntimeError
|
24
|
+
attr_reader :path
|
24
25
|
|
25
26
|
def initialize(original_exception, path)
|
26
27
|
super(original_exception)
|
@@ -31,7 +32,7 @@ module Cucumber
|
|
31
32
|
class FileNotFoundException < FileException
|
32
33
|
end
|
33
34
|
|
34
|
-
class FeatureFolderNotFoundException <
|
35
|
+
class FeatureFolderNotFoundException < RuntimeError
|
35
36
|
def initialize(path)
|
36
37
|
@path = path
|
37
38
|
end
|
@@ -54,7 +55,6 @@ module Cucumber
|
|
54
55
|
def initialize(configuration = Configuration.default)
|
55
56
|
@configuration = Configuration.new(configuration)
|
56
57
|
@support_code = SupportCode.new(self, @configuration)
|
57
|
-
@results = Formatter::LegacyApi::Results.new
|
58
58
|
end
|
59
59
|
|
60
60
|
# Allows you to take an existing runtime and change its configuration
|
@@ -65,6 +65,10 @@ module Cucumber
|
|
65
65
|
|
66
66
|
require 'cucumber/wire/plugin'
|
67
67
|
def run!
|
68
|
+
@configuration.notify :envelope, Cucumber::Messages::Envelope.new(
|
69
|
+
meta: Cucumber::CreateMeta.create_meta('cucumber-ruby', Cucumber::VERSION)
|
70
|
+
)
|
71
|
+
|
68
72
|
load_step_definitions
|
69
73
|
install_wire_plugin
|
70
74
|
fire_after_configuration_hook
|
@@ -72,7 +76,7 @@ module Cucumber
|
|
72
76
|
self.visitor = report
|
73
77
|
|
74
78
|
receiver = Test::Runner.new(@configuration.event_bus)
|
75
|
-
compile features, receiver, filters
|
79
|
+
compile features, receiver, filters, @configuration.event_bus
|
76
80
|
@configuration.notify :test_run_finished
|
77
81
|
end
|
78
82
|
|
@@ -84,14 +88,6 @@ module Cucumber
|
|
84
88
|
@configuration.dry_run?
|
85
89
|
end
|
86
90
|
|
87
|
-
def scenarios(status = nil)
|
88
|
-
@results.scenarios(status)
|
89
|
-
end
|
90
|
-
|
91
|
-
def steps(status = nil)
|
92
|
-
@results.steps(status)
|
93
|
-
end
|
94
|
-
|
95
91
|
def unmatched_step_definitions
|
96
92
|
@support_code.unmatched_step_definitions
|
97
93
|
end
|
@@ -107,13 +103,12 @@ module Cucumber
|
|
107
103
|
# Returns Ast::DocString for +string_without_triple_quotes+.
|
108
104
|
#
|
109
105
|
def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0)
|
110
|
-
|
111
|
-
Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
|
106
|
+
Core::Test::DocString.new(string_without_triple_quotes, content_type)
|
112
107
|
end
|
113
108
|
|
114
109
|
private
|
115
110
|
|
116
|
-
def fire_after_configuration_hook #:nodoc
|
111
|
+
def fire_after_configuration_hook #:nodoc:
|
117
112
|
@support_code.fire_hook(:after_configuration, @configuration)
|
118
113
|
end
|
119
114
|
|
@@ -143,14 +138,12 @@ module Cucumber
|
|
143
138
|
end
|
144
139
|
|
145
140
|
def initialize(path)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
raise FeatureFolderNotFoundException.new(path)
|
153
|
-
end
|
141
|
+
@file = File.new(path)
|
142
|
+
set_encoding
|
143
|
+
rescue Errno::EACCES => e
|
144
|
+
raise FileNotFoundException.new(e, File.expand_path(path))
|
145
|
+
rescue Errno::ENOENT
|
146
|
+
raise FeatureFolderNotFoundException, path
|
154
147
|
end
|
155
148
|
|
156
149
|
def read
|
@@ -162,7 +155,7 @@ module Cucumber
|
|
162
155
|
def set_encoding
|
163
156
|
@file.each do |line|
|
164
157
|
if ENCODING_PATTERN =~ line
|
165
|
-
@file.set_encoding
|
158
|
+
@file.set_encoding Regexp.last_match(1)
|
166
159
|
break
|
167
160
|
end
|
168
161
|
break unless COMMENT_OR_EMPTY_LINE_PATTERN =~ line
|
@@ -171,9 +164,6 @@ module Cucumber
|
|
171
164
|
end
|
172
165
|
end
|
173
166
|
|
174
|
-
require 'cucumber/formatter/legacy_api/adapter'
|
175
|
-
require 'cucumber/formatter/legacy_api/runtime_facade'
|
176
|
-
require 'cucumber/formatter/legacy_api/results'
|
177
167
|
require 'cucumber/formatter/ignore_missing_messages'
|
178
168
|
require 'cucumber/formatter/fail_fast'
|
179
169
|
require 'cucumber/core/report/summary'
|
@@ -194,39 +184,26 @@ module Cucumber
|
|
194
184
|
|
195
185
|
def formatters
|
196
186
|
@formatters ||=
|
197
|
-
@configuration.formatter_factories do |factory, formatter_options, path_or_io
|
198
|
-
create_formatter(factory, formatter_options, path_or_io
|
187
|
+
@configuration.formatter_factories do |factory, formatter_options, path_or_io|
|
188
|
+
create_formatter(factory, formatter_options, path_or_io)
|
199
189
|
end
|
200
190
|
end
|
201
191
|
|
202
|
-
def create_formatter(factory, formatter_options, path_or_io
|
203
|
-
if
|
204
|
-
if
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
return factory.new(@configuration.with_options(out_stream: path_or_io))
|
211
|
-
end
|
192
|
+
def create_formatter(factory, formatter_options, path_or_io)
|
193
|
+
if accept_options?(factory)
|
194
|
+
return factory.new(@configuration, formatter_options) if path_or_io.nil?
|
195
|
+
factory.new(@configuration.with_options(out_stream: path_or_io),
|
196
|
+
formatter_options)
|
197
|
+
else
|
198
|
+
return factory.new(@configuration) if path_or_io.nil?
|
199
|
+
factory.new(@configuration.with_options(out_stream: path_or_io))
|
212
200
|
end
|
213
|
-
results = Formatter::LegacyApi::Results.new
|
214
|
-
runtime_facade = Formatter::LegacyApi::RuntimeFacade.new(results, @support_code, @configuration)
|
215
|
-
formatter = factory.new(runtime_facade, path_or_io, cli_options)
|
216
|
-
Formatter::LegacyApi::Adapter.new(
|
217
|
-
Formatter::IgnoreMissingMessages.new(formatter),
|
218
|
-
results, @configuration
|
219
|
-
)
|
220
201
|
end
|
221
202
|
|
222
203
|
def accept_options?(factory)
|
223
204
|
factory.instance_method(:initialize).arity > 1
|
224
205
|
end
|
225
206
|
|
226
|
-
def legacy_formatter?(factory)
|
227
|
-
factory.instance_method(:initialize).arity > 2
|
228
|
-
end
|
229
|
-
|
230
207
|
def failure?
|
231
208
|
if @configuration.wip?
|
232
209
|
summary_report.test_cases.total_passed > 0
|
@@ -237,7 +214,7 @@ module Cucumber
|
|
237
214
|
public :failure?
|
238
215
|
|
239
216
|
require 'cucumber/core/test/filters'
|
240
|
-
def filters
|
217
|
+
def filters # rubocop:disable Metrics/AbcSize
|
241
218
|
tag_expressions = @configuration.tag_expressions
|
242
219
|
name_regexps = @configuration.name_regexps
|
243
220
|
tag_limits = @configuration.tag_limits
|
@@ -250,14 +227,13 @@ module Cucumber
|
|
250
227
|
# TODO: can we just use Glue::RegistryAndMore's step definitions directly?
|
251
228
|
step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration)
|
252
229
|
filters << Filters::ActivateSteps.new(step_match_search, @configuration)
|
253
|
-
@configuration.filters.each
|
254
|
-
filters << filter
|
255
|
-
end
|
230
|
+
@configuration.filters.each { |filter| filters << filter }
|
256
231
|
unless configuration.dry_run?
|
257
232
|
filters << Filters::ApplyAfterStepHooks.new(@support_code)
|
258
233
|
filters << Filters::ApplyBeforeHooks.new(@support_code)
|
259
234
|
filters << Filters::ApplyAfterHooks.new(@support_code)
|
260
235
|
filters << Filters::ApplyAroundHooks.new(@support_code)
|
236
|
+
filters << Filters::BroadcastTestCaseReadyEvent.new(@configuration)
|
261
237
|
filters << Filters::BroadcastTestRunStartedEvent.new(@configuration)
|
262
238
|
filters << Filters::Quit.new
|
263
239
|
filters << Filters::Retry.new(@configuration)
|
@@ -273,7 +249,7 @@ module Cucumber
|
|
273
249
|
end
|
274
250
|
|
275
251
|
def install_wire_plugin
|
276
|
-
Cucumber::Wire::Plugin.new(@configuration).install if @configuration.all_files_to_load.any? { |f| f =~
|
252
|
+
Cucumber::Wire::Plugin.new(@configuration, @support_code.registry).install if @configuration.all_files_to_load.any? { |f| f =~ /\.wire$/ }
|
277
253
|
end
|
278
254
|
|
279
255
|
def log
|
@@ -9,11 +9,12 @@ module Cucumber
|
|
9
9
|
attr_reader :regexp_source, :location
|
10
10
|
|
11
11
|
def initialize(regexp_source, location)
|
12
|
-
@regexp_source
|
12
|
+
@regexp_source = regexp_source
|
13
|
+
@location = location
|
13
14
|
end
|
14
15
|
|
15
|
-
def eql?(
|
16
|
-
regexp_source ==
|
16
|
+
def eql?(other)
|
17
|
+
regexp_source == other.regexp_source && location == other.location
|
17
18
|
end
|
18
19
|
|
19
20
|
def hash
|
@@ -8,8 +8,8 @@ module Cucumber
|
|
8
8
|
@support_code.load_files_from_paths(configuration.autoload_code_paths)
|
9
9
|
end
|
10
10
|
|
11
|
-
def to_json
|
12
|
-
@support_code.step_definitions.map(&:to_hash).to_json
|
11
|
+
def to_json(obj = nil)
|
12
|
+
@support_code.step_definitions.map(&:to_hash).to_json(obj)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/cucumber/step_match.rb
CHANGED
@@ -9,7 +9,9 @@ module Cucumber
|
|
9
9
|
|
10
10
|
def initialize(step_definition, step_name, step_arguments)
|
11
11
|
raise "step_arguments can't be nil (but it can be an empty array)" if step_arguments.nil?
|
12
|
-
@step_definition
|
12
|
+
@step_definition = step_definition
|
13
|
+
@name_to_match = step_name
|
14
|
+
@step_arguments = step_arguments
|
13
15
|
end
|
14
16
|
|
15
17
|
def args
|
@@ -21,7 +23,7 @@ module Cucumber
|
|
21
23
|
|
22
24
|
def activate(test_step)
|
23
25
|
test_step.with_action(@step_definition.location) do
|
24
|
-
invoke(MultilineArgument.from_core(test_step.
|
26
|
+
invoke(MultilineArgument.from_core(test_step.multiline_arg))
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -46,7 +48,7 @@ module Cucumber
|
|
46
48
|
#
|
47
49
|
# lambda { |param| "[#{param}]" }
|
48
50
|
#
|
49
|
-
def format_args(format =
|
51
|
+
def format_args(format = ->(a) { a }, &proc)
|
50
52
|
replace_arguments(@name_to_match, @step_arguments, format, &proc)
|
51
53
|
end
|
52
54
|
|
@@ -75,7 +77,7 @@ module Cucumber
|
|
75
77
|
|
76
78
|
replacement = if block_given?
|
77
79
|
yield(group.value)
|
78
|
-
elsif Proc
|
80
|
+
elsif Proc == format.class
|
79
81
|
format.call(group.value)
|
80
82
|
else
|
81
83
|
format % group.value
|
@@ -95,13 +97,13 @@ module Cucumber
|
|
95
97
|
private
|
96
98
|
|
97
99
|
def deep_clone_args
|
98
|
-
Marshal.load(
|
100
|
+
Marshal.load(Marshal.dump(args))
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
102
104
|
class SkippingStepMatch
|
103
105
|
def activate(test_step)
|
104
|
-
|
106
|
+
test_step.with_action { raise Core::Test::Result::Skipped }
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
@@ -123,8 +125,7 @@ module Cucumber
|
|
123
125
|
end
|
124
126
|
|
125
127
|
def file_colon_line
|
126
|
-
|
127
|
-
@step.file_colon_line
|
128
|
+
location.to_s
|
128
129
|
end
|
129
130
|
|
130
131
|
def backtrace_line
|
@@ -132,7 +133,7 @@ module Cucumber
|
|
132
133
|
end
|
133
134
|
|
134
135
|
def text_length
|
135
|
-
@step.
|
136
|
+
@step.text.length
|
136
137
|
end
|
137
138
|
|
138
139
|
def step_arguments
|
@@ -141,7 +142,7 @@ module Cucumber
|
|
141
142
|
|
142
143
|
def activate(test_step)
|
143
144
|
# noop
|
144
|
-
|
145
|
+
test_step
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
@@ -151,7 +152,7 @@ module Cucumber
|
|
151
152
|
end
|
152
153
|
|
153
154
|
def activate(test_step)
|
154
|
-
|
155
|
+
test_step.with_action { raise @error }
|
155
156
|
end
|
156
157
|
end
|
157
158
|
end
|
@@ -35,7 +35,7 @@ module Cucumber
|
|
35
35
|
[:on_magenta, 45],
|
36
36
|
[:on_cyan, 46],
|
37
37
|
[:on_white, 47]
|
38
|
-
]
|
38
|
+
].freeze
|
39
39
|
|
40
40
|
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
41
41
|
# :startdoc:
|
@@ -54,8 +54,9 @@ module Cucumber
|
|
54
54
|
end
|
55
55
|
self.coloring = true
|
56
56
|
|
57
|
+
# rubocop:disable Security/Eval
|
57
58
|
ATTRIBUTES.each do |c, v|
|
58
|
-
eval
|
59
|
+
eval <<-END_EVAL, binding, __FILE__, __LINE__ + 1
|
59
60
|
def #{c}(string = nil)
|
60
61
|
result = String.new
|
61
62
|
result << "\e[#{v}m" if Cucumber::Term::ANSIColor.coloring?
|
@@ -71,23 +72,23 @@ module Cucumber
|
|
71
72
|
result << "\e[0m" if Cucumber::Term::ANSIColor.coloring?
|
72
73
|
result
|
73
74
|
end
|
74
|
-
|
75
|
+
END_EVAL
|
75
76
|
end
|
77
|
+
# rubocop:enable Security/Eval
|
76
78
|
|
77
79
|
# Regular expression that is used to scan for ANSI-sequences while
|
78
80
|
# uncoloring strings.
|
79
81
|
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
80
82
|
|
81
83
|
def self.included(klass)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
84
|
+
return unless klass == String
|
85
|
+
ATTRIBUTES.delete(:clear)
|
86
|
+
ATTRIBUTE_NAMES.delete(:clear)
|
86
87
|
end
|
87
88
|
|
88
89
|
# Returns an uncolored version of the string, that is all
|
89
90
|
# ANSI-sequences are stripped from the string.
|
90
|
-
def uncolored(string = nil)
|
91
|
+
def uncolored(string = nil)
|
91
92
|
if block_given?
|
92
93
|
yield.gsub(COLORED_REGEXP, '')
|
93
94
|
elsif string
|
@@ -105,7 +106,6 @@ module Cucumber
|
|
105
106
|
def attributes
|
106
107
|
ATTRIBUTE_NAMES
|
107
108
|
end
|
108
|
-
extend self
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
data/lib/cucumber/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
4.1.0
|