cucumber 3.1.2 → 5.2.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.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +287 -14
  3. data/CONTRIBUTING.md +11 -25
  4. data/README.md +4 -5
  5. data/bin/cucumber +1 -1
  6. data/lib/autotest/cucumber_mixin.rb +46 -53
  7. data/lib/cucumber.rb +1 -1
  8. data/lib/cucumber/cli/configuration.rb +5 -5
  9. data/lib/cucumber/cli/main.rb +12 -12
  10. data/lib/cucumber/cli/options.rb +97 -76
  11. data/lib/cucumber/cli/profile_loader.rb +49 -26
  12. data/lib/cucumber/configuration.rb +44 -29
  13. data/lib/cucumber/constantize.rb +2 -5
  14. data/lib/cucumber/deprecate.rb +31 -7
  15. data/lib/cucumber/errors.rb +5 -7
  16. data/lib/cucumber/events.rb +13 -6
  17. data/lib/cucumber/events/envelope.rb +9 -0
  18. data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
  19. data/lib/cucumber/events/hook_test_step_created.rb +13 -0
  20. data/lib/cucumber/events/step_activated.rb +2 -1
  21. data/lib/cucumber/events/test_case_created.rb +13 -0
  22. data/lib/cucumber/events/test_case_ready.rb +12 -0
  23. data/lib/cucumber/events/test_step_created.rb +13 -0
  24. data/lib/cucumber/events/undefined_parameter_type.rb +10 -0
  25. data/lib/cucumber/file_specs.rb +6 -6
  26. data/lib/cucumber/filters.rb +1 -0
  27. data/lib/cucumber/filters/activate_steps.rb +5 -3
  28. data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
  29. data/lib/cucumber/filters/prepare_world.rb +5 -9
  30. data/lib/cucumber/filters/quit.rb +1 -3
  31. data/lib/cucumber/filters/tag_limits/verifier.rb +2 -4
  32. data/lib/cucumber/formatter/ansicolor.rb +40 -45
  33. data/lib/cucumber/formatter/ast_lookup.rb +163 -0
  34. data/lib/cucumber/formatter/backtrace_filter.rb +9 -8
  35. data/lib/cucumber/formatter/console.rb +58 -66
  36. data/lib/cucumber/formatter/console_counts.rb +4 -9
  37. data/lib/cucumber/formatter/console_issues.rb +6 -3
  38. data/lib/cucumber/formatter/duration.rb +1 -1
  39. data/lib/cucumber/formatter/duration_extractor.rb +3 -1
  40. data/lib/cucumber/formatter/errors.rb +6 -0
  41. data/lib/cucumber/formatter/fanout.rb +2 -0
  42. data/lib/cucumber/formatter/html.rb +11 -598
  43. data/lib/cucumber/formatter/http_io.rb +147 -0
  44. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
  45. data/lib/cucumber/formatter/interceptor.rb +11 -30
  46. data/lib/cucumber/formatter/io.rb +55 -13
  47. data/lib/cucumber/formatter/json.rb +102 -110
  48. data/lib/cucumber/formatter/junit.rb +55 -55
  49. data/lib/cucumber/formatter/message.rb +22 -0
  50. data/lib/cucumber/formatter/message_builder.rb +255 -0
  51. data/lib/cucumber/formatter/pretty.rb +359 -153
  52. data/lib/cucumber/formatter/progress.rb +30 -32
  53. data/lib/cucumber/formatter/publish_banner_printer.rb +77 -0
  54. data/lib/cucumber/formatter/query/hook_by_test_step.rb +31 -0
  55. data/lib/cucumber/formatter/query/pickle_by_test.rb +26 -0
  56. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +26 -0
  57. data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +40 -0
  58. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +40 -0
  59. data/lib/cucumber/formatter/rerun.rb +22 -4
  60. data/lib/cucumber/formatter/stepdefs.rb +1 -2
  61. data/lib/cucumber/formatter/steps.rb +3 -4
  62. data/lib/cucumber/formatter/summary.rb +16 -8
  63. data/lib/cucumber/formatter/unicode.rb +15 -17
  64. data/lib/cucumber/formatter/url_reporter.rb +17 -0
  65. data/lib/cucumber/formatter/usage.rb +11 -10
  66. data/lib/cucumber/gherkin/data_table_parser.rb +17 -6
  67. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +13 -17
  68. data/lib/cucumber/gherkin/formatter/escaping.rb +2 -2
  69. data/lib/cucumber/gherkin/steps_parser.rb +17 -8
  70. data/lib/cucumber/glue/hook.rb +34 -11
  71. data/lib/cucumber/glue/invoke_in_world.rb +13 -18
  72. data/lib/cucumber/glue/proto_world.rb +42 -33
  73. data/lib/cucumber/glue/registry_and_more.rb +42 -12
  74. data/lib/cucumber/glue/snippet.rb +23 -22
  75. data/lib/cucumber/glue/step_definition.rb +42 -19
  76. data/lib/cucumber/glue/world_factory.rb +1 -1
  77. data/lib/cucumber/hooks.rb +11 -11
  78. data/lib/cucumber/multiline_argument.rb +4 -6
  79. data/lib/cucumber/multiline_argument/data_table.rb +97 -64
  80. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +2 -2
  81. data/lib/cucumber/multiline_argument/doc_string.rb +1 -1
  82. data/lib/cucumber/platform.rb +3 -3
  83. data/lib/cucumber/rake/task.rb +16 -18
  84. data/lib/cucumber/rspec/disable_option_parser.rb +9 -8
  85. data/lib/cucumber/rspec/doubles.rb +3 -5
  86. data/lib/cucumber/running_test_case.rb +2 -53
  87. data/lib/cucumber/runtime.rb +41 -58
  88. data/lib/cucumber/runtime/after_hooks.rb +8 -4
  89. data/lib/cucumber/runtime/before_hooks.rb +8 -4
  90. data/lib/cucumber/runtime/for_programming_languages.rb +4 -2
  91. data/lib/cucumber/runtime/step_hooks.rb +6 -2
  92. data/lib/cucumber/runtime/support_code.rb +13 -15
  93. data/lib/cucumber/runtime/user_interface.rb +6 -16
  94. data/lib/cucumber/step_definition_light.rb +4 -3
  95. data/lib/cucumber/step_definitions.rb +2 -2
  96. data/lib/cucumber/step_match.rb +12 -11
  97. data/lib/cucumber/step_match_search.rb +2 -1
  98. data/lib/cucumber/term/ansicolor.rb +9 -9
  99. data/lib/cucumber/term/banner.rb +56 -0
  100. data/lib/cucumber/version +1 -1
  101. metadata +254 -83
  102. data/lib/cucumber/events/gherkin_source_parsed.rb~ +0 -14
  103. data/lib/cucumber/formatter/ast_lookup.rb~ +0 -9
  104. data/lib/cucumber/formatter/cucumber.css +0 -286
  105. data/lib/cucumber/formatter/cucumber.sass +0 -247
  106. data/lib/cucumber/formatter/hook_query_visitor.rb +0 -42
  107. data/lib/cucumber/formatter/html_builder.rb +0 -121
  108. data/lib/cucumber/formatter/inline-js.js +0 -30
  109. data/lib/cucumber/formatter/jquery-min.js +0 -154
  110. data/lib/cucumber/formatter/json_pretty.rb +0 -11
  111. data/lib/cucumber/formatter/legacy_api/adapter.rb +0 -1028
  112. data/lib/cucumber/formatter/legacy_api/ast.rb +0 -394
  113. data/lib/cucumber/formatter/legacy_api/results.rb +0 -50
  114. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +0 -32
  115. data/lib/cucumber/step_argument.rb +0 -25
