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,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'yaml'
|
3
4
|
|
4
5
|
module Cucumber
|
5
6
|
module Cli
|
6
|
-
|
7
7
|
class ProfileLoader
|
8
|
-
|
9
8
|
def initialize
|
10
9
|
@cucumber_yml = nil
|
11
10
|
end
|
@@ -17,26 +16,19 @@ Could not find profile: '#{profile}'
|
|
17
16
|
|
18
17
|
Defined profiles in cucumber.yml:
|
19
18
|
* #{cucumber_yml.keys.sort.join("\n * ")}
|
20
|
-
|
19
|
+
END_OF_ERROR
|
21
20
|
end
|
22
21
|
|
23
22
|
args_from_yml = cucumber_yml[profile] || ''
|
24
23
|
|
25
|
-
require 'shellwords'
|
26
|
-
|
27
24
|
case args_from_yml
|
28
25
|
when String
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
placeholder = 'pseudo_unique_backslash_placeholder'
|
34
|
-
sanitized_line = args_from_yml.gsub('\\', placeholder)
|
35
|
-
|
36
|
-
args_from_yml = Shellwords.shellwords(sanitized_line).collect { |argument| argument.gsub(placeholder, '\\') }
|
37
|
-
else
|
38
|
-
args_from_yml = Shellwords.shellwords(args_from_yml)
|
26
|
+
if args_from_yml =~ /^\s*$/
|
27
|
+
raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was blank." \
|
28
|
+
" Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n"
|
39
29
|
end
|
30
|
+
|
31
|
+
args_from_yml = processed_shellwords(args_from_yml)
|
40
32
|
when Array
|
41
33
|
raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was empty. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml.empty?
|
42
34
|
else
|
@@ -46,7 +38,7 @@ Defined profiles in cucumber.yml:
|
|
46
38
|
args_from_yml
|
47
39
|
end
|
48
40
|
|
49
|
-
def
|
41
|
+
def profile?(profile)
|
50
42
|
cucumber_yml.key?(profile)
|
51
43
|
end
|
52
44
|
|
@@ -59,29 +51,47 @@ Defined profiles in cucumber.yml:
|
|
59
51
|
# Loads the profile, processing it through ERB and YAML, and returns it as a hash.
|
60
52
|
def cucumber_yml
|
61
53
|
return @cucumber_yml if @cucumber_yml
|
62
|
-
|
63
|
-
|
54
|
+
|
55
|
+
ensure_configuration_file_exists
|
56
|
+
process_configuration_file_with_erb
|
57
|
+
load_configuration
|
58
|
+
|
59
|
+
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
60
|
+
raise(YmlLoadError, 'cucumber.yml was found, but was blank or malformed. ' \
|
61
|
+
"Please refer to cucumber's documentation on correct profile usage.\n")
|
64
62
|
end
|
65
63
|
|
64
|
+
@cucumber_yml
|
65
|
+
end
|
66
|
+
|
67
|
+
def ensure_configuration_file_exists
|
68
|
+
return if cucumber_yml_defined?
|
69
|
+
|
70
|
+
raise(ProfilesNotDefinedError, "cucumber.yml was not found. Current directory is #{Dir.pwd}." \
|
71
|
+
"Please refer to cucumber's documentation on defining profiles in cucumber.yml. You must define" \
|
72
|
+
"a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
|
73
|
+
end
|
74
|
+
|
75
|
+
def process_configuration_file_with_erb
|
66
76
|
require 'erb'
|
67
|
-
require 'yaml'
|
68
77
|
begin
|
69
|
-
@cucumber_erb =
|
78
|
+
@cucumber_erb = if RUBY_VERSION >= '2.6'
|
79
|
+
ERB.new(IO.read(cucumber_file), trim_mode: '%').result(binding)
|
80
|
+
else
|
81
|
+
ERB.new(IO.read(cucumber_file), nil, '%').result(binding)
|
82
|
+
end
|
70
83
|
rescue StandardError
|
71
|
-
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage.\n#{
|
84
|
+
raise(YmlLoadError, "cucumber.yml was found, but could not be parsed with ERB. Please refer to cucumber's documentation on correct profile usage.\n#{$ERROR_INFO.inspect}")
|
72
85
|
end
|
86
|
+
end
|
73
87
|
|
88
|
+
def load_configuration
|
89
|
+
require 'yaml'
|
74
90
|
begin
|
75
|
-
@cucumber_yml = YAML.load(@cucumber_erb)
|
91
|
+
@cucumber_yml = YAML.load(@cucumber_erb) # rubocop:disable Security/YAMLLoad
|
76
92
|
rescue StandardError
|
77
|
-
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
|
78
|
-
end
|
79
|
-
|
80
|
-
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
81
|
-
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage.\n")
|
93
|
+
raise(YmlLoadError, "cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
|
82
94
|
end
|
83
|
-
|
84
|
-
return @cucumber_yml
|
85
95
|
end
|
86
96
|
|
87
97
|
# Locates cucumber.yml file. The file can end in .yml or .yaml,
|
@@ -91,6 +101,17 @@ Defined profiles in cucumber.yml:
|
|
91
101
|
@cucumber_file ||= Dir.glob('{,.config/,config/}cucumber{.yml,.yaml}').first
|
92
102
|
end
|
93
103
|
|
104
|
+
def processed_shellwords(args_from_yml)
|
105
|
+
require 'shellwords'
|
106
|
+
|
107
|
+
return Shellwords.shellwords(args_from_yml) unless Cucumber::WINDOWS
|
108
|
+
|
109
|
+
# Shellwords treats backslash as an escape character so we have to mask it out temporarily
|
110
|
+
placeholder = 'pseudo_unique_backslash_placeholder'
|
111
|
+
sanitized_line = args_from_yml.gsub('\\', placeholder)
|
112
|
+
|
113
|
+
Shellwords.shellwords(sanitized_line).collect { |argument| argument.gsub(placeholder, '\\') }
|
114
|
+
end
|
94
115
|
end
|
95
116
|
end
|
96
117
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/constantize'
|
3
4
|
require 'cucumber/cli/rerun_file'
|
4
5
|
require 'cucumber/events'
|
6
|
+
require 'cucumber/messages'
|
5
7
|
require 'cucumber/core/event_bus'
|
6
8
|
require 'cucumber/core/test/result'
|
7
9
|
require 'forwardable'
|
@@ -53,7 +55,7 @@ module Cucumber
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def seed
|
56
|
-
|
58
|
+
@options[:seed]
|
57
59
|
end
|
58
60
|
|
59
61
|
def dry_run?
|
@@ -166,27 +168,31 @@ module Cucumber
|
|
166
168
|
end
|
167
169
|
|
168
170
|
def support_to_load
|
169
|
-
support_files = all_files_to_load.select {|f| f =~ %r{/support/} }
|
170
|
-
|
171
|
+
support_files = all_files_to_load.select { |f| f =~ %r{/support/} }
|
172
|
+
|
173
|
+
# env_files are separated from other_files so we can ensure env files
|
174
|
+
# load first.
|
175
|
+
#
|
176
|
+
env_files = support_files.select { |f| f =~ %r{/support/env\..*} }
|
171
177
|
other_files = support_files - env_files
|
172
|
-
|
178
|
+
env_files.reverse + other_files.reverse
|
173
179
|
end
|
174
180
|
|
175
181
|
def all_files_to_load
|
176
182
|
files = require_dirs.map do |path|
|
177
183
|
path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes.
|
178
|
-
path = path.gsub(/\/$/, '') # Strip trailing slash.
|
184
|
+
path = path.gsub(/\/$/, '') # Strip trailing slash. # rubocop:disable Style/RegexpLiteral
|
179
185
|
File.directory?(path) ? Dir["#{path}/**/*"] : path
|
180
186
|
end.flatten.uniq
|
181
187
|
remove_excluded_files_from(files)
|
182
|
-
files.
|
183
|
-
files.reject! {|f| File.extname(f) == '.feature' }
|
184
|
-
files.reject! {|f| f =~ /^http/}
|
188
|
+
files.select! { |f| File.file?(f) }
|
189
|
+
files.reject! { |f| File.extname(f) == '.feature' }
|
190
|
+
files.reject! { |f| f =~ /^http/ }
|
185
191
|
files.sort
|
186
192
|
end
|
187
193
|
|
188
194
|
def step_defs_to_load
|
189
|
-
all_files_to_load.reject {|f| f =~ %r{/support/} }
|
195
|
+
all_files_to_load.reject { |f| f =~ %r{/support/} }
|
190
196
|
end
|
191
197
|
|
192
198
|
def formatter_factories
|
@@ -195,9 +201,8 @@ module Cucumber
|
|
195
201
|
factory = formatter_class(format)
|
196
202
|
yield factory,
|
197
203
|
formatter_options,
|
198
|
-
path_or_io
|
199
|
-
|
200
|
-
rescue Exception => e
|
204
|
+
path_or_io
|
205
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
201
206
|
raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace
|
202
207
|
end
|
203
208
|
end
|
@@ -238,26 +243,30 @@ module Cucumber
|
|
238
243
|
@options[:event_bus]
|
239
244
|
end
|
240
245
|
|
246
|
+
def id_generator
|
247
|
+
@id_generator ||= Cucumber::Messages::IdGenerator::UUID.new
|
248
|
+
end
|
249
|
+
|
241
250
|
private
|
242
251
|
|
243
252
|
def default_options
|
244
253
|
{
|
245
|
-
:
|
246
|
-
:
|
247
|
-
:
|
248
|
-
:
|
249
|
-
:
|
250
|
-
:
|
251
|
-
:
|
252
|
-
:
|
253
|
-
:
|
254
|
-
:
|
255
|
-
:
|
256
|
-
:
|
257
|
-
:
|
258
|
-
:
|
259
|
-
:
|
260
|
-
:
|
254
|
+
autoload_code_paths: ['features/support', 'features/step_definitions'],
|
255
|
+
filters: [],
|
256
|
+
strict: Cucumber::Core::Test::Result::StrictConfiguration.new,
|
257
|
+
require: [],
|
258
|
+
dry_run: false,
|
259
|
+
fail_fast: false,
|
260
|
+
formats: [],
|
261
|
+
excludes: [],
|
262
|
+
tag_expressions: [],
|
263
|
+
name_regexps: [],
|
264
|
+
env_vars: {},
|
265
|
+
diff_enabled: true,
|
266
|
+
snippets: true,
|
267
|
+
source: true,
|
268
|
+
duration: true,
|
269
|
+
event_bus: Cucumber::Events.make_event_bus
|
261
270
|
}
|
262
271
|
end
|
263
272
|
|
@@ -271,7 +280,7 @@ module Cucumber
|
|
271
280
|
end
|
272
281
|
|
273
282
|
def remove_excluded_files_from(files)
|
274
|
-
files.reject! {|path| @options[:excludes].detect {|pattern| path =~ pattern } }
|
283
|
+
files.reject! { |path| @options[:excludes].detect { |pattern| path =~ pattern } }
|
275
284
|
end
|
276
285
|
|
277
286
|
def require_dirs
|
data/lib/cucumber/constantize.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/platform'
|
3
4
|
module Cucumber
|
4
5
|
module Constantize #:nodoc:
|
@@ -16,21 +17,18 @@ module Cucumber
|
|
16
17
|
constant
|
17
18
|
rescue NameError => e
|
18
19
|
require underscore(camel_cased_word)
|
19
|
-
if try < 2
|
20
|
-
|
21
|
-
else
|
22
|
-
raise e
|
23
|
-
end
|
20
|
+
retry if try < 2
|
21
|
+
raise e
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
25
|
# Snagged from active_support
|
28
26
|
def underscore(camel_cased_word)
|
29
|
-
camel_cased_word.to_s.gsub(/::/, '/')
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
camel_cased_word.to_s.gsub(/::/, '/')
|
28
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
29
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
30
|
+
.tr('-', '_')
|
31
|
+
.downcase
|
34
32
|
end
|
35
33
|
|
36
34
|
private
|
data/lib/cucumber/deprecate.rb
CHANGED
@@ -1,30 +1,54 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/platform'
|
3
4
|
require 'cucumber/gherkin/formatter/ansi_escapes'
|
4
5
|
|
5
6
|
module Cucumber
|
6
7
|
module Deprecate
|
7
|
-
|
8
|
-
|
8
|
+
class AnsiString
|
9
|
+
include Cucumber::Gherkin::Formatter::AnsiEscapes
|
10
|
+
|
11
|
+
def self.failure_message(message)
|
12
|
+
AnsiString.new.failure_message(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure_message(message)
|
16
|
+
failed + message + reset
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class CliOption
|
21
|
+
def self.deprecate(stream, option, message, remove_after_version)
|
22
|
+
return if stream.nil?
|
23
|
+
stream.puts(
|
24
|
+
AnsiString.failure_message(
|
25
|
+
"\nWARNING: #{option} is deprecated" \
|
26
|
+
" and will be removed after version #{remove_after_version}.\n#{message}.\n"
|
27
|
+
)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
9
31
|
|
32
|
+
module ForUsers
|
10
33
|
def self.call(message, method, remove_after_version)
|
11
|
-
STDERR.puts
|
34
|
+
STDERR.puts AnsiString.failure_message(
|
35
|
+
"\nWARNING: ##{method} is deprecated" \
|
36
|
+
" and will be removed after version #{remove_after_version}. #{message}.\n" \
|
37
|
+
"(Called from #{caller(3..3).first})"
|
38
|
+
)
|
12
39
|
end
|
13
40
|
end
|
14
41
|
|
15
42
|
module ForDevelopers
|
16
43
|
def self.call(_message, _method, remove_after_version)
|
17
|
-
if Cucumber::VERSION > remove_after_version
|
18
|
-
raise "This method is due for removal after version #{remove_after_version}"
|
19
|
-
end
|
44
|
+
raise "This method is due for removal after version #{remove_after_version}" if Cucumber::VERSION > remove_after_version
|
20
45
|
end
|
21
46
|
end
|
22
47
|
|
23
|
-
STRATEGY = $
|
48
|
+
STRATEGY = $PROGRAM_NAME =~ /rspec$/ ? ForDevelopers : ForUsers
|
24
49
|
end
|
25
50
|
|
26
51
|
def self.deprecate(*args)
|
27
52
|
Deprecate::STRATEGY.call(*args)
|
28
53
|
end
|
29
|
-
|
30
54
|
end
|
data/lib/cucumber/encoding.rb
CHANGED
data/lib/cucumber/errors.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/core/test/result'
|
3
4
|
|
4
5
|
module Cucumber
|
5
6
|
# Raised when there is no matching StepDefinition for a step.
|
6
7
|
class Undefined < Core::Test::Result::Undefined
|
7
8
|
def self.from(result, step_name)
|
8
|
-
if result.is_a?(self)
|
9
|
-
return result.with_message(with_prefix(result.message))
|
10
|
-
end
|
9
|
+
return result.with_message(with_prefix(result.message)) if result.is_a?(self)
|
11
10
|
|
12
11
|
begin
|
13
|
-
raise
|
14
|
-
rescue =>
|
15
|
-
return
|
12
|
+
raise new(with_prefix(step_name)) # rubocop:disable Style/RaiseArgs
|
13
|
+
rescue StandardError => e
|
14
|
+
return e
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
@@ -36,7 +35,7 @@ module Cucumber
|
|
36
35
|
# Raised when a step matches 2 or more StepDefinitions
|
37
36
|
class Ambiguous < StandardError
|
38
37
|
def initialize(step_name, step_definitions, used_guess)
|
39
|
-
message = String.new
|
38
|
+
message = String.new # rubocop:disable Style/EmptyLiteral
|
40
39
|
message << "Ambiguous match of \"#{step_name}\":\n\n"
|
41
40
|
message << step_definitions.map(&:backtrace_line).join("\n")
|
42
41
|
message << "\n\n"
|
data/lib/cucumber/events.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Dir[File.dirname(__FILE__) + '/events/*.rb'].map(&method(:require))
|
3
4
|
|
4
5
|
module Cucumber
|
5
|
-
|
6
6
|
# Events tell you what's happening while Cucumber runs your features.
|
7
7
|
#
|
8
8
|
# They're designed to be read-only, appropriate for writing formatters and other
|
@@ -24,15 +24,22 @@ module Cucumber
|
|
24
24
|
|
25
25
|
def self.registry
|
26
26
|
Core::Events.build_registry(
|
27
|
-
|
27
|
+
GherkinSourceParsed,
|
28
|
+
GherkinSourceRead,
|
29
|
+
HookTestStepCreated,
|
30
|
+
StepActivated,
|
31
|
+
StepDefinitionRegistered,
|
32
|
+
TestCaseCreated,
|
28
33
|
TestCaseFinished,
|
34
|
+
TestCaseStarted,
|
35
|
+
TestCaseReady,
|
36
|
+
TestRunFinished,
|
37
|
+
TestRunStarted,
|
38
|
+
TestStepCreated,
|
29
39
|
TestStepFinished,
|
30
40
|
TestStepStarted,
|
31
|
-
|
32
|
-
|
33
|
-
TestRunFinished,
|
34
|
-
GherkinSourceRead,
|
35
|
-
TestRunStarted
|
41
|
+
Envelope,
|
42
|
+
UndefinedParameterType
|
36
43
|
)
|
37
44
|
end
|
38
45
|
end
|