cucumber 3.0.0.pre.1 → 3.0.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. checksums.yaml +4 -4
  2. data/.cucumberproignore +6 -0
  3. data/.rubocop.yml +13 -0
  4. data/.rubocop_todo.yml +1075 -0
  5. data/.travis.yml +42 -8
  6. data/CONTRIBUTING.md +8 -1
  7. data/Gemfile +16 -10
  8. data/History.md +96 -36
  9. data/README.md +12 -3
  10. data/Rakefile +12 -2
  11. data/appveyor.yml +26 -0
  12. data/cucumber.gemspec +15 -10
  13. data/cucumber.yml +9 -10
  14. data/examples/i18n/Rakefile +1 -1
  15. data/examples/i18n/ar/features/step_definitions/calculator_steps.rb +2 -2
  16. data/examples/i18n/ar/lib/calculator.rb +2 -2
  17. data/examples/i18n/bg/features/step_definitions/calculator_steps.rb +6 -6
  18. data/examples/i18n/ca/features/step_definitions/calculator_steps.rb +4 -4
  19. data/examples/i18n/ca/lib/calculadora.rb +2 -2
  20. data/examples/i18n/cs/features/step_definitions/calculator_steps.rb +4 -4
  21. data/examples/i18n/cs/lib/calculator.rb +3 -3
  22. data/examples/i18n/da/features/step_definitions/lommeregner_steps.rb +4 -4
  23. data/examples/i18n/da/lib/lommeregner.rb +2 -2
  24. data/examples/i18n/de/features/step_definitions/calculator_steps.rb +4 -4
  25. data/examples/i18n/de/lib/calculator.rb +2 -2
  26. data/examples/i18n/el/features/step_definitions/calculator_steps.rb +5 -5
  27. data/examples/i18n/el/lib/calculator.rb +2 -2
  28. data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +4 -4
  29. data/examples/i18n/en-lol/lib/basket.rb +2 -2
  30. data/examples/i18n/en-lol/lib/belly.rb +2 -2
  31. data/examples/i18n/en/features/step_definitions/calculator_steps.rb +4 -4
  32. data/examples/i18n/en/lib/calculator.rb +2 -2
  33. data/examples/i18n/eo/features/step_definitions/calculator_steps.rb +4 -4
  34. data/examples/i18n/eo/lib/calculator.rb +2 -2
  35. data/examples/i18n/es/features/step_definitions/calculador_steps.rb +5 -5
  36. data/examples/i18n/es/lib/calculador.rb +2 -2
  37. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +4 -4
  38. data/examples/i18n/et/lib/kalkulaator.rb +3 -3
  39. data/examples/i18n/fi/features/step_definitions/laskin_steps.rb +3 -3
  40. data/examples/i18n/fi/lib/laskin.rb +1 -1
  41. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +8 -8
  42. data/examples/i18n/fr/features/support/env.rb +1 -1
  43. data/examples/i18n/fr/lib/calculatrice.rb +2 -2
  44. data/examples/i18n/he/features/step_definitions/calculator_steps.rb +4 -4
  45. data/examples/i18n/he/lib/calculator.rb +1 -1
  46. data/examples/i18n/hi/features/step_definitions/calculator_steps.rb +3 -3
  47. data/examples/i18n/hi/lib/calculator.rb +1 -1
  48. data/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +4 -4
  49. data/examples/i18n/ht/lib/kalkilatris.rb +2 -2
  50. data/examples/i18n/hu/features/step_definitions/calculator_steps.rb +4 -4
  51. data/examples/i18n/hu/lib/calculator.rb +1 -1
  52. data/examples/i18n/id/features/step_definitions/calculator_steps.rb +4 -4
  53. data/examples/i18n/id/lib/calculator.rb +2 -2
  54. data/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb +4 -4
  55. data/examples/i18n/it/lib/calcolatrice.rb +3 -3
  56. data/examples/i18n/ja/features/step_definitions/calculator_steps.rb +3 -3
  57. data/examples/i18n/ja/features/support/env.rb +1 -1
  58. data/examples/i18n/ja/lib/calculator.rb +2 -2
  59. data/examples/i18n/ko/features/step_definitions/calculator_steps.rb +4 -4
  60. data/examples/i18n/ko/lib/calculator.rb +2 -2
  61. data/examples/i18n/lt/features/step_definitions/calculator_steps.rb +4 -4
  62. data/examples/i18n/lt/lib/calculator.rb +2 -2
  63. data/examples/i18n/lv/features/step_definitions/calculator_steps.rb +4 -4
  64. data/examples/i18n/lv/lib/calculator.rb +2 -2
  65. data/examples/i18n/no/features/step_definitions/kalkulator_steps.rb +3 -3
  66. data/examples/i18n/no/features/support/env.rb +1 -1
  67. data/examples/i18n/no/lib/kalkulator.rb +2 -2
  68. data/examples/i18n/pl/features/step_definitions/calculator_steps.rb +4 -4
  69. data/examples/i18n/pl/lib/calculator.rb +2 -2
  70. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -3
  71. data/examples/i18n/pt/features/support/env.rb +1 -1
  72. data/examples/i18n/pt/lib/calculadora.rb +1 -1
  73. data/examples/i18n/ro/features/step_definitions/calculator_steps.rb +5 -5
  74. data/examples/i18n/ro/lib/calculator.rb +1 -1
  75. data/examples/i18n/ru/features/step_definitions/calculator_steps.rb +5 -5
  76. data/examples/i18n/sk/features/step_definitions/calculator_steps.rb +4 -4
  77. data/examples/i18n/sk/lib/calculator.rb +2 -2
  78. data/examples/i18n/sr-Cyrl/features/step_definitions/calculator_steps.rb +3 -3
  79. data/examples/i18n/sr-Cyrl/features/support/env.rb +1 -1
  80. data/examples/i18n/sr-Cyrl/lib/calculator.rb +2 -2
  81. data/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb +4 -4
  82. data/examples/i18n/sr-Latn/lib/calculator.rb +2 -2
  83. data/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb +3 -3
  84. data/examples/i18n/sv/lib/kalkulator.rb +2 -2
  85. data/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb +4 -4
  86. data/examples/i18n/tr/lib/hesap_makinesi.rb +2 -2
  87. data/examples/i18n/uk/features/step_definitions/calculator_steps.rb +4 -4
  88. data/examples/i18n/uz/features/step_definitions/calculator_steps.rb +4 -4
  89. data/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb +5 -5
  90. data/examples/i18n/zh-CN/lib/calculator.rb +2 -2
  91. data/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb +4 -4
  92. data/examples/i18n/zh-TW/lib/calculator.rb +2 -2
  93. data/examples/rspec_doubles/features/step_definitions/calvin_steps.rb +3 -3
  94. data/examples/sinatra/features/step_definitions/add_steps.rb +4 -4
  95. data/examples/tcl/features/step_definitions/fib_steps.rb +2 -2
  96. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +4 -4
  97. data/examples/watir/features/step_definitions/search_steps.rb +3 -3
  98. data/examples/watir/features/support/screenshots.rb +5 -5
  99. data/features/docs/api/list_step_defs_as_json.feature +21 -7
  100. data/features/docs/api/listen_for_events.feature +1 -1
  101. data/features/docs/api/run_cli_main_with_existing_runtime.feature +1 -0
  102. data/features/docs/cli/dry_run.feature +3 -0
  103. data/features/docs/cli/execute_with_tag_filter.feature +4 -4
  104. data/features/docs/cli/fail_fast.feature +2 -0
  105. data/features/docs/{gherkin/language_help.feature → cli/i18n.feature} +6 -6
  106. data/features/docs/cli/randomize.feature +2 -2
  107. data/features/docs/cli/retry_failing_tests.feature +28 -3
  108. data/features/docs/cli/run_scenarios_matching_name.feature +1 -0
  109. data/features/docs/cli/specifying_multiple_formatters.feature +3 -0
  110. data/features/docs/cli/strict_mode.feature +6 -0
  111. data/features/docs/defining_steps/nested_steps.feature +5 -1
  112. data/features/docs/defining_steps/nested_steps_i18n.feature +1 -0
  113. data/features/docs/defining_steps/nested_steps_with_second_arg.feature +2 -0
  114. data/features/docs/defining_steps/printing_messages.feature +1 -1
  115. data/features/docs/defining_steps/skip_scenario.feature +1 -0
  116. data/features/docs/defining_steps/snippets.feature +18 -18
  117. data/features/docs/events/gherkin_source_read_event.feature +43 -0
  118. data/features/docs/events/step_activated_event.feature +36 -0
  119. data/features/docs/events/step_definition_registered_event.feature +29 -0
  120. data/features/docs/events/test_case_finished_event.feature +35 -0
  121. data/features/docs/events/test_case_starting_event.feature +54 -0
  122. data/features/docs/events/test_run_finished_event.feature +40 -0
  123. data/features/docs/events/test_run_starting_event.feature +41 -0
  124. data/features/docs/events/test_step_finished_event.feature +47 -0
  125. data/features/docs/events/test_step_starting_event.feature +43 -0
  126. data/features/docs/exception_in_after_hook.feature +3 -2
  127. data/features/docs/exception_in_after_step_hook.feature +2 -0
  128. data/features/docs/exception_in_around_hook.feature +2 -0
  129. data/features/docs/exception_in_before_hook.feature +3 -1
  130. data/features/docs/extending_cucumber/custom_formatter.feature +21 -1
  131. data/features/docs/formatters/json_formatter.feature +4 -4
  132. data/features/docs/formatters/junit_formatter.feature +7 -6
  133. data/features/docs/formatters/pretty_formatter.feature +1 -0
  134. data/features/docs/formatters/progress_formatter.feature +1 -0
  135. data/features/docs/formatters/rerun_formatter.feature +2 -0
  136. data/features/docs/formatters/summary_formatter.feature +1 -0
  137. data/features/docs/formatters/usage_formatter.feature +3 -0
  138. data/features/docs/getting_started.feature +2 -1
  139. data/features/docs/gherkin/background.feature +5 -5
  140. data/features/docs/gherkin/doc_strings.feature +2 -0
  141. data/features/docs/gherkin/expand_option_for_outlines.feature +1 -0
  142. data/features/docs/gherkin/outlines.feature +4 -0
  143. data/features/docs/gherkin/unicode_table.feature +1 -0
  144. data/features/docs/gherkin/using_descriptions.feature +1 -0
  145. data/features/docs/gherkin/using_star_notation.feature +1 -1
  146. data/features/docs/post_configuration_hook.feature +1 -1
  147. data/features/docs/rake_task.feature +5 -0
  148. data/features/docs/raketask.feature +3 -1
  149. data/features/docs/work_in_progress.feature +5 -2
  150. data/features/docs/writing_support_code/after_step_hooks.feature +3 -1
  151. data/features/docs/writing_support_code/around_hooks.feature +6 -0
  152. data/features/docs/writing_support_code/before_hook.feature +1 -0
  153. data/features/docs/writing_support_code/hook_order.feature +3 -1
  154. data/features/docs/writing_support_code/parameter_types.feature +75 -0
  155. data/features/docs/writing_support_code/tagged_hooks.feature +1 -1
  156. data/features/lib/step_definitions/aruba_steps.rb +4 -10
  157. data/features/lib/step_definitions/cli_steps.rb +2 -2
  158. data/features/lib/step_definitions/cucumber_steps.rb +8 -12
  159. data/features/lib/step_definitions/iso-8859-1_steps.rb +2 -2
  160. data/features/lib/step_definitions/json_steps.rb +1 -1
  161. data/features/lib/step_definitions/junit_steps.rb +1 -1
  162. data/features/lib/step_definitions/language_steps.rb +2 -2
  163. data/features/lib/step_definitions/profile_steps.rb +6 -6
  164. data/features/lib/step_definitions/retry_steps.rb +3 -3
  165. data/features/lib/step_definitions/ruby_steps.rb +1 -1
  166. data/features/lib/support/env.rb +1 -1
  167. data/features/lib/support/fake_wire_server.rb +7 -2
  168. data/features/lib/support/feature_factory.rb +1 -1
  169. data/features/lib/support/normalise_output.rb +13 -12
  170. data/features/lib/support/parameter_types.rb +8 -0
  171. data/gem_tasks/contributors.rake +9 -6
  172. data/gem_tasks/environment.rake +1 -5
  173. data/gem_tasks/examples.rake +1 -1
  174. data/gem_tasks/fix_cr_lf.rake +1 -1
  175. data/gem_tasks/flog.rake +2 -2
  176. data/gem_tasks/rspec.rake +1 -1
  177. data/lib/autotest/cucumber_mixin.rb +15 -15
  178. data/lib/autotest/discover.rb +2 -2
  179. data/lib/cucumber/cli/configuration.rb +7 -13
  180. data/lib/cucumber/cli/main.rb +6 -6
  181. data/lib/cucumber/cli/options.rb +163 -126
  182. data/lib/cucumber/cli/profile_loader.rb +24 -20
  183. data/lib/cucumber/configuration.rb +12 -17
  184. data/lib/cucumber/constantize.rb +1 -1
  185. data/lib/cucumber/core_ext/string.rb +1 -1
  186. data/lib/cucumber/deprecate.rb +1 -1
  187. data/lib/cucumber/events.rb +11 -1
  188. data/lib/cucumber/events/gherkin_source_read.rb +17 -0
  189. data/lib/cucumber/events/{step_match.rb → step_activated.rb} +2 -2
  190. data/lib/cucumber/events/step_definition_registered.rb +1 -1
  191. data/lib/cucumber/events/test_case_finished.rb +18 -0
  192. data/lib/cucumber/events/test_case_starting.rb +15 -0
  193. data/lib/cucumber/events/test_run_starting.rb +16 -0
  194. data/lib/cucumber/events/test_step_finished.rb +20 -0
  195. data/lib/cucumber/events/test_step_starting.rb +17 -0
  196. data/lib/cucumber/filters.rb +1 -0
  197. data/lib/cucumber/filters/activate_steps.rb +1 -1
  198. data/lib/cucumber/filters/broadcast_test_run_starting_event.rb +27 -0
  199. data/lib/cucumber/filters/retry.rb +1 -1
  200. data/lib/cucumber/filters/tag_limits.rb +3 -3
  201. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -1
  202. data/lib/cucumber/formatter/ansicolor.rb +8 -11
  203. data/lib/cucumber/formatter/backtrace_filter.rb +19 -7
  204. data/lib/cucumber/formatter/console.rb +16 -19
  205. data/lib/cucumber/formatter/console_counts.rb +8 -21
  206. data/lib/cucumber/formatter/console_issues.rb +30 -9
  207. data/lib/cucumber/formatter/duration.rb +1 -1
  208. data/lib/cucumber/formatter/fail_fast.rb +1 -1
  209. data/lib/cucumber/formatter/html.rb +168 -242
  210. data/lib/cucumber/formatter/html_builder.rb +110 -0
  211. data/lib/cucumber/formatter/inline-js.js +30 -0
  212. data/lib/cucumber/formatter/interceptor.rb +2 -2
  213. data/lib/cucumber/formatter/json.rb +12 -12
  214. data/lib/cucumber/formatter/junit.rb +11 -11
  215. data/lib/cucumber/formatter/legacy_api/adapter.rb +27 -27
  216. data/lib/cucumber/formatter/legacy_api/ast.rb +16 -20
  217. data/lib/cucumber/formatter/legacy_api/results.rb +6 -8
  218. data/lib/cucumber/formatter/pretty.rb +17 -17
  219. data/lib/cucumber/formatter/progress.rb +11 -12
  220. data/lib/cucumber/formatter/rerun.rb +1 -1
  221. data/lib/cucumber/formatter/steps.rb +1 -1
  222. data/lib/cucumber/formatter/unicode.rb +1 -1
  223. data/lib/cucumber/formatter/usage.rb +12 -12
  224. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -1
  225. data/lib/cucumber/gherkin/formatter/escaping.rb +1 -1
  226. data/lib/cucumber/{rb_support/rb_dsl.rb → glue/dsl.rb} +44 -17
  227. data/lib/cucumber/glue/hook.rb +43 -0
  228. data/lib/cucumber/glue/invoke_in_world.rb +70 -0
  229. data/lib/cucumber/glue/proto_world.rb +225 -0
  230. data/lib/cucumber/{rb_support/rb_language.rb → glue/registry_and_more.rb} +45 -86
  231. data/lib/cucumber/{rb_support → glue}/snippet.rb +62 -25
  232. data/lib/cucumber/glue/step_definition.rb +143 -0
  233. data/lib/cucumber/glue/world_factory.rb +23 -0
  234. data/lib/cucumber/hooks.rb +4 -4
  235. data/lib/cucumber/multiline_argument.rb +2 -2
  236. data/lib/cucumber/multiline_argument/data_table.rb +40 -178
  237. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +158 -0
  238. data/lib/cucumber/platform.rb +3 -5
  239. data/lib/cucumber/rake/task.rb +11 -11
  240. data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
  241. data/lib/cucumber/rspec/doubles.rb +1 -1
  242. data/lib/cucumber/running_test_case.rb +2 -2
  243. data/lib/cucumber/runtime.rb +46 -34
  244. data/lib/cucumber/runtime/after_hooks.rb +1 -1
  245. data/lib/cucumber/runtime/for_programming_languages.rb +1 -36
  246. data/lib/cucumber/runtime/support_code.rb +19 -15
  247. data/lib/cucumber/runtime/user_interface.rb +4 -11
  248. data/lib/cucumber/step_argument.rb +0 -2
  249. data/lib/cucumber/step_definition_light.rb +1 -0
  250. data/lib/cucumber/step_match.rb +16 -15
  251. data/lib/cucumber/step_match_search.rb +2 -3
  252. data/lib/cucumber/term/ansicolor.rb +1 -1
  253. data/lib/cucumber/version +1 -1
  254. data/lib/simplecov_setup.rb +1 -1
  255. data/scripts/invite-collaborator +40 -0
  256. data/scripts/update-history +83 -0
  257. data/spec/cucumber/cli/configuration_spec.rb +95 -97
  258. data/spec/cucumber/cli/main_spec.rb +7 -7
  259. data/spec/cucumber/cli/options_spec.rb +112 -78
  260. data/spec/cucumber/cli/profile_loader_spec.rb +24 -5
  261. data/spec/cucumber/cli/rerun_spec.rb +20 -20
  262. data/spec/cucumber/configuration_spec.rb +47 -47
  263. data/spec/cucumber/constantize_spec.rb +2 -2
  264. data/spec/cucumber/events_spec.rb +9 -0
  265. data/spec/cucumber/file_specs_spec.rb +25 -25
  266. data/spec/cucumber/filters/activate_steps_spec.rb +16 -16
  267. data/spec/cucumber/filters/gated_receiver_spec.rb +6 -6
  268. data/spec/cucumber/filters/retry_spec.rb +22 -9
  269. data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +11 -11
  270. data/spec/cucumber/filters/tag_limits/verifier_spec.rb +14 -14
  271. data/spec/cucumber/filters/tag_limits_spec.rb +8 -8
  272. data/spec/cucumber/formatter/ansicolor_spec.rb +9 -9
  273. data/spec/cucumber/formatter/backtrace_filter_spec.rb +32 -0
  274. data/spec/cucumber/formatter/console_counts_spec.rb +1 -1
  275. data/spec/cucumber/formatter/duration_spec.rb +3 -3
  276. data/spec/cucumber/formatter/fail_fast_spec.rb +21 -21
  277. data/spec/cucumber/formatter/html_spec.rb +58 -58
  278. data/spec/cucumber/formatter/json_spec.rb +44 -46
  279. data/spec/cucumber/formatter/junit_spec.rb +43 -45
  280. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +43 -43
  281. data/spec/cucumber/formatter/pretty_spec.rb +107 -107
  282. data/spec/cucumber/formatter/progress_spec.rb +20 -20
  283. data/spec/cucumber/formatter/rerun_spec.rb +1 -1
  284. data/spec/cucumber/formatter/spec_helper.rb +6 -5
  285. data/spec/cucumber/{rb_support/rb_world_spec.rb → glue/proto_world_spec.rb} +20 -5
  286. data/spec/cucumber/glue/registry_and_more_spec.rb +213 -0
  287. data/spec/cucumber/{rb_support → glue}/snippet_spec.rb +61 -25
  288. data/spec/cucumber/glue/step_definition_spec.rb +207 -0
  289. data/spec/cucumber/hooks_spec.rb +3 -3
  290. data/spec/cucumber/multiline_argument/data_table_spec.rb +177 -133
  291. data/spec/cucumber/project_initializer_spec.rb +10 -10
  292. data/spec/cucumber/rake/forked_spec.rb +10 -10
  293. data/spec/cucumber/rake/task_spec.rb +20 -20
  294. data/spec/cucumber/running_test_case_spec.rb +35 -35
  295. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -30
  296. data/spec/cucumber/runtime_spec.rb +2 -2
  297. data/spec/cucumber/step_argument_spec.rb +5 -5
  298. data/spec/cucumber/step_match_search_spec.rb +31 -41
  299. data/spec/cucumber/step_match_spec.rb +33 -33
  300. data/spec/cucumber/world/pending_spec.rb +10 -10
  301. metadata +117 -47
  302. data/features/docs/formatters/debug_formatter.feature +0 -47
  303. data/features/docs/writing_support_code/transforms.feature +0 -98
  304. data/features/lib/step_definitions/wire_steps.rb +0 -59
  305. data/gem_tasks/cucumber.rake +0 -26
  306. data/lib/cucumber/core_ext/instance_exec.rb +0 -71
  307. data/lib/cucumber/formatter/debug.rb +0 -36
  308. data/lib/cucumber/rb_support/rb_hook.rb +0 -20
  309. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -132
  310. data/lib/cucumber/rb_support/rb_transform.rb +0 -60
  311. data/lib/cucumber/rb_support/rb_world.rb +0 -171
  312. data/spec/cucumber/core_ext/instance_exec_spec.rb +0 -5
  313. data/spec/cucumber/formatter/debug_spec.rb +0 -65
  314. data/spec/cucumber/rb_support/rb_language_spec.rb +0 -321
  315. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +0 -200
  316. data/spec/cucumber/rb_support/rb_transform_spec.rb +0 -47