@@ -5,6 +5,7 @@ require 'cucumber/formatter/console'
5
5
  require 'cucumber/formatter/console_counts'
6
6
  require 'cucumber/formatter/console_issues'
7
7
  require 'cucumber/core/test/result'
8
+ require 'cucumber/formatter/ast_lookup'
8
9
 
9
10
  module Cucumber
10
11
  module Formatter
@@ -14,9 +15,11 @@ module Cucumber
14
15
  include Console
15
16
 
16
17
  def initialize(config)
17
- @config, @io = config, ensure_io(config.out_stream)
18
+ @config = config
19
+ @io = ensure_io(config.out_stream, config.error_stream)
20
+ @ast_lookup = AstLookup.new(config)
18
21
  @counts = ConsoleCounts.new(@config)
19
- @issues = ConsoleIssues.new(@config)
22
+ @issues = ConsoleIssues.new(@config, @ast_lookup)
20
23
  @start_time = Time.now
21
24
 
22
25
  @config.on_event :test_case_started do |event|
@@ -28,7 +31,7 @@ module Cucumber
28
31
  print_result event.result
29
32
  end
30
33
 
31
- @config.on_event :test_run_finished do |event|
34
+ @config.on_event :test_run_finished do |_event|
32
35
  duration = Time.now - @start_time
33
36
  @io.puts
34
37
  print_statistics(duration, @config, @counts, @issues)
@@ -37,12 +40,17 @@ module Cucumber
37
40
 
38
41
  private
39
42
 
43
+ def gherkin_document(uri)
44
+ @ast_lookup.gherkin_document(uri)
45
+ end
46
+
40
47
  def print_feature(test_case)
41
- feature = test_case.feature
42
- return if @current_feature == feature
43
- @io.puts unless @current_feature.nil?
44
- @io.puts feature
45
- @current_feature = feature
48
+ uri = test_case.location.file
49
+ return if @current_feature_uri == uri
50
+ feature_name = gherkin_document(uri).feature.name
51
+ @io.puts unless @current_feature_uri.nil?
52
+ @io.puts feature_name
53
+ @current_feature_uri = uri
46
54
  end
47
55
 
48
56
  def print_test_case(test_case)
@@ -9,39 +9,37 @@ if Cucumber::WINDOWS
9
9
  if ENV['CUCUMBER_OUTPUT_ENCODING']
10
10
  Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
11
11
  elsif `cmd /c chcp` =~ /(\d+)/
12
- if [65000, 65001].include? $1.to_i
13
- Cucumber::CODEPAGE = 'UTF-8'
12
+ if [65_000, 65_001].include? Regexp.last_match(1).to_i
13
+ Cucumber::CODEPAGE = 'UTF-8'.freeze
14
14
  ENV['ANSICON_API'] = 'ruby'
15
15
  else
16
- Cucumber::CODEPAGE = "cp#{$1.to_i}"
16
+ Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}".freeze
17
17
  end
18
18
  else
19
- Cucumber::CODEPAGE = 'cp1252'
19
+ Cucumber::CODEPAGE = 'cp1252'.freeze
20
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.")
21
21
  end
22
22
 
23
23
  module Cucumber
24
24
  # @private
25
25
  module WindowsOutput
26
- def self.extended(o)
27
- o.instance_eval do
28
- def cucumber_preprocess_output(*a)
29
- begin
30
- a.map { |arg| arg.to_s.encode(Encoding.default_external) }
31
- rescue Encoding::UndefinedConversionError => e
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(*a)
39
- cucumber_print(*cucumber_preprocess_output(*a))
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(*a)
44
- cucumber_puts(*cucumber_preprocess_output(*a))
41
+ def puts(*out)
42
+ cucumber_puts(*cucumber_preprocess_output(*out))
45
43
  end
46
44
  end
47
45
  end
@@ -0,0 +1,17 @@
1
+ module Cucumber
2
+ module Formatter
3
+ class URLReporter
4
+ def initialize(io)
5
+ @io = io
6
+ end
7
+
8
+ def report(banner)
9
+ @io.puts(banner)
10
+ end
11
+ end
12
+
13
+ class NoReporter
14
+ def report(banner); end
15
+ end
16
+ end
17
+ 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.source] = step_match
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,25 +28,26 @@ module Cucumber
28
28
  end
29
29
 
30
30
  def on_step_match(event)
31
- @matches[event.test_step.source] = event.step_match
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 HookQueryVisitor.new(event.test_step).hook?
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.source]
40
+ step_match = @matches[test_step.to_s]
41
41
 
42
42
  unless step_match.nil?
43
43
  step_definition = step_match.step_definition
44
44
  stepdef_key = StepDefKey.new(step_definition.expression.to_s, step_definition.location)
45
45
  unless @stepdef_to_match[stepdef_key].map { |key| key[:location] }.include? test_step.location
46
46
  duration = DurationExtractor.new(result).result_duration
47
+ keyword = @ast_lookup.step_source(test_step).step.keyword
47
48
 
48
49
  @stepdef_to_match[stepdef_key] << {
49
- keyword: test_step.source.last.keyword,
50
+ keyword: keyword,
50
51
  step_match: step_match,
51
52
  status: result.to_sym,
52
53
  location: test_step.location,
@@ -64,9 +65,9 @@ module Cucumber
64
65
  aggregate_info
65
66
 
66
67
  keys = if config.dry_run?
67
- @stepdef_to_match.keys.sort { |a, b| a.regexp_source <=> b.regexp_source }
68
+ @stepdef_to_match.keys.sort_by(&:regexp_source)
68
69
  else
69
- @stepdef_to_match.keys.sort { |a, b| a.mean_duration <=> b.mean_duration }.reverse
70
+ @stepdef_to_match.keys.sort_by(&:mean_duration).reverse
70
71
  end
71
72
 
72
73
  keys.each do |stepdef_key|
@@ -83,7 +84,7 @@ module Cucumber
83
84
  end
84
85
 
85
86
  def print_step_definition(stepdef_key)
86
- @io.print format_string(format('%.7f', stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run?
87
+ @io.print format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped) + ' ' unless config.dry_run?
87
88
  @io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
88
89
  if config.source?
89
90
  indent = max_length - stepdef_key.regexp_source.unpack('U*').length
@@ -96,7 +97,7 @@ module Cucumber
96
97
  def print_steps(stepdef_key)
97
98
  @stepdef_to_match[stepdef_key].each do |step|
98
99
  @io.print ' '
99
- @io.print format_string(format('%.7f', step[:duration]), :skipped) + ' ' unless config.dry_run?
100
+ @io.print format_string(format('%<duration>.7f', duration: step[:duration]), :skipped) + ' ' unless config.dry_run?
100
101
  @io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
101
102
  if config.source?
102
103
  indent = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
@@ -135,7 +136,7 @@ module Cucumber
135
136
  end
136
137
 
137
138
  def worst_status(statuses)
138
- [:passed, :undefined, :pending, :skipped, :failed].find do |status|
139
+ %i[passed undefined pending skipped failed].find do |status|
139
140
  statuses.include?(status)
140
141
  end
141
142
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gherkin/token_scanner'
4
- require 'gherkin/parser'
3
+ require 'gherkin'
5
4
  require 'gherkin/dialect'
6
5
 
7
6
  module Cucumber
@@ -12,15 +11,27 @@ module Cucumber
12
11
  end
13
12
 
14
13
  def parse(text)
15
- token_scanner = ::Gherkin::TokenScanner.new(feature_header + text)
16
- parser = ::Gherkin::Parser.new
17
- gherkin_document = parser.parse(token_scanner)
14
+ gherkin_document = nil
15
+ messages = ::Gherkin.from_source('dummy', feature_header + text, gherkin_options)
18
16
 
19
- gherkin_document[:feature][:children][0][:steps][0][:argument][:rows].each do |row|
17
+ messages.each do |message|
18
+ gherkin_document = message.gherkin_document.to_hash unless message.gherkin_document.nil?
19
+ end
20
+
21
+ return if gherkin_document.nil?
22
+ gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row|
20
23
  @builder.row(row[:cells].map { |cell| cell[:value] })
21
24
  end
22
25
  end
23
26
 
27
+ def gherkin_options
28
+ {
29
+ include_source: false,
30
+ include_gherkin_document: true,
31
+ include_pickles: false
32
+ }
33
+ end
34
+
24
35
  def feature_header
25
36
  dialect = ::Gherkin::Dialect.for('en')
26
37
  %(#{dialect.feature_keywords[0]}:
@@ -51,23 +51,21 @@ module Cucumber
51
51
  'white' => "\e[37m",
52
52
  'grey' => "\e[90m",
53
53
  'bold' => "\e[1m"
54
- }
54
+ }.freeze
55
55
 
56
56
  ALIASES = Hash.new do |h, k|
57
- if k.to_s =~ /(.*)_arg/
58
- h[$1] + ',bold'
59
- end
60
- end.merge({
61
- 'undefined' => 'yellow',
62
- 'pending' => 'yellow',
63
- 'executing' => 'grey',
64
- 'failed' => 'red',
65
- 'passed' => 'green',
66
- 'outline' => 'cyan',
67
- 'skipped' => 'cyan',
68
- 'comments' => 'grey',
69
- 'tag' => 'cyan'
70
- })
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
+ )
71
69
 
72
70
  if ENV['GHERKIN_COLORS'] # Example: export GHERKIN_COLORS="passed=red:failed=yellow"
73
71
  ENV['GHERKIN_COLORS'].split(':').each do |pair|
@@ -93,8 +91,6 @@ module Cucumber
93
91
  def up(n)
94
92
  "\e[#{n}A"
95
93
  end
96
-
97
- extend self
98
94
  end
99
95
  end
100
96
  end
@@ -10,8 +10,8 @@ module Cucumber
10
10
  # * \ becomes \\
11
11
  #
12
12
  # This is used in the pretty formatter.
13
- def escape_cell(s)
14
- s.gsub(/\\(?!\|)/, '\\\\\\\\').gsub(/\n/, '\\n').gsub(/\|/, '\\|')
13
+ def escape_cell(sym)
14
+ sym.gsub(/\\(?!\|)/, '\\\\\\\\').gsub(/\n/, '\\n').gsub(/\|/, '\\|')
15
15
  end
16
16
  end
17
17
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gherkin/token_scanner'
4
- require 'gherkin/token_matcher'
5
- require 'gherkin/parser'
3
+ require 'gherkin'
6
4
  require 'gherkin/dialect'
7
5
 
8
6
  module Cucumber
@@ -15,12 +13,23 @@ module Cucumber
15
13
 
16
14
  def parse(text)
17
15
  dialect = ::Gherkin::Dialect.for(@language)
18
- token_matcher = ::Gherkin::TokenMatcher.new(@language)
19
- token_scanner = ::Gherkin::TokenScanner.new(feature_header(dialect) + text)
20
- parser = ::Gherkin::Parser.new
21
- gherkin_document = parser.parse(token_scanner, token_matcher)
16
+ gherkin_document = nil
17
+ messages = ::Gherkin.from_source('dummy', feature_header(dialect) + text, gherkin_options)
22
18
 
23
- @builder.steps(gherkin_document[:feature][:children][0][:steps])
19
+ messages.each do |message|
20
+ gherkin_document = message.gherkin_document.to_hash unless message.gherkin_document.nil?
21
+ end
22
+
23
+ @builder.steps(gherkin_document[:feature][:children][0][:scenario][:steps])
24
+ end
25
+
26
+ def gherkin_options
27
+ {
28
+ default_dialect: @language,
29
+ include_source: false,
30
+ include_gherkin_document: true,
31
+ include_pickles: false
32
+ }
24
33
  end
25
34
 
26
35
  def feature_header(dialect)
@@ -6,14 +6,15 @@ module Cucumber
6
6
  module Glue
7
7
  # TODO: Kill pointless wrapper for Before, After and AfterStep hooks with fire
8
8
  class Hook
9
- attr_reader :tag_expressions, :location
9
+ attr_reader :id, :tag_expressions, :location
10
10
 
11
- def initialize(registry, tag_expressions, proc)
11
+ def initialize(id, registry, tag_expressions, proc)
12
+ @id = id
12
13
  @registry = registry
13
- @tag_expressions = tag_expressions
14
+ @tag_expressions = sanitize_tag_expressions(tag_expressions)
14
15
  @proc = proc
15
- @location = Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
16
- warn_for_old_style_tag_expressions(tag_expressions)
16
+ @location = Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
17
+ fail_for_old_style_tag_expressions(@tag_expressions)
17
18
  end
18
19
 
19
20
  def invoke(pseudo_method, arguments, &block)
@@ -27,16 +28,38 @@ module Cucumber
27
28
  )
28
29
  end
29
30
 
31
+ def to_envelope
32
+ Cucumber::Messages::Envelope.new(
33
+ hook: Cucumber::Messages::Hook.new(
34
+ id: id,
35
+ tag_expression: tag_expressions.join(' '),
36
+ source_reference: Cucumber::Messages::SourceReference.new(
37
+ uri: location.file,
38
+ location: Cucumber::Messages::Location.new(
39
+ line: location.lines.first
40
+ )
41
+ )
42
+ )
43
+ )
44
+ end
45
+
30
46
  private
31
47
 
32
- def warn_for_old_style_tag_expressions(tag_expressions)
48
+ def sanitize_tag_expressions(tag_expressions)
49
+ # TODO: remove when '~@no-clobber' has been changed to 'not @no-clobber' in aruba
50
+ tag_expressions.map { |tag_expression| tag_expression == '~@no-clobber' ? 'not @no-clobber' : tag_expression }
51
+ end
52
+
53
+ def fail_for_old_style_tag_expressions(tag_expressions)
33
54
  tag_expressions.each do |tag_expression|
34
- if tag_expression.include?('~') && tag_expression != '~@no-clobber' # ~@no-clobber is used in aruba
35
- warn("Deprecated: Found tagged hook with '#{tag_expression}'. Support for '~@tag' will be removed from the next release of Cucumber. Please use 'not @tag' instead.")
36
- end
37
- if tag_expression.include?(',')
38
- warn("Deprecated: Found tagged hook with '#{tag_expression}'. Support for '@tag1,@tag2' will be removed from the next release of Cucumber. Please use '@tag or @tag2' instead.")
55
+ if tag_expression.include?('~')
56
+ raise("Found tagged hook with '#{tag_expression}'." \
57
+ "'~@tag' is no longer supported, use 'not @tag' instead.")
39
58
  end
59
+
60
+ next unless tag_expression.include?(',')
61
+ warn("Found tagged hook with '#{tag_expression}'." \
62
+ "'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
40
63
  end
41
64
  end
42
65
  end
@@ -11,16 +11,15 @@ module Cucumber
11
11
  return if Cucumber.use_full_backtrace
12
12
 
13
13
  instance_exec_pos = backtrace.index(instance_exec_invocation_line)
14
- if instance_exec_pos
15
- replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
16
- backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
14
+ return unless instance_exec_pos
15
+ replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
16
+ backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
17
17
 
18
- depth = backtrace.count { |line| line == instance_exec_invocation_line }
19
- end_pos = depth > 1 ? instance_exec_pos : -1
18
+ depth = backtrace.count { |line| line == instance_exec_invocation_line }
19
+ end_pos = depth > 1 ? instance_exec_pos : -1
20
20
 
21
- backtrace[replacement_line + 1..end_pos] = nil
22
- backtrace.compact!
23
- end
21
+ backtrace[replacement_line + 1..end_pos] = nil
22
+ backtrace.compact!
24
23
  end
25
24
 
26
25
  def self.cucumber_instance_exec_in(world, check_arity, pseudo_method, *args, &block)
@@ -31,9 +30,7 @@ module Cucumber
31
30
  ari = ari < 0 ? (ari.abs - 1).to_s + '+' : ari
32
31
  s1 = ari == 1 ? '' : 's'
33
32
  s2 = args.length == 1 ? '' : 's'
34
- raise ArityMismatchError.new(
35
- "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
36
- )
33
+ raise ArityMismatchError, "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
37
34
  end
38
35
  else
39
36
  world.instance_exec(*args, &block)
@@ -50,13 +47,11 @@ module Cucumber
50
47
  end
51
48
 
52
49
  def self.cucumber_run_with_backtrace_filtering(pseudo_method)
53
- begin
54
- yield
55
- rescue Exception => e
56
- instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
57
- replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
58
- raise e
59
- end
50
+ yield
51
+ rescue Exception => e # rubocop:disable Lint/RescueException
52
+ instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
53
+ replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
54
+ raise e
60
55
  end
61
56
 
62
57
  INSTANCE_EXEC_OFFSET = -3