cucumber 2.99.0 → 3.0.0.pre.1

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 (214) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -10
  3. data/CONTRIBUTING.md +13 -0
  4. data/Gemfile +11 -4
  5. data/History.md +19 -1
  6. data/README.md +1 -1
  7. data/cucumber.gemspec +2 -2
  8. data/cucumber.yml +2 -2
  9. data/features/docs/api/listen_for_events.feature +7 -6
  10. data/features/docs/cli/help.feature +8 -0
  11. data/features/docs/cli/retry_failing_tests.feature +51 -16
  12. data/features/docs/defining_steps/nested_steps_i18n.feature +2 -0
  13. data/features/docs/defining_steps/printing_messages.feature +0 -1
  14. data/features/docs/defining_steps/skip_scenario.feature +0 -34
  15. data/features/docs/extending_cucumber/custom_formatter.feature +2 -30
  16. data/features/docs/formatters/summary_formatter.feature +34 -0
  17. data/features/docs/gherkin/unicode_table.feature +1 -1
  18. data/features/docs/post_configuration_hook.feature +0 -16
  19. data/features/docs/writing_support_code/world.feature +129 -0
  20. data/features/lib/step_definitions/aruba_steps.rb +1 -0
  21. data/features/lib/step_definitions/cli_steps.rb +4 -0
  22. data/features/lib/step_definitions/cucumber_steps.rb +1 -0
  23. data/features/lib/step_definitions/iso-8859-1_steps.rb +1 -0
  24. data/features/lib/step_definitions/json_steps.rb +1 -0
  25. data/features/lib/step_definitions/junit_steps.rb +1 -0
  26. data/features/lib/step_definitions/language_steps.rb +1 -0
  27. data/features/lib/step_definitions/profile_steps.rb +1 -0
  28. data/features/lib/step_definitions/retry_steps.rb +32 -12
  29. data/features/lib/step_definitions/ruby_steps.rb +1 -0
  30. data/features/lib/step_definitions/wire_steps.rb +1 -0
  31. data/features/lib/support/env.rb +2 -1
  32. data/features/lib/support/fake_wire_server.rb +1 -0
  33. data/features/lib/support/feature_factory.rb +1 -0
  34. data/features/lib/support/normalise_output.rb +1 -0
  35. data/gem_tasks/contributors.rake +1 -0
  36. data/gem_tasks/cov.rake +1 -0
  37. data/gem_tasks/cucumber.rake +1 -0
  38. data/gem_tasks/downloads.rb +1 -0
  39. data/gem_tasks/environment.rake +1 -0
  40. data/gem_tasks/examples.rake +2 -1
  41. data/gem_tasks/fix_cr_lf.rake +2 -1
  42. data/gem_tasks/flog.rake +2 -1
  43. data/gem_tasks/rspec.rake +1 -0
  44. data/gem_tasks/sass.rake +2 -1
  45. data/lib/autotest/cucumber.rb +1 -0
  46. data/lib/autotest/cucumber_mixin.rb +1 -0
  47. data/lib/autotest/cucumber_rails.rb +1 -0
  48. data/lib/autotest/cucumber_rails_rspec.rb +1 -0
  49. data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
  50. data/lib/autotest/cucumber_rspec.rb +1 -0
  51. data/lib/autotest/cucumber_rspec2.rb +1 -0
  52. data/lib/autotest/discover.rb +1 -0
  53. data/lib/cucumber.rb +1 -13
  54. data/lib/cucumber/cli/configuration.rb +3 -6
  55. data/lib/cucumber/cli/main.rb +2 -1
  56. data/lib/cucumber/cli/options.rb +239 -173
  57. data/lib/cucumber/cli/profile_loader.rb +1 -0
  58. data/lib/cucumber/cli/rerun_file.rb +1 -0
  59. data/lib/cucumber/configuration.rb +40 -19
  60. data/lib/cucumber/constantize.rb +1 -0
  61. data/lib/cucumber/core_ext/instance_exec.rb +1 -0
  62. data/lib/cucumber/core_ext/string.rb +1 -0
  63. data/lib/cucumber/deprecate.rb +1 -0
  64. data/lib/cucumber/encoding.rb +1 -0
  65. data/lib/cucumber/errors.rb +3 -1
  66. data/lib/cucumber/events.rb +13 -3
  67. data/lib/cucumber/events/step_definition_registered.rb +24 -0
  68. data/lib/cucumber/events/step_match.rb +4 -1
  69. data/lib/cucumber/events/test_run_finished.rb +12 -0
  70. data/lib/cucumber/file_specs.rb +1 -0
  71. data/lib/cucumber/filters.rb +2 -0
  72. data/lib/cucumber/filters/activate_steps.rb +2 -1
  73. data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
  74. data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
  75. data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
  76. data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
  77. data/lib/cucumber/filters/gated_receiver.rb +1 -0
  78. data/lib/cucumber/filters/prepare_world.rb +1 -0
  79. data/lib/cucumber/filters/quit.rb +1 -0
  80. data/lib/cucumber/filters/randomizer.rb +1 -0
  81. data/lib/cucumber/filters/retry.rb +3 -3
  82. data/lib/cucumber/filters/tag_limits.rb +1 -0
  83. data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -0
  84. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -0
  85. data/lib/cucumber/formatter/ansicolor.rb +1 -0
  86. data/lib/cucumber/formatter/backtrace_filter.rb +3 -2
  87. data/lib/cucumber/formatter/console.rb +61 -52
  88. data/lib/cucumber/formatter/console_counts.rb +57 -0
  89. data/lib/cucumber/formatter/console_issues.rb +37 -0
  90. data/lib/cucumber/formatter/debug.rb +1 -0
  91. data/lib/cucumber/formatter/duration.rb +1 -0
  92. data/lib/cucumber/formatter/duration_extractor.rb +1 -0
  93. data/lib/cucumber/formatter/fail_fast.rb +4 -2
  94. data/lib/cucumber/formatter/fanout.rb +1 -0
  95. data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
  96. data/lib/cucumber/formatter/html.rb +6 -5
  97. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -0
  98. data/lib/cucumber/formatter/interceptor.rb +1 -0
  99. data/lib/cucumber/formatter/io.rb +1 -0
  100. data/lib/cucumber/formatter/json.rb +15 -13
  101. data/lib/cucumber/formatter/json_pretty.rb +1 -0
  102. data/lib/cucumber/formatter/junit.rb +13 -11
  103. data/lib/cucumber/formatter/legacy_api/adapter.rb +28 -32
  104. data/lib/cucumber/formatter/legacy_api/ast.rb +1 -0
  105. data/lib/cucumber/formatter/legacy_api/results.rb +1 -0
  106. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +1 -0
  107. data/lib/cucumber/formatter/pretty.rb +7 -1
  108. data/lib/cucumber/formatter/progress.rb +56 -13
  109. data/lib/cucumber/formatter/rerun.rb +15 -18
  110. data/lib/cucumber/formatter/stepdefs.rb +1 -0
  111. data/lib/cucumber/formatter/steps.rb +1 -0
  112. data/lib/cucumber/formatter/summary.rb +43 -20
  113. data/lib/cucumber/formatter/unicode.rb +1 -0
  114. data/lib/cucumber/formatter/usage.rb +26 -21
  115. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  116. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -0
  117. data/lib/cucumber/gherkin/formatter/escaping.rb +1 -0
  118. data/lib/cucumber/gherkin/i18n.rb +1 -0
  119. data/lib/cucumber/gherkin/steps_parser.rb +1 -0
  120. data/lib/cucumber/hooks.rb +1 -0
  121. data/lib/cucumber/load_path.rb +1 -0
  122. data/lib/cucumber/multiline_argument.rb +1 -2
  123. data/lib/cucumber/multiline_argument/data_table.rb +3 -1
  124. data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
  125. data/lib/cucumber/platform.rb +1 -0
  126. data/lib/cucumber/project_initializer.rb +2 -1
  127. data/lib/cucumber/rake/task.rb +1 -0
  128. data/lib/cucumber/rb_support/rb_dsl.rb +11 -9
  129. data/lib/cucumber/rb_support/rb_hook.rb +1 -0
  130. data/lib/cucumber/rb_support/rb_language.rb +19 -8
  131. data/lib/cucumber/rb_support/rb_step_definition.rb +1 -0
  132. data/lib/cucumber/rb_support/rb_transform.rb +1 -0
  133. data/lib/cucumber/rb_support/rb_world.rb +42 -20
  134. data/lib/cucumber/rb_support/snippet.rb +2 -1
  135. data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
  136. data/lib/cucumber/rspec/doubles.rb +1 -0
  137. data/lib/cucumber/running_test_case.rb +1 -25
  138. data/lib/cucumber/runtime.rb +15 -10
  139. data/lib/cucumber/runtime/after_hooks.rb +1 -0
  140. data/lib/cucumber/runtime/before_hooks.rb +1 -0
  141. data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
  142. data/lib/cucumber/runtime/step_hooks.rb +1 -0
  143. data/lib/cucumber/runtime/support_code.rb +1 -0
  144. data/lib/cucumber/runtime/user_interface.rb +1 -0
  145. data/lib/cucumber/step_argument.rb +1 -0
  146. data/lib/cucumber/step_definition_light.rb +1 -0
  147. data/lib/cucumber/step_definitions.rb +1 -0
  148. data/lib/cucumber/step_match.rb +1 -0
  149. data/lib/cucumber/step_match_search.rb +1 -0
  150. data/lib/cucumber/term/ansicolor.rb +1 -0
  151. data/lib/cucumber/unit.rb +1 -0
  152. data/lib/cucumber/version +1 -1
  153. data/lib/simplecov_setup.rb +1 -0
  154. data/spec/cucumber/cli/configuration_spec.rb +1 -0
  155. data/spec/cucumber/cli/main_spec.rb +1 -0
  156. data/spec/cucumber/cli/options_spec.rb +1 -0
  157. data/spec/cucumber/cli/profile_loader_spec.rb +1 -0
  158. data/spec/cucumber/cli/rerun_spec.rb +1 -0
  159. data/spec/cucumber/configuration_spec.rb +1 -0
  160. data/spec/cucumber/constantize_spec.rb +1 -0
  161. data/spec/cucumber/core_ext/instance_exec_spec.rb +1 -0
  162. data/spec/cucumber/file_specs_spec.rb +1 -0
  163. data/spec/cucumber/filters/activate_steps_spec.rb +9 -6
  164. data/spec/cucumber/filters/gated_receiver_spec.rb +1 -0
  165. data/spec/cucumber/filters/retry_spec.rb +27 -21
  166. data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +1 -0
  167. data/spec/cucumber/filters/tag_limits/verifier_spec.rb +1 -0
  168. data/spec/cucumber/filters/tag_limits_spec.rb +1 -0
  169. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -0
  170. data/spec/cucumber/formatter/console_counts_spec.rb +14 -0
  171. data/spec/cucumber/formatter/debug_spec.rb +1 -0
  172. data/spec/cucumber/formatter/duration_spec.rb +1 -0
  173. data/spec/cucumber/formatter/fail_fast_spec.rb +5 -5
  174. data/spec/cucumber/formatter/html_spec.rb +6 -1
  175. data/spec/cucumber/formatter/interceptor_spec.rb +1 -0
  176. data/spec/cucumber/formatter/json_spec.rb +29 -28
  177. data/spec/cucumber/formatter/junit_spec.rb +1 -0
  178. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +8 -3
  179. data/spec/cucumber/formatter/pretty_spec.rb +1 -0
  180. data/spec/cucumber/formatter/progress_spec.rb +2 -1
  181. data/spec/cucumber/formatter/rerun_spec.rb +70 -64
  182. data/spec/cucumber/formatter/spec_helper.rb +8 -7
  183. data/spec/cucumber/hooks_spec.rb +1 -0
  184. data/spec/cucumber/multiline_argument/data_table_spec.rb +1 -0
  185. data/spec/cucumber/project_initializer_spec.rb +2 -1
  186. data/spec/cucumber/rake/forked_spec.rb +1 -0
  187. data/spec/cucumber/rake/task_spec.rb +1 -0
  188. data/spec/cucumber/rb_support/rb_language_spec.rb +81 -3
  189. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +1 -0
  190. data/spec/cucumber/rb_support/rb_transform_spec.rb +1 -0
  191. data/spec/cucumber/rb_support/rb_world_spec.rb +2 -1
  192. data/spec/cucumber/rb_support/snippet_spec.rb +1 -0
  193. data/spec/cucumber/running_test_case_spec.rb +1 -0
  194. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -0
  195. data/spec/cucumber/runtime/support_code_spec.rb +1 -0
  196. data/spec/cucumber/runtime_spec.rb +1 -0
  197. data/spec/cucumber/step_argument_spec.rb +1 -0
  198. data/spec/cucumber/step_match_search_spec.rb +1 -0
  199. data/spec/cucumber/step_match_spec.rb +1 -0
  200. data/spec/cucumber/world/pending_spec.rb +1 -0
  201. data/spec/spec_helper.rb +1 -0
  202. data/spec/support/standard_step_actions.rb +1 -0
  203. metadata +24 -23
  204. data/lib/cucumber/ast.rb +0 -13
  205. data/lib/cucumber/events/after_test_case.rb +0 -25
  206. data/lib/cucumber/events/after_test_step.rb +0 -30
  207. data/lib/cucumber/events/before_test_case.rb +0 -18
  208. data/lib/cucumber/events/before_test_step.rb +0 -23
  209. data/lib/cucumber/events/bus.rb +0 -86
  210. data/lib/cucumber/events/finished_testing.rb +0 -9
  211. data/lib/cucumber/formatter/event_bus_report.rb +0 -38
  212. data/spec/cucumber/events/bus_spec.rb +0 -94
  213. data/spec/cucumber/formatter/event_bus_report_spec.rb +0 -88
  214. data/spec/cucumber_spec.rb +0 -39