@@ -0,0 +1,158 @@
1
+ module Cucumber
2
+ module MultilineArgument
3
+ class DataTable
4
+ class DiffMatrices #:nodoc:
5
+ attr_accessor :cell_matrix, :other_table_cell_matrix, :options
6
+
7
+ def initialize(cell_matrix, other_table_cell_matrix, options)
8
+ @cell_matrix = cell_matrix
9
+ @other_table_cell_matrix = other_table_cell_matrix
10
+ @options = options
11
+ end
12
+
13
+ def call
14
+ prepare_diff
15
+ perform_diff
16
+ fill_in_missing_values
17
+ raise_error if should_raise?
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :row_indices, :original_width, :original_header, :padded_width, :missing_row_pos, :insert_row_pos
23
+
24
+ def prepare_diff
25
+ @original_width = cell_matrix[0].length
26
+ @original_header = other_table_cell_matrix[0]
27
+ pad_and_match
28
+ @padded_width = cell_matrix[0].length
29
+ @row_indices = Array.new(other_table_cell_matrix.length) {|n| n}
30
+ end
31
+
32
+ # Pads two cell matrices to same column width and matches columns according to header value.
33
+ def pad_and_match
34
+ cols = cell_matrix.transpose
35
+ unmatched_cols = other_table_cell_matrix.transpose
36
+
37
+ header_values = cols.map(&:first)
38
+ matched_cols = []
39
+
40
+ header_values.each_with_index do |v, i|
41
+ mapped_index = unmatched_cols.index{|unmapped_col| unmapped_col.first == v}
42
+ if mapped_index
43
+ matched_cols << unmatched_cols.delete_at(mapped_index)
44
+ else
45
+ mark_as_missing(cols[i])
46
+ empty_col = ensure_2d(other_table_cell_matrix).collect {SurplusCell.new(nil, self, -1)}
47
+ empty_col.first.value = v
48
+ matched_cols << empty_col
49
+ end
50
+ end
51
+
52
+ unmatched_cols.each do
53
+ empty_col = cell_matrix.collect {SurplusCell.new(nil, self, -1)}
54
+ cols << empty_col
55
+ end
56
+
57
+ self.cell_matrix = ensure_2d(cols.transpose)
58
+ self.other_table_cell_matrix = ensure_2d((matched_cols + unmatched_cols).transpose)
59
+ end
60
+
61
+ def mark_as_missing(col)
62
+ col.each do |cell|
63
+ cell.status = :undefined
64
+ end
65
+ end
66
+
67
+ def ensure_2d(array)
68
+ array[0].is_a?(Array) ? array : [array]
69
+ end
70
+
71
+
72
+ def perform_diff
73
+ inserted = 0
74
+ missing = 0
75
+ last_change = nil
76
+
77
+ changes.each do |change|
78
+ if change.action == '-'
79
+ @missing_row_pos = change.position + inserted
80
+ cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
81
+ row_indices.insert(missing_row_pos, nil)
82
+ missing += 1
83
+ else # '+'
84
+ @insert_row_pos = change.position + missing
85
+ inserted_row = change.element
86
+ inserted_row.each{|cell| cell.status = :comment}
87
+ cell_matrix.insert(insert_row_pos, inserted_row)
88
+ row_indices[insert_row_pos] = nil
89
+ inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change == '-'
90
+ inserted += 1
91
+ end
92
+ last_change = change.action
93
+ end
94
+ end
95
+
96
+ def changes
97
+ require 'diff/lcs'
98
+ diffable_cell_matrix = cell_matrix.dup.extend(::Diff::LCS)
99
+ diffable_cell_matrix.diff(other_table_cell_matrix).flatten
100
+ end
101
+
102
+ def inspect_rows(missing_row, inserted_row)
103
+ missing_row.each_with_index do |missing_cell, col|
104
+ inserted_cell = inserted_row[col]
105
+ if missing_cell.value != inserted_cell.value && missing_cell.value.to_s == inserted_cell.value.to_s
106
+ missing_cell.inspect!
107
+ inserted_cell.inspect!
108
+ end
109
+ end
110
+ end
111
+
112
+
113
+ def fill_in_missing_values
114
+ other_table_cell_matrix.each_with_index do |other_row, i|
115
+ row_index = row_indices.index(i)
116
+ row = cell_matrix[row_index] if row_index
117
+ next unless row
118
+ (original_width..padded_width).each do |col_index|
119
+ surplus_cell = other_row[col_index]
120
+ row[col_index].value = surplus_cell.value if row[col_index]
121
+ end
122
+ end
123
+ end
124
+
125
+ def missing_col
126
+ cell_matrix[0].find{|cell| cell.status == :undefined}
127
+ end
128
+
129
+ def surplus_col
130
+ padded_width > original_width
131
+ end
132
+
133
+ def misplaced_col
134
+ cell_matrix[0] != original_header
135
+ end
136
+
137
+
138
+ def raise_error
139
+ table = DataTable.from([[]])
140
+ table.instance_variable_set :@cell_matrix, cell_matrix
141
+ raise Different.new(table) if should_raise?
142
+ end
143
+
144
+ def should_raise?
145
+ [
146
+ missing_row_pos && options.fetch(:missing_row, true),
147
+ insert_row_pos && options.fetch(:surplus_row, true),
148
+ missing_col && options.fetch(:missing_col, true),
149
+ surplus_col && options.fetch(:surplus_col, false),
150
+ misplaced_col && options.fetch(:misplaced_col, false)
151
+ ].any?
152
+ end
153
+ end
154
+ private_constant :DiffMatrices
155
+ end
156
+ end
157
+ end
158
+
@@ -6,20 +6,18 @@ require 'cucumber/core/platform'
6
6
 
7
7
  module Cucumber
8
8
  unless defined?(Cucumber::VERSION)
9
- VERSION = File.read(File.expand_path("../version", __FILE__))
9
+ VERSION = File.read(File.expand_path('../version', __FILE__))
10
10
  BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
11
11
  LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
12
12
  RAILS = defined?(Rails)
13
13
  RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
14
- RUBY_2_2 = RUBY_VERSION =~ /^2\.2/
15
- RUBY_2_1 = RUBY_VERSION =~ /^2\.1/
16
- RUBY_2_3 = RUBY_VERSION =~ /^2\.3/
14
+ RUBY = defined? RUBY_VERSION
17
15
 
18
16
  class << self
19
17
  attr_accessor :use_full_backtrace
20
18
 
21
19
  # @private
22
- def file_mode(m, encoding="UTF-8")
20
+ def file_mode(m, encoding='UTF-8')
23
21
  "#{m}:#{encoding}"
24
22
  end
25
23
  end
@@ -35,7 +35,7 @@ module Cucumber
35
35
  attr_reader :args
36
36
 
37
37
  def initialize(libs, cucumber_opts, feature_files)
38
- raise "libs must be an Array when running in-process" unless Array === libs
38
+ raise 'libs must be an Array when running in-process' unless Array === libs
39
39
  libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
40
40
  @args = (
41
41
  cucumber_opts +
@@ -46,7 +46,7 @@ module Cucumber
46
46
  def run
47
47
  require 'cucumber/cli/main'
48
48
  failure = Cucumber::Cli::Main.execute(args)
49
- raise "Cucumber failed" if failure
49
+ raise 'Cucumber failed' if failure
50
50
  end
51
51
  end
52
52
 
@@ -61,16 +61,16 @@ module Cucumber
61
61
  @feature_files = feature_files
62
62
  end
63
63
 
64
- def load_path(libs)
65
- ['"%s"' % @libs.join(File::PATH_SEPARATOR)]
64
+ def load_path
65
+ [format('"%s"', @libs.join(File::PATH_SEPARATOR))]
66
66
  end
67
67
 
68
68
  def quoted_binary(cucumber_bin)
69
- ['"%s"' % cucumber_bin]
69
+ [format('"%s"', cucumber_bin)]
70
70
  end
71
71
 
72
72
  def use_bundler
73
- @bundler.nil? ? File.exist?("./Gemfile") && bundler_gem_available? : @bundler
73
+ @bundler.nil? ? File.exist?('./Gemfile') && bundler_gem_available? : @bundler
74
74
  end
75
75
 
76
76
  def bundler_gem_available?
@@ -84,13 +84,13 @@ module Cucumber
84
84
  [ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
85
85
  @feature_files ].flatten
86
86
  else
87
- [ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
87
+ [ Cucumber::RUBY_BINARY, '-I', load_path, quoted_binary(@cucumber_bin),
88
88
  @cucumber_opts, @feature_files ].flatten
89
89
  end
90
90
  end
91
91
 
92
92
  def run
93
- sh cmd.join(" ") do |ok, res|
93
+ sh cmd.join(' ') do |ok, res|
94
94
  if !ok
95
95
  exit res.exitstatus
96
96
  end
@@ -128,7 +128,7 @@ module Cucumber
128
128
  attr_accessor :bundler
129
129
 
130
130
  # Define Cucumber Rake task
131
- def initialize(task_name = "cucumber", desc = "Run Cucumber features")
131
+ def initialize(task_name = 'cucumber', desc = 'Run Cucumber features')
132
132
  @task_name, @desc = task_name, desc
133
133
  @fork = true
134
134
  @libs = ['lib']
@@ -145,7 +145,7 @@ module Cucumber
145
145
  end
146
146
  end
147
147
 
148
- def runner(task_args = nil) #:nodoc:
148
+ def runner(_task_args = nil) #:nodoc:
149
149
  cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
150
150
  if(@fork)
151
151
  return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files)
@@ -154,7 +154,7 @@ module Cucumber
154
154
  end
155
155
 
156
156
  def cucumber_opts_with_profile #:nodoc:
157
- Array(cucumber_opts).concat Array(@profile).flat_map {|p| ["--profile", p] }
157
+ Array(cucumber_opts).concat Array(@profile).flat_map {|p| ['--profile', p] }
158
158
  end
159
159
 
160
160
  def feature_files #:nodoc:
@@ -8,7 +8,7 @@ module Spec #:nodoc:
8
8
  # will fail when running cucumber)
9
9
  class OptionParser < ::OptionParser #:nodoc:
10
10
  NEUTERED_RSPEC = Object.new
11
- def NEUTERED_RSPEC.method_missing(m, *args); self; end
11
+ def NEUTERED_RSPEC.method_missing(_m, *_args); self; end
12
12
 
13
13
  def self.method_added(m)
14
14
  unless @__neutering_rspec
@@ -4,7 +4,7 @@ require 'rspec/mocks'
4
4
  World(RSpec::Mocks::ExampleMethods)
5
5
 
6
6
  Before do
7
- if RSpec::Mocks::Version::STRING >= "2.9.9"
7
+ if RSpec::Mocks::Version::STRING >= '2.9.9'
8
8
  RSpec::Mocks.setup
9
9
  else
10
10
  RSpec::Mocks.setup(self)
@@ -32,11 +32,11 @@ module Cucumber
32
32
  def feature(feature)
33
33
  end
34
34
 
35
- def scenario(scenario)
35
+ def scenario(_scenario)
36
36
  @factory = Scenario
37
37
  end
38
38
 
39
- def scenario_outline(scenario)
39
+ def scenario_outline(_scenario)
40
40
  @factory = ScenarioOutlineExample
41
41
  end
42
42
 
@@ -14,7 +14,7 @@ require 'cucumber/step_match_search'
14
14
  module Cucumber
15
15
  module FixRuby21Bug9285
16
16
  def message
17
- String(super).gsub("@ rb_sysopen ", "")
17
+ String(super).gsub('@ rb_sysopen ', '')
18
18
  end
19
19
  end
20
20
 
@@ -30,8 +30,14 @@ module Cucumber
30
30
  class FileNotFoundException < FileException
31
31
  end
32
32
 
33
- class FeatureFolderNotFoundException < FileException
34
- include FixRuby21Bug9285 if Cucumber::RUBY_2_1 || Cucumber::RUBY_2_2 || Cucumber::RUBY_2_3
33
+ class FeatureFolderNotFoundException < Exception
34
+ def initialize(path)
35
+ @path = path
36
+ end
37
+
38
+ def message
39
+ "No such file or directory - #{@path}"
40
+ end
35
41
  end
36
42
 
37
43
  require 'cucumber/core'
@@ -58,11 +64,10 @@ module Cucumber
58
64
 
59
65
  require 'cucumber/wire/plugin'
60
66
  def run!
67
+ load_step_definitions
61
68
  install_wire_plugin
62
- load_support_files
63
69
  fire_after_configuration_hook
64
- formatters
65
- load_step_definitions
70
+ # TODO: can we remove this state?
66
71
  self.visitor = report
67
72
 
68
73
  receiver = Test::Runner.new(@configuration.event_bus)
@@ -90,22 +95,22 @@ module Cucumber
90
95
  @support_code.unmatched_step_definitions
91
96
  end
92
97
 
93
- def begin_scenario(scenario)
94
- @support_code.fire_hook(:begin_scenario, scenario)
98
+ def begin_scenario(test_case)
99
+ @support_code.fire_hook(:begin_scenario, test_case)
95
100
  end
96
101
 
97
- def end_scenario(scenario)
102
+ def end_scenario(_scenario)
98
103
  @support_code.fire_hook(:end_scenario)
99
104
  end
100
105
 
101
106
  # Returns Ast::DocString for +string_without_triple_quotes+.
102
107
  #
103
- def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
108
+ def doc_string(string_without_triple_quotes, content_type='', _line_offset=0)
104
109
  location = Core::Ast::Location.of_caller
105
110
  Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
106
111
  end
107
112
 
108
- private
113
+ private
109
114
 
110
115
  def fire_after_configuration_hook #:nodoc
111
116
  @support_code.fire_hook(:after_configuration, @configuration)
@@ -115,6 +120,7 @@ module Cucumber
115
120
  def features
116
121
  @features ||= feature_files.map do |path|
117
122
  source = NormalisedEncodingFile.read(path)
123
+ @configuration.notify :gherkin_source_read, path, source
118
124
  Cucumber::Core::Gherkin::Document.new(path, source)
119
125
  end
120
126
  end
@@ -141,13 +147,13 @@ module Cucumber
141
147
  set_encoding
142
148
  rescue Errno::EACCES => e
143
149
  raise FileNotFoundException.new(e, File.expand_path(path))
144
- rescue Errno::ENOENT => e
145
- raise FeatureFolderNotFoundException.new(e, path)
150
+ rescue Errno::ENOENT
151
+ raise FeatureFolderNotFoundException.new(path)
146
152
  end
147
153
  end
148
154
 
149
155
  def read
150
- @file.read.encode("UTF-8")
156
+ @file.read.encode('UTF-8')
151
157
  end
152
158
 
153
159
  private
@@ -186,34 +192,44 @@ module Cucumber
186
192
  end
187
193
 
188
194
  def formatters
189
- @formatters ||= @configuration.formatter_factories { |factory, path_or_io, options|
190
- create_formatter(factory, path_or_io, options)
191
- }
195
+ @formatters ||=
196
+ @configuration.formatter_factories do |factory, formatter_options, path_or_io, options|
197
+ create_formatter(factory, formatter_options, path_or_io, options)
198
+ end
192
199
  end
193
200
 
194
- def create_formatter(factory, path_or_io, options)
201
+ def create_formatter(factory, formatter_options, path_or_io, cli_options)
195
202
  if !legacy_formatter?(factory)
196
- return factory.new(@configuration) if path_or_io.nil?
197
- return factory.new(@configuration.with_options(out_stream: path_or_io))
203
+ if accept_options?(factory)
204
+ return factory.new(@configuration, formatter_options) if path_or_io.nil?
205
+ return factory.new(@configuration.with_options(out_stream: path_or_io),
206
+ formatter_options)
207
+ else
208
+ return factory.new(@configuration) if path_or_io.nil?
209
+ return factory.new(@configuration.with_options(out_stream: path_or_io))
210
+ end
198
211
  end
199
212
  results = Formatter::LegacyApi::Results.new
200
213
  runtime_facade = Formatter::LegacyApi::RuntimeFacade.new(results, @support_code, @configuration)
201
- formatter = factory.new(runtime_facade, path_or_io, options)
214
+ formatter = factory.new(runtime_facade, path_or_io, cli_options)
202
215
  Formatter::LegacyApi::Adapter.new(
203
216
  Formatter::IgnoreMissingMessages.new(formatter),
204
217
  results, @configuration)
205
218
  end
206
219
 
207
- def legacy_formatter?(factory)
220
+ def accept_options?(factory)
208
221
  factory.instance_method(:initialize).arity > 1
209
222
  end
210
223
 
224
+ def legacy_formatter?(factory)
225
+ factory.instance_method(:initialize).arity > 2
226
+ end
227
+
211
228
  def failure?
212
229
  if @configuration.wip?
213
230
  summary_report.test_cases.total_passed > 0
214
231
  else
215
- summary_report.test_cases.total_failed > 0 || summary_report.test_steps.total_failed > 0 ||
216
- (@configuration.strict? && (summary_report.test_steps.total_undefined > 0 || summary_report.test_steps.total_pending > 0))
232
+ !summary_report.ok?(@configuration.strict?)
217
233
  end
218
234
  end
219
235
  public :failure?
@@ -229,10 +245,8 @@ module Cucumber
229
245
  filters << Cucumber::Core::Test::NameFilter.new(name_regexps)
230
246
  filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations)
231
247
  filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize?
232
- filters << Filters::Quit.new
233
- filters << Filters::Retry.new(@configuration)
234
- # TODO: can we just use RbLanguages's step definitions directly?
235
- step_match_search = StepMatchSearch.new(@support_code.ruby.method(:step_matches), @configuration)
248
+ # TODO: can we just use Glue::RegistryAndMore's step definitions directly?
249
+ step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration)
236
250
  filters << Filters::ActivateSteps.new(step_match_search, @configuration)
237
251
  @configuration.filters.each do |filter|
238
252
  filters << filter
@@ -242,19 +256,17 @@ module Cucumber
242
256
  filters << Filters::ApplyBeforeHooks.new(@support_code)
243
257
  filters << Filters::ApplyAfterHooks.new(@support_code)
244
258
  filters << Filters::ApplyAroundHooks.new(@support_code)
259
+ filters << Filters::BroadcastTestRunStartingEvent.new(@configuration)
260
+ filters << Filters::Quit.new
261
+ filters << Filters::Retry.new(@configuration)
245
262
  # need to do this last so it becomes the first test step
246
263
  filters << Filters::PrepareWorld.new(self)
247
264
  end
248
265
  end
249
266
  end
250
267
 
251
- def load_support_files
252
- files = @configuration.support_to_load
253
- @support_code.load_files!(files)
254
- end
255
-
256
268
  def load_step_definitions
257
- files = @configuration.step_defs_to_load
269
+ files = @configuration.support_to_load + @configuration.step_defs_to_load
258
270
  @support_code.load_files!(files)
259
271
  end
260
272