@@ -1,4 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require 'cucumber/core/report/summary'
3
+ require 'cucumber/formatter/backtrace_filter'
1
4
  require 'cucumber/formatter/console'
5
+ require 'cucumber/formatter/console_counts'
6
+ require 'cucumber/formatter/console_issues'
2
7
  require 'cucumber/formatter/io'
3
8
  require 'cucumber/formatter/duration_extractor'
4
9
  require 'cucumber/formatter/hook_query_visitor'
@@ -10,32 +15,60 @@ module Cucumber
10
15
  include Console
11
16
  include Io
12
17
  attr_reader :runtime
18
+ attr_reader :config, :summary
13
19
 
14
- def initialize(runtime, path_or_io, options)
15
- @runtime, @io, @options = runtime, ensure_io(path_or_io), options
20
+ def initialize(config)
21
+ @config, @io = config, ensure_io(config.out_stream)
16
22
  @previous_step_keyword = nil
17
23
  @snippets_input = []
18
24
  @total_duration = 0
25
+ @summary = Cucumber::Core::Report::Summary.new(config.event_bus)
26
+ @matches = {}
27
+ @pending_step_matches = []
28
+ @failed_results = []
29
+ @failed_test_cases = []
30
+ @passed_test_cases = []
31
+ @counts = ConsoleCounts.new(config)
32
+ @issues = ConsoleIssues.new(config)
33
+ config.on_event :step_match, &method(:on_step_match)
34
+ config.on_event :test_case_starting, &method(:on_test_case_starting)
35
+ config.on_event :test_step_finished, &method(:on_test_step_finished)
36
+ config.on_event :test_case_finished, &method(:on_test_case_finished)
37
+ config.on_event :test_run_finished, &method(:on_test_run_finished)
19
38
  end
20
39
 
21
- def before_test_case(_test_case)
40
+ def on_step_match(event)
41
+ @matches[event.test_step.source] = event.step_match
42
+ end
43
+
44
+ def on_test_case_starting(_event)
22
45
  unless @profile_information_printed
23
- print_profile_information
46
+ do_print_profile_information(config.profiles) unless config.skip_profile_information? || config.profiles.nil? || config.profiles.empty?
24
47
  @profile_information_printed = true
25
48
  end
26
49
  @previous_step_keyword = nil
27
50
  end
28
51
 
29
- def after_test_step(test_step, result)
52
+ def on_test_step_finished(event)
53
+ test_step = event.test_step
54
+ result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
30
55
  progress(result.to_sym) if !HookQueryVisitor.new(test_step).hook? || result.failed?
31
- collect_snippet_data(test_step, result) unless HookQueryVisitor.new(test_step).hook?
56
+ unless HookQueryVisitor.new(test_step).hook?
57
+ collect_snippet_data(test_step, result)
58
+ @pending_step_matches << @matches[test_step.source] if result.pending?
59
+ @failed_results << result if result.failed?
60
+ end
32
61
  end
33
62
 
34
- def after_test_case(_test_case, result)
63
+ def on_test_case_finished(event)
64
+ test_case = event.test_case
65
+ result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
66
+ @failed_test_cases << test_case if result.failed?
67
+ @passed_test_cases << test_case if result.passed?
35
68
  @total_duration += DurationExtractor.new(result).result_duration
36
69
  end
37
70
 
38
- def done
71
+ def on_test_run_finished(_event)
39
72
  @io.puts
40
73
  @io.puts
41
74
  print_summary
@@ -44,11 +77,19 @@ module Cucumber
44
77
  private
45
78
 
46
79
  def print_summary
47
- print_steps(:pending)
48
- print_steps(:failed)
49
- print_statistics(@total_duration, @options)
50
- print_snippets(@options)
51
- print_passing_wip(@options)
80
+ print_elements(@pending_step_matches, :pending, 'steps')
81
+ print_elements(@failed_results, :failed, 'steps')
82
+ print_statistics(@total_duration, @config, @counts, @issues)
83
+ snippet_text_proc = lambda { |step_keyword, step_name, multiline_arg|
84
+ snippet_text(step_keyword, step_name, multiline_arg)
85
+ }
86
+ do_print_snippets(snippet_text_proc) if config.snippets? && summary.test_steps.total(:undefined) > 0
87
+ if config.wip?
88
+ messages = @passed_test_cases.map do |test_case|
89
+ message = linebreaks("#{test_case.location.on_line(test_case.location.line)}:in `#{test_case.name}'", ENV['CUCUMBER_TRUNCATE_OUTPUT'].to_i)
90
+ end
91
+ do_print_passing_wip(messages)
92
+ end
52
93
  end
53
94
 
54
95
  CHARS = {
@@ -68,6 +109,8 @@ module Cucumber
68
109
  def table_header_cell?(status)
69
110
  status == :skipped_param
70
111
  end
112
+
113
+ TestCaseData = Struct.new(:name, :location)
71
114
  end
72
115
  end
73
116
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/io'
2
3
 
3
4
  module Cucumber
@@ -5,28 +6,24 @@ module Cucumber
5
6
  class Rerun
6
7
  include Formatter::Io
7
8
 
8
- def initialize(runtime, path_or_io, options)
9
- @io = ensure_io(path_or_io)
9
+ def initialize(config)
10
+ @io = ensure_io(config.out_stream)
11
+ @config = config
10
12
  @failures = {}
11
- @options = options
12
- end
13
-
14
- def after_test_case(test_case, result)
15
- return if result.ok?(@options[:strict])
16
- @failures[test_case.location.file] ||= []
17
- @failures[test_case.location.file] << test_case.location.line
18
- end
19
-
20
- def done
21
- return if @failures.empty?
22
- @io.print file_failures.join(' ')
23
- end
24
-
25
- [:before_test_case, :before_test_step, :after_test_step].each do |method|
26
- define_method(method) { |*| }
13
+ config.on_event :test_case_finished do |event|
14
+ test_case, result = *event.attributes
15
+ next if result.ok?(@config.strict?)
16
+ @failures[test_case.location.file] ||= []
17
+ @failures[test_case.location.file] << test_case.location.line
18
+ end
19
+ config.on_event :test_run_finished do
20
+ next if @failures.empty?
21
+ @io.print file_failures.join(' ')
22
+ end
27
23
  end
28
24
 
29
25
  private
26
+
30
27
  def file_failures
31
28
  @failures.map { |file, lines| [file, lines].join(':') }
32
29
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/usage'
2
3
 
3
4
  module Cucumber
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Formatter
3
4
  # The formatter used for <tt>--format steps</tt>
@@ -1,35 +1,58 @@
1
+ # frozen_string_literal: true
2
+ require 'cucumber/formatter/io'
3
+ require 'cucumber/formatter/console'
4
+ require 'cucumber/formatter/console_counts'
5
+ require 'cucumber/formatter/console_issues'
6
+ require 'cucumber/core/test/result'
7
+
1
8
  module Cucumber
2
9
  module Formatter
3
- module Summary
4
10
 
5
- def scenario_summary(runtime, &block)
6
- scenarios_proc = lambda{|status| runtime.scenarios(status)}
7
- dump_count(runtime.scenarios.length, "scenario") + dump_status_counts(scenarios_proc, &block)
8
- end
11
+ # Summary formatter, outputting only feature / scenario titles
12
+ class Summary
13
+ include Io
14
+ include Console
15
+
16
+ def initialize(config)
17
+ @config, @io = config, ensure_io(config.out_stream)
18
+ @counts = ConsoleCounts.new(@config)
19
+ @issues = ConsoleIssues.new(@config)
20
+ @start_time = Time.now
9
21
 
10
- def step_summary(runtime, &block)
11
- steps_proc = lambda{|status| runtime.steps(status)}
12
- dump_count(runtime.steps.length, "step") + dump_status_counts(steps_proc, &block)
22
+ @config.on_event :test_case_starting do |event|
23
+ print_feature event.test_case
24
+ print_test_case event.test_case
25
+ end
26
+
27
+ @config.on_event :test_case_finished do |event|
28
+ print_result event.result
29
+ end
30
+
31
+ @config.on_event :test_run_finished do |event|
32
+ duration = Time.now - @start_time
33
+ @io.puts
34
+ print_statistics(duration, @config, @counts, @issues)
35
+ end
13
36
  end
14
37
 
15
38
  private
16
39
 
17
- def dump_status_counts(find_elements_proc)
18
- counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status|
19
- elements = find_elements_proc.call(status)
20
- elements.any? ? yield("#{elements.length} #{status.to_s}", status) : nil
21
- end.compact
22
- if counts.any?
23
- " (#{counts.join(', ')})"
24
- else
25
- ""
26
- end
40
+ 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
27
46
  end
28
47
 
29
- def dump_count(count, what, state=nil)
30
- [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ")
48
+ def print_test_case(test_case)
49
+ @io.print " #{test_case.name} "
31
50
  end
32
51
 
52
+ def print_result(result)
53
+ @io.puts format_string(result, result.to_sym)
54
+ end
33
55
  end
34
56
  end
35
57
  end
58
+
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Require this file if you need Unicode support.
2
3
  # Tips for improvement - esp. ruby 1.9: http://www.ruby-forum.com/topic/184730
3
4
  require 'cucumber/platform'
@@ -1,30 +1,42 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/formatter/progress'
2
3
  require 'cucumber/step_definition_light'
3
4
 
4
5
  module Cucumber
5
6
  module Formatter
6
7
  class Usage < Progress
7
- include Console
8
8
 
9
9
  class StepDefKey < StepDefinitionLight
10
10
  attr_accessor :mean_duration, :status
11
11
  end
12
12
 
13
- def initialize(runtime, path_or_io, options)
14
- @runtime = runtime
15
- @io = ensure_io(path_or_io)
16
- @options = options
13
+ def initialize(config)
14
+ super
17
15
  @stepdef_to_match = Hash.new { |h, stepdef_key| h[stepdef_key] = [] }
18
16
  @total_duration = 0
19
17
  @matches = {}
20
- runtime.configuration.on_event :step_match do |event|
21
- @matches[event.test_step.source] = event.step_match
18
+ config.on_event :step_match do |event|
19
+ test_step, step_match = *event.attributes
20
+ @matches[test_step.source] = step_match
22
21
  end
22
+ config.on_event :step_definition_registered, &method(:on_step_definition_registered)
23
+ end
24
+
25
+ def on_step_definition_registered(event)
26
+ stepdef_key = StepDefKey.new(event.step_definition.regexp_source, event.step_definition.location)
27
+ @stepdef_to_match[stepdef_key] = []
28
+ end
29
+
30
+ def on_step_match(event)
31
+ @matches[event.test_step.source] = event.step_match
32
+ super
23
33
  end
24
34
 
25
- def after_test_step(test_step, result)
26
- return if HookQueryVisitor.new(test_step).hook?
35
+ def on_test_step_finished(event)
36
+ return if HookQueryVisitor.new(event.test_step).hook?
27
37
 
38
+ test_step = event.test_step
39
+ result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
28
40
  step_match = @matches[test_step.source]
29
41
  step_definition = step_match.step_definition
30
42
  stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.location)
@@ -45,10 +57,9 @@ module Cucumber
45
57
  private
46
58
 
47
59
  def print_summary
48
- add_unused_stepdefs
49
60
  aggregate_info
50
61
 
51
- if @options[:dry_run]
62
+ if config.dry_run?
52
63
  keys = @stepdef_to_match.keys.sort {|a,b| a.regexp_source <=> b.regexp_source}
53
64
  else
54
65
  keys = @stepdef_to_match.keys.sort {|a,b| a.mean_duration <=> b.mean_duration}.reverse
@@ -68,9 +79,9 @@ module Cucumber
68
79
  end
69
80
 
70
81
  def print_step_definition(stepdef_key)
71
- @io.print format_string(sprintf("%.7f", stepdef_key.mean_duration), :skipped) + " " unless @options[:dry_run]
82
+ @io.print format_string(sprintf("%.7f", stepdef_key.mean_duration), :skipped) + " " unless config.dry_run?
72
83
  @io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
73
- if @options[:source]
84
+ if config.source?
74
85
  indent = max_length - stepdef_key.regexp_source.unpack('U*').length
75
86
  line_comment = " # #{stepdef_key.location}".indent(indent)
76
87
  @io.print(format_string(line_comment, :comment))
@@ -81,9 +92,9 @@ module Cucumber
81
92
  def print_steps(stepdef_key)
82
93
  @stepdef_to_match[stepdef_key].each do |step|
83
94
  @io.print " "
84
- @io.print format_string(sprintf("%.7f", step[:duration]), :skipped) + " " unless @options[:dry_run]
95
+ @io.print format_string(sprintf("%.7f", step[:duration]), :skipped) + " " unless config.dry_run?
85
96
  @io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
86
- if @options[:source]
97
+ if config.source?
87
98
  indent = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
88
99
  line_comment = " # #{step[:location]}".indent(indent)
89
100
  @io.print(format_string(line_comment, :comment))
@@ -125,12 +136,6 @@ module Cucumber
125
136
  end
126
137
  end
127
138
 
128
- def add_unused_stepdefs
129
- @runtime.unmatched_step_definitions.each do |step_definition|
130
- stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.location)
131
- @stepdef_to_match[stepdef_key] = []
132
- end
133
- end
134
139
  end
135
140
  end
136
141
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'gherkin/token_scanner'
2
3
  require 'gherkin/parser'
3
4
  require 'gherkin/dialect'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Gherkin
3
4
  module Formatter
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Gherkin
3
4
  module Formatter
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module Gherkin
3
4
  module I18n
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'gherkin/token_scanner'
2
3
  require 'gherkin/token_matcher'
3
4
  require 'gherkin/parser'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'pathname'
2
3
  require 'cucumber/core/ast/location'
3
4
  require 'cucumber/core/test/around_hook'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module LoadPath
3
4
  def add_dirs(*dirs)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'delegate'
2
3
  require 'cucumber/multiline_argument/data_table'
3
4
  require 'cucumber/multiline_argument/doc_string'
@@ -67,5 +68,3 @@ module Cucumber
67
68
  end
68
69
  end
69
70
  end
70
-
71
- require 'cucumber/ast'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'forwardable'
2
3
  require 'cucumber/gherkin/data_table_parser'
3
4
  require 'cucumber/gherkin/formatter/escaping'
@@ -469,7 +470,8 @@ module Cucumber
469
470
 
470
471
  c = Cucumber::Term::ANSIColor.coloring?
471
472
  Cucumber::Term::ANSIColor.coloring = options[:color]
472
- formatter = Formatter::Pretty.new(nil, io, options)
473
+ runtime = Struct.new(:configuration).new(Configuration.new)
474
+ formatter = Formatter::Pretty.new(runtime, io, options)
473
475
  formatter.instance_variable_set('@indent', options[:indent])
474
476
  Formatter::LegacyApi::Ast::MultilineArg.for(self).accept(Formatter::Fanout.new([formatter]))
475
477
  Cucumber::Term::ANSIColor.coloring = c
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
  module MultilineArgument
3
4
  class DocString < SimpleDelegator
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Detect the platform we're running on so we can tweak behaviour
2
3
  # in various places.
3
4
  require 'rbconfig'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Cucumber
2
3
 
3
4
  # Generates generic file structure for a cucumber project
@@ -40,4 +41,4 @@ module Cucumber
40
41
  puts " create #{file}"
41
42
  end
42
43
  end
43
- end
44
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cucumber/platform'
2
3
  require 'cucumber/gherkin/formatter/ansi_escapes'
3
4
  begin