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.
- checksums.yaml +4 -4
- data/.cucumberproignore +6 -0
- data/.rubocop.yml +13 -0
- data/.rubocop_todo.yml +1075 -0
- data/.travis.yml +42 -8
- data/CONTRIBUTING.md +8 -1
- data/Gemfile +16 -10
- data/History.md +96 -36
- data/README.md +12 -3
- data/Rakefile +12 -2
- data/appveyor.yml +26 -0
- data/cucumber.gemspec +15 -10
- data/cucumber.yml +9 -10
- data/examples/i18n/Rakefile +1 -1
- data/examples/i18n/ar/features/step_definitions/calculator_steps.rb +2 -2
- data/examples/i18n/ar/lib/calculator.rb +2 -2
- data/examples/i18n/bg/features/step_definitions/calculator_steps.rb +6 -6
- data/examples/i18n/ca/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/ca/lib/calculadora.rb +2 -2
- data/examples/i18n/cs/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/cs/lib/calculator.rb +3 -3
- data/examples/i18n/da/features/step_definitions/lommeregner_steps.rb +4 -4
- data/examples/i18n/da/lib/lommeregner.rb +2 -2
- data/examples/i18n/de/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/de/lib/calculator.rb +2 -2
- data/examples/i18n/el/features/step_definitions/calculator_steps.rb +5 -5
- data/examples/i18n/el/lib/calculator.rb +2 -2
- data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +4 -4
- data/examples/i18n/en-lol/lib/basket.rb +2 -2
- data/examples/i18n/en-lol/lib/belly.rb +2 -2
- data/examples/i18n/en/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/en/lib/calculator.rb +2 -2
- data/examples/i18n/eo/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/eo/lib/calculator.rb +2 -2
- data/examples/i18n/es/features/step_definitions/calculador_steps.rb +5 -5
- data/examples/i18n/es/lib/calculador.rb +2 -2
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +4 -4
- data/examples/i18n/et/lib/kalkulaator.rb +3 -3
- data/examples/i18n/fi/features/step_definitions/laskin_steps.rb +3 -3
- data/examples/i18n/fi/lib/laskin.rb +1 -1
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +8 -8
- data/examples/i18n/fr/features/support/env.rb +1 -1
- data/examples/i18n/fr/lib/calculatrice.rb +2 -2
- data/examples/i18n/he/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/he/lib/calculator.rb +1 -1
- data/examples/i18n/hi/features/step_definitions/calculator_steps.rb +3 -3
- data/examples/i18n/hi/lib/calculator.rb +1 -1
- data/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +4 -4
- data/examples/i18n/ht/lib/kalkilatris.rb +2 -2
- data/examples/i18n/hu/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/hu/lib/calculator.rb +1 -1
- data/examples/i18n/id/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/id/lib/calculator.rb +2 -2
- data/examples/i18n/it/features/step_definitions/calcolatrice_steps.rb +4 -4
- data/examples/i18n/it/lib/calcolatrice.rb +3 -3
- data/examples/i18n/ja/features/step_definitions/calculator_steps.rb +3 -3
- data/examples/i18n/ja/features/support/env.rb +1 -1
- data/examples/i18n/ja/lib/calculator.rb +2 -2
- data/examples/i18n/ko/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/ko/lib/calculator.rb +2 -2
- data/examples/i18n/lt/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/lt/lib/calculator.rb +2 -2
- data/examples/i18n/lv/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/lv/lib/calculator.rb +2 -2
- data/examples/i18n/no/features/step_definitions/kalkulator_steps.rb +3 -3
- data/examples/i18n/no/features/support/env.rb +1 -1
- data/examples/i18n/no/lib/kalkulator.rb +2 -2
- data/examples/i18n/pl/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/pl/lib/calculator.rb +2 -2
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +3 -3
- data/examples/i18n/pt/features/support/env.rb +1 -1
- data/examples/i18n/pt/lib/calculadora.rb +1 -1
- data/examples/i18n/ro/features/step_definitions/calculator_steps.rb +5 -5
- data/examples/i18n/ro/lib/calculator.rb +1 -1
- data/examples/i18n/ru/features/step_definitions/calculator_steps.rb +5 -5
- data/examples/i18n/sk/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/sk/lib/calculator.rb +2 -2
- data/examples/i18n/sr-Cyrl/features/step_definitions/calculator_steps.rb +3 -3
- data/examples/i18n/sr-Cyrl/features/support/env.rb +1 -1
- data/examples/i18n/sr-Cyrl/lib/calculator.rb +2 -2
- data/examples/i18n/sr-Latn/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/sr-Latn/lib/calculator.rb +2 -2
- data/examples/i18n/sv/features/step_definitions/kalkulator_steps.rb +3 -3
- data/examples/i18n/sv/lib/kalkulator.rb +2 -2
- data/examples/i18n/tr/features/step_definitions/hesap_makinesi_adimlari.rb +4 -4
- data/examples/i18n/tr/lib/hesap_makinesi.rb +2 -2
- data/examples/i18n/uk/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/uz/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/zh-CN/features/step_definitions/calculator_steps.rb +5 -5
- data/examples/i18n/zh-CN/lib/calculator.rb +2 -2
- data/examples/i18n/zh-TW/features/step_definitions/calculator_steps.rb +4 -4
- data/examples/i18n/zh-TW/lib/calculator.rb +2 -2
- data/examples/rspec_doubles/features/step_definitions/calvin_steps.rb +3 -3
- data/examples/sinatra/features/step_definitions/add_steps.rb +4 -4
- data/examples/tcl/features/step_definitions/fib_steps.rb +2 -2
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +4 -4
- data/examples/watir/features/step_definitions/search_steps.rb +3 -3
- data/examples/watir/features/support/screenshots.rb +5 -5
- data/features/docs/api/list_step_defs_as_json.feature +21 -7
- data/features/docs/api/listen_for_events.feature +1 -1
- data/features/docs/api/run_cli_main_with_existing_runtime.feature +1 -0
- data/features/docs/cli/dry_run.feature +3 -0
- data/features/docs/cli/execute_with_tag_filter.feature +4 -4
- data/features/docs/cli/fail_fast.feature +2 -0
- data/features/docs/{gherkin/language_help.feature → cli/i18n.feature} +6 -6
- data/features/docs/cli/randomize.feature +2 -2
- data/features/docs/cli/retry_failing_tests.feature +28 -3
- data/features/docs/cli/run_scenarios_matching_name.feature +1 -0
- data/features/docs/cli/specifying_multiple_formatters.feature +3 -0
- data/features/docs/cli/strict_mode.feature +6 -0
- data/features/docs/defining_steps/nested_steps.feature +5 -1
- data/features/docs/defining_steps/nested_steps_i18n.feature +1 -0
- data/features/docs/defining_steps/nested_steps_with_second_arg.feature +2 -0
- data/features/docs/defining_steps/printing_messages.feature +1 -1
- data/features/docs/defining_steps/skip_scenario.feature +1 -0
- data/features/docs/defining_steps/snippets.feature +18 -18
- data/features/docs/events/gherkin_source_read_event.feature +43 -0
- data/features/docs/events/step_activated_event.feature +36 -0
- data/features/docs/events/step_definition_registered_event.feature +29 -0
- data/features/docs/events/test_case_finished_event.feature +35 -0
- data/features/docs/events/test_case_starting_event.feature +54 -0
- data/features/docs/events/test_run_finished_event.feature +40 -0
- data/features/docs/events/test_run_starting_event.feature +41 -0
- data/features/docs/events/test_step_finished_event.feature +47 -0
- data/features/docs/events/test_step_starting_event.feature +43 -0
- data/features/docs/exception_in_after_hook.feature +3 -2
- data/features/docs/exception_in_after_step_hook.feature +2 -0
- data/features/docs/exception_in_around_hook.feature +2 -0
- data/features/docs/exception_in_before_hook.feature +3 -1
- data/features/docs/extending_cucumber/custom_formatter.feature +21 -1
- data/features/docs/formatters/json_formatter.feature +4 -4
- data/features/docs/formatters/junit_formatter.feature +7 -6
- data/features/docs/formatters/pretty_formatter.feature +1 -0
- data/features/docs/formatters/progress_formatter.feature +1 -0
- data/features/docs/formatters/rerun_formatter.feature +2 -0
- data/features/docs/formatters/summary_formatter.feature +1 -0
- data/features/docs/formatters/usage_formatter.feature +3 -0
- data/features/docs/getting_started.feature +2 -1
- data/features/docs/gherkin/background.feature +5 -5
- data/features/docs/gherkin/doc_strings.feature +2 -0
- data/features/docs/gherkin/expand_option_for_outlines.feature +1 -0
- data/features/docs/gherkin/outlines.feature +4 -0
- data/features/docs/gherkin/unicode_table.feature +1 -0
- data/features/docs/gherkin/using_descriptions.feature +1 -0
- data/features/docs/gherkin/using_star_notation.feature +1 -1
- data/features/docs/post_configuration_hook.feature +1 -1
- data/features/docs/rake_task.feature +5 -0
- data/features/docs/raketask.feature +3 -1
- data/features/docs/work_in_progress.feature +5 -2
- data/features/docs/writing_support_code/after_step_hooks.feature +3 -1
- data/features/docs/writing_support_code/around_hooks.feature +6 -0
- data/features/docs/writing_support_code/before_hook.feature +1 -0
- data/features/docs/writing_support_code/hook_order.feature +3 -1
- data/features/docs/writing_support_code/parameter_types.feature +75 -0
- data/features/docs/writing_support_code/tagged_hooks.feature +1 -1
- data/features/lib/step_definitions/aruba_steps.rb +4 -10
- data/features/lib/step_definitions/cli_steps.rb +2 -2
- data/features/lib/step_definitions/cucumber_steps.rb +8 -12
- data/features/lib/step_definitions/iso-8859-1_steps.rb +2 -2
- data/features/lib/step_definitions/json_steps.rb +1 -1
- data/features/lib/step_definitions/junit_steps.rb +1 -1
- data/features/lib/step_definitions/language_steps.rb +2 -2
- data/features/lib/step_definitions/profile_steps.rb +6 -6
- data/features/lib/step_definitions/retry_steps.rb +3 -3
- data/features/lib/step_definitions/ruby_steps.rb +1 -1
- data/features/lib/support/env.rb +1 -1
- data/features/lib/support/fake_wire_server.rb +7 -2
- data/features/lib/support/feature_factory.rb +1 -1
- data/features/lib/support/normalise_output.rb +13 -12
- data/features/lib/support/parameter_types.rb +8 -0
- data/gem_tasks/contributors.rake +9 -6
- data/gem_tasks/environment.rake +1 -5
- data/gem_tasks/examples.rake +1 -1
- data/gem_tasks/fix_cr_lf.rake +1 -1
- data/gem_tasks/flog.rake +2 -2
- data/gem_tasks/rspec.rake +1 -1
- data/lib/autotest/cucumber_mixin.rb +15 -15
- data/lib/autotest/discover.rb +2 -2
- data/lib/cucumber/cli/configuration.rb +7 -13
- data/lib/cucumber/cli/main.rb +6 -6
- data/lib/cucumber/cli/options.rb +163 -126
- data/lib/cucumber/cli/profile_loader.rb +24 -20
- data/lib/cucumber/configuration.rb +12 -17
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/core_ext/string.rb +1 -1
- data/lib/cucumber/deprecate.rb +1 -1
- data/lib/cucumber/events.rb +11 -1
- data/lib/cucumber/events/gherkin_source_read.rb +17 -0
- data/lib/cucumber/events/{step_match.rb → step_activated.rb} +2 -2
- data/lib/cucumber/events/step_definition_registered.rb +1 -1
- data/lib/cucumber/events/test_case_finished.rb +18 -0
- data/lib/cucumber/events/test_case_starting.rb +15 -0
- data/lib/cucumber/events/test_run_starting.rb +16 -0
- data/lib/cucumber/events/test_step_finished.rb +20 -0
- data/lib/cucumber/events/test_step_starting.rb +17 -0
- data/lib/cucumber/filters.rb +1 -0
- data/lib/cucumber/filters/activate_steps.rb +1 -1
- data/lib/cucumber/filters/broadcast_test_run_starting_event.rb +27 -0
- data/lib/cucumber/filters/retry.rb +1 -1
- data/lib/cucumber/filters/tag_limits.rb +3 -3
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -1
- data/lib/cucumber/formatter/ansicolor.rb +8 -11
- data/lib/cucumber/formatter/backtrace_filter.rb +19 -7
- data/lib/cucumber/formatter/console.rb +16 -19
- data/lib/cucumber/formatter/console_counts.rb +8 -21
- data/lib/cucumber/formatter/console_issues.rb +30 -9
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/fail_fast.rb +1 -1
- data/lib/cucumber/formatter/html.rb +168 -242
- data/lib/cucumber/formatter/html_builder.rb +110 -0
- data/lib/cucumber/formatter/inline-js.js +30 -0
- data/lib/cucumber/formatter/interceptor.rb +2 -2
- data/lib/cucumber/formatter/json.rb +12 -12
- data/lib/cucumber/formatter/junit.rb +11 -11
- data/lib/cucumber/formatter/legacy_api/adapter.rb +27 -27
- data/lib/cucumber/formatter/legacy_api/ast.rb +16 -20
- data/lib/cucumber/formatter/legacy_api/results.rb +6 -8
- data/lib/cucumber/formatter/pretty.rb +17 -17
- data/lib/cucumber/formatter/progress.rb +11 -12
- data/lib/cucumber/formatter/rerun.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +1 -1
- data/lib/cucumber/formatter/unicode.rb +1 -1
- data/lib/cucumber/formatter/usage.rb +12 -12
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +1 -1
- data/lib/cucumber/gherkin/formatter/escaping.rb +1 -1
- data/lib/cucumber/{rb_support/rb_dsl.rb → glue/dsl.rb} +44 -17
- data/lib/cucumber/glue/hook.rb +43 -0
- data/lib/cucumber/glue/invoke_in_world.rb +70 -0
- data/lib/cucumber/glue/proto_world.rb +225 -0
- data/lib/cucumber/{rb_support/rb_language.rb → glue/registry_and_more.rb} +45 -86
- data/lib/cucumber/{rb_support → glue}/snippet.rb +62 -25
- data/lib/cucumber/glue/step_definition.rb +143 -0
- data/lib/cucumber/glue/world_factory.rb +23 -0
- data/lib/cucumber/hooks.rb +4 -4
- data/lib/cucumber/multiline_argument.rb +2 -2
- data/lib/cucumber/multiline_argument/data_table.rb +40 -178
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +158 -0
- data/lib/cucumber/platform.rb +3 -5
- data/lib/cucumber/rake/task.rb +11 -11
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/running_test_case.rb +2 -2
- data/lib/cucumber/runtime.rb +46 -34
- data/lib/cucumber/runtime/after_hooks.rb +1 -1
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -36
- data/lib/cucumber/runtime/support_code.rb +19 -15
- data/lib/cucumber/runtime/user_interface.rb +4 -11
- data/lib/cucumber/step_argument.rb +0 -2
- data/lib/cucumber/step_definition_light.rb +1 -0
- data/lib/cucumber/step_match.rb +16 -15
- data/lib/cucumber/step_match_search.rb +2 -3
- data/lib/cucumber/term/ansicolor.rb +1 -1
- data/lib/cucumber/version +1 -1
- data/lib/simplecov_setup.rb +1 -1
- data/scripts/invite-collaborator +40 -0
- data/scripts/update-history +83 -0
- data/spec/cucumber/cli/configuration_spec.rb +95 -97
- data/spec/cucumber/cli/main_spec.rb +7 -7
- data/spec/cucumber/cli/options_spec.rb +112 -78
- data/spec/cucumber/cli/profile_loader_spec.rb +24 -5
- data/spec/cucumber/cli/rerun_spec.rb +20 -20
- data/spec/cucumber/configuration_spec.rb +47 -47
- data/spec/cucumber/constantize_spec.rb +2 -2
- data/spec/cucumber/events_spec.rb +9 -0
- data/spec/cucumber/file_specs_spec.rb +25 -25
- data/spec/cucumber/filters/activate_steps_spec.rb +16 -16
- data/spec/cucumber/filters/gated_receiver_spec.rb +6 -6
- data/spec/cucumber/filters/retry_spec.rb +22 -9
- data/spec/cucumber/filters/tag_limits/test_case_index_spec.rb +11 -11
- data/spec/cucumber/filters/tag_limits/verifier_spec.rb +14 -14
- data/spec/cucumber/filters/tag_limits_spec.rb +8 -8
- data/spec/cucumber/formatter/ansicolor_spec.rb +9 -9
- data/spec/cucumber/formatter/backtrace_filter_spec.rb +32 -0
- data/spec/cucumber/formatter/console_counts_spec.rb +1 -1
- data/spec/cucumber/formatter/duration_spec.rb +3 -3
- data/spec/cucumber/formatter/fail_fast_spec.rb +21 -21
- data/spec/cucumber/formatter/html_spec.rb +58 -58
- data/spec/cucumber/formatter/json_spec.rb +44 -46
- data/spec/cucumber/formatter/junit_spec.rb +43 -45
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +43 -43
- data/spec/cucumber/formatter/pretty_spec.rb +107 -107
- data/spec/cucumber/formatter/progress_spec.rb +20 -20
- data/spec/cucumber/formatter/rerun_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +6 -5
- data/spec/cucumber/{rb_support/rb_world_spec.rb → glue/proto_world_spec.rb} +20 -5
- data/spec/cucumber/glue/registry_and_more_spec.rb +213 -0
- data/spec/cucumber/{rb_support → glue}/snippet_spec.rb +61 -25
- data/spec/cucumber/glue/step_definition_spec.rb +207 -0
- data/spec/cucumber/hooks_spec.rb +3 -3
- data/spec/cucumber/multiline_argument/data_table_spec.rb +177 -133
- data/spec/cucumber/project_initializer_spec.rb +10 -10
- data/spec/cucumber/rake/forked_spec.rb +10 -10
- data/spec/cucumber/rake/task_spec.rb +20 -20
- data/spec/cucumber/running_test_case_spec.rb +35 -35
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -30
- data/spec/cucumber/runtime_spec.rb +2 -2
- data/spec/cucumber/step_argument_spec.rb +5 -5
- data/spec/cucumber/step_match_search_spec.rb +31 -41
- data/spec/cucumber/step_match_spec.rb +33 -33
- data/spec/cucumber/world/pending_spec.rb +10 -10
- metadata +117 -47
- data/features/docs/formatters/debug_formatter.feature +0 -47
- data/features/docs/writing_support_code/transforms.feature +0 -98
- data/features/lib/step_definitions/wire_steps.rb +0 -59
- data/gem_tasks/cucumber.rake +0 -26
- data/lib/cucumber/core_ext/instance_exec.rb +0 -71
- data/lib/cucumber/formatter/debug.rb +0 -36
- data/lib/cucumber/rb_support/rb_hook.rb +0 -20
- data/lib/cucumber/rb_support/rb_step_definition.rb +0 -132
- data/lib/cucumber/rb_support/rb_transform.rb +0 -60
- data/lib/cucumber/rb_support/rb_world.rb +0 -171
- data/spec/cucumber/core_ext/instance_exec_spec.rb +0 -5
- data/spec/cucumber/formatter/debug_spec.rb +0 -65
- data/spec/cucumber/rb_support/rb_language_spec.rb +0 -321
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +0 -200
- data/spec/cucumber/rb_support/rb_transform_spec.rb +0 -47
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Cucumber
|
3
|
-
module
|
4
|
+
module Glue
|
4
5
|
module Snippet
|
5
6
|
|
6
7
|
ARGUMENT_PATTERNS = ['"([^"]*)"', '(\d+)']
|
@@ -10,22 +11,27 @@ module Cucumber
|
|
10
11
|
configuration.snippet_generators << new
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def initialize(cucumber_expression_generator)
|
15
|
+
@cucumber_expression_generator = cucumber_expression_generator
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(code_keyword, step_name, multiline_arg, snippet_type)
|
14
19
|
snippet_class = typed_snippet_class(snippet_type)
|
15
|
-
snippet_class.new(code_keyword, step_name, multiline_arg).to_s
|
20
|
+
snippet_class.new(@cucumber_expression_generator, code_keyword, step_name, multiline_arg).to_s
|
16
21
|
end
|
17
22
|
|
18
23
|
def typed_snippet_class(type)
|
19
|
-
SNIPPET_TYPES.fetch(type || :
|
24
|
+
SNIPPET_TYPES.fetch(type || :cucumber_expression)
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
class BaseSnippet
|
24
29
|
|
25
|
-
def initialize(code_keyword,
|
30
|
+
def initialize(cucumber_expression_generator, code_keyword, step_name, multiline_argument)
|
26
31
|
@number_of_arguments = 0
|
27
32
|
@code_keyword = code_keyword
|
28
|
-
@pattern = replace_and_count_capturing_groups(
|
33
|
+
@pattern = replace_and_count_capturing_groups(step_name)
|
34
|
+
@generated_expressions = cucumber_expression_generator.generate_expressions(step_name)
|
29
35
|
@multiline_argument = MultilineArgumentSnippet.new(multiline_argument)
|
30
36
|
end
|
31
37
|
|
@@ -37,13 +43,13 @@ module Cucumber
|
|
37
43
|
"#{code_keyword}#{typed_pattern}"
|
38
44
|
end
|
39
45
|
|
40
|
-
def self.cli_option_string(type)
|
41
|
-
|
46
|
+
def self.cli_option_string(type, cucumber_expression_generator)
|
47
|
+
format('%-7s: %-28s e.g. %s', type, description, example(cucumber_expression_generator))
|
42
48
|
end
|
43
49
|
|
44
50
|
private
|
45
51
|
|
46
|
-
attr_reader :code_keyword, :pattern, :multiline_argument, :number_of_arguments
|
52
|
+
attr_reader :code_keyword, :pattern, :generated_expressions, :multiline_argument, :number_of_arguments
|
47
53
|
|
48
54
|
def replace_and_count_capturing_groups(pattern)
|
49
55
|
modified_pattern = ::Regexp.escape(pattern).gsub('\ ', ' ').gsub('/', '\/')
|
@@ -58,32 +64,62 @@ module Cucumber
|
|
58
64
|
|
59
65
|
def do_block
|
60
66
|
do_block = String.new
|
61
|
-
do_block << "do#{
|
67
|
+
do_block << "do#{parameters}\n"
|
62
68
|
multiline_argument.append_comment_to(do_block)
|
63
69
|
do_block << " pending # Write code here that turns the phrase above into concrete actions\n"
|
64
|
-
do_block <<
|
70
|
+
do_block << 'end'
|
65
71
|
do_block
|
66
72
|
end
|
67
73
|
|
68
|
-
def
|
74
|
+
def parameters
|
69
75
|
block_args = (0...number_of_arguments).map { |n| "arg#{n+1}" }
|
70
|
-
multiline_argument.
|
71
|
-
block_args.empty? ?
|
76
|
+
multiline_argument.append_block_parameter_to(block_args)
|
77
|
+
block_args.empty? ? '' : " |#{block_args.join(", ")}|"
|
72
78
|
end
|
73
79
|
|
74
|
-
def self.example
|
75
|
-
new(
|
80
|
+
def self.example(cucumber_expression_generator)
|
81
|
+
new(cucumber_expression_generator, 'Given', 'I have 2 cukes', MultilineArgument::None.new).step
|
76
82
|
end
|
77
83
|
|
78
84
|
end
|
79
85
|
|
86
|
+
class CucumberExpression < BaseSnippet
|
87
|
+
def typed_pattern
|
88
|
+
"(\"#{generated_expressions[0].source}\")"
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_s
|
92
|
+
header = generated_expressions.each_with_index.map do |expr, i|
|
93
|
+
prefix = i == 0 ? '' : '# '
|
94
|
+
"#{prefix}#{code_keyword}(\"#{expr.source}\") do#{parameters(expr)}"
|
95
|
+
end.join("\n")
|
96
|
+
|
97
|
+
body = String.new
|
98
|
+
multiline_argument.append_comment_to(body)
|
99
|
+
body << " pending # Write code here that turns the phrase above into concrete actions\n"
|
100
|
+
body << 'end'
|
101
|
+
|
102
|
+
"#{header}\n#{body}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def parameters(expr)
|
106
|
+
parameter_names = expr.parameter_names
|
107
|
+
multiline_argument.append_block_parameter_to(parameter_names)
|
108
|
+
parameter_names.empty? ? '' : " |#{parameter_names.join(", ")}|"
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.description
|
112
|
+
'Cucumber Expressions'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
80
116
|
class Regexp < BaseSnippet
|
81
117
|
def typed_pattern
|
82
118
|
"(/^#{pattern}$/)"
|
83
119
|
end
|
84
120
|
|
85
121
|
def self.description
|
86
|
-
|
122
|
+
'Snippets with parentheses'
|
87
123
|
end
|
88
124
|
end
|
89
125
|
|
@@ -93,7 +129,7 @@ module Cucumber
|
|
93
129
|
end
|
94
130
|
|
95
131
|
def self.description
|
96
|
-
|
132
|
+
'Snippets without parentheses. Note that these cause a warning from modern versions of Ruby.'
|
97
133
|
end
|
98
134
|
end
|
99
135
|
|
@@ -103,11 +139,12 @@ module Cucumber
|
|
103
139
|
end
|
104
140
|
|
105
141
|
def self.description
|
106
|
-
|
142
|
+
'Snippets with percent regexp'
|
107
143
|
end
|
108
144
|
end
|
109
145
|
|
110
146
|
SNIPPET_TYPES = {
|
147
|
+
:cucumber_expression => CucumberExpression,
|
111
148
|
:regexp => Regexp,
|
112
149
|
:classic => Classic,
|
113
150
|
:percent => Percent
|
@@ -122,11 +159,11 @@ module Cucumber
|
|
122
159
|
end
|
123
160
|
|
124
161
|
class Builder
|
125
|
-
def doc_string(*
|
162
|
+
def doc_string(*_args)
|
126
163
|
@result = DocString.new
|
127
164
|
end
|
128
165
|
|
129
|
-
def data_table(table, *
|
166
|
+
def data_table(table, *_args)
|
130
167
|
@result = DataTable.new(table)
|
131
168
|
end
|
132
169
|
|
@@ -136,7 +173,7 @@ module Cucumber
|
|
136
173
|
end
|
137
174
|
|
138
175
|
class DocString
|
139
|
-
def
|
176
|
+
def append_block_parameter_to(array)
|
140
177
|
array << 'string'
|
141
178
|
end
|
142
179
|
|
@@ -149,17 +186,17 @@ module Cucumber
|
|
149
186
|
@table = table
|
150
187
|
end
|
151
188
|
|
152
|
-
def
|
189
|
+
def append_block_parameter_to(array)
|
153
190
|
array << 'table'
|
154
191
|
end
|
155
192
|
|
156
193
|
def append_comment_to(string)
|
157
|
-
string << " # table is a #{Cucumber::MultilineArgument::DataTable
|
194
|
+
string << " # table is a #{Cucumber::MultilineArgument::DataTable}\n"
|
158
195
|
end
|
159
196
|
end
|
160
197
|
|
161
198
|
class None
|
162
|
-
def
|
199
|
+
def append_block_parameter_to(array)
|
163
200
|
end
|
164
201
|
|
165
202
|
def append_comment_to(string)
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'cucumber/step_match'
|
3
|
+
require 'cucumber/step_argument'
|
4
|
+
require 'cucumber/core_ext/string'
|
5
|
+
require 'cucumber/glue/invoke_in_world'
|
6
|
+
|
7
|
+
module Cucumber
|
8
|
+
module Glue
|
9
|
+
# A Step Definition holds a Regexp pattern and a Proc, and is
|
10
|
+
# typically created by calling {Dsl#register_rb_step_definition Given, When or Then}
|
11
|
+
# in the step_definitions Ruby files.
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
#
|
15
|
+
# Given /I have (\d+) cucumbers in my belly/ do
|
16
|
+
# # some code here
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
class StepDefinition
|
20
|
+
|
21
|
+
class MissingProc < StandardError
|
22
|
+
def message
|
23
|
+
'Step definitions must always have a proc or symbol'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def new(registry, string_or_regexp, proc_or_sym, options)
|
29
|
+
raise MissingProc if proc_or_sym.nil?
|
30
|
+
super registry, registry.create_expression(string_or_regexp), create_proc(proc_or_sym, options)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def create_proc(proc_or_sym, options)
|
36
|
+
return proc_or_sym if proc_or_sym.is_a?(Proc)
|
37
|
+
raise ArgumentError unless proc_or_sym.is_a?(Symbol)
|
38
|
+
message = proc_or_sym
|
39
|
+
target_proc = parse_target_proc_from(options)
|
40
|
+
patch_location_onto lambda { |*args|
|
41
|
+
target = instance_exec(&target_proc)
|
42
|
+
target.send(message, *args)
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def patch_location_onto(block)
|
47
|
+
location = Core::Ast::Location.of_caller(5)
|
48
|
+
block.define_singleton_method(:source_location) { [location.file, location.line] }
|
49
|
+
block
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_target_proc_from(options)
|
53
|
+
return lambda { self } unless options.key?(:on)
|
54
|
+
target = options[:on]
|
55
|
+
case target
|
56
|
+
when Proc
|
57
|
+
target
|
58
|
+
when Symbol
|
59
|
+
lambda { self.send(target) }
|
60
|
+
else
|
61
|
+
lambda { raise ArgumentError, 'Target must be a symbol or a proc' }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_reader :expression
|
67
|
+
|
68
|
+
def initialize(registry, expression, proc)
|
69
|
+
raise 'No regexp' if expression.is_a?(Regexp)
|
70
|
+
@registry, @expression, @proc = registry, expression, proc
|
71
|
+
# @registry.available_step_definition(regexp_source, location)
|
72
|
+
end
|
73
|
+
|
74
|
+
# @api private
|
75
|
+
def to_hash
|
76
|
+
type = expression.is_a?(CucumberExpressions::RegularExpression) ? 'regular expression' : 'cucumber expression'
|
77
|
+
regexp = expression.regexp
|
78
|
+
flags = ''
|
79
|
+
flags += 'm' if (regexp.options & Regexp::MULTILINE) != 0
|
80
|
+
flags += 'i' if (regexp.options & Regexp::IGNORECASE) != 0
|
81
|
+
flags += 'x' if (regexp.options & Regexp::EXTENDED) != 0
|
82
|
+
{
|
83
|
+
source: {
|
84
|
+
type: type,
|
85
|
+
expression: expression.source
|
86
|
+
},
|
87
|
+
regexp: {
|
88
|
+
source: regexp.source,
|
89
|
+
flags: flags
|
90
|
+
}
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# @api private
|
95
|
+
def ==(step_definition)
|
96
|
+
expression.source == step_definition.expression.source
|
97
|
+
end
|
98
|
+
|
99
|
+
# @api private
|
100
|
+
def arguments_from(step_name)
|
101
|
+
args = @expression.match(step_name)
|
102
|
+
# @registry.invoked_step_definition(regexp_source, location) if args
|
103
|
+
args
|
104
|
+
end
|
105
|
+
|
106
|
+
# @api private
|
107
|
+
# TODO: inline this and step definition just be a value object
|
108
|
+
def invoke(args)
|
109
|
+
begin
|
110
|
+
InvokeInWorld.cucumber_instance_exec_in(@registry.current_world, true, @expression.to_s, *args, &@proc)
|
111
|
+
rescue ArityMismatchError => e
|
112
|
+
e.backtrace.unshift(self.backtrace_line)
|
113
|
+
raise e
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# @api private
|
118
|
+
def backtrace_line
|
119
|
+
"#{location}:in `#{@expression}'"
|
120
|
+
end
|
121
|
+
|
122
|
+
# @api private
|
123
|
+
def file_colon_line
|
124
|
+
case @proc
|
125
|
+
when Proc
|
126
|
+
location.to_s
|
127
|
+
when Symbol
|
128
|
+
":#{@proc}"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# The source location where the step defintion can be found
|
133
|
+
def location
|
134
|
+
@location ||= Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
|
135
|
+
end
|
136
|
+
|
137
|
+
# @api private
|
138
|
+
def file
|
139
|
+
@file ||= location.file
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Glue
|
3
|
+
|
4
|
+
class WorldFactory
|
5
|
+
def initialize(proc)
|
6
|
+
@proc = proc || -> { Object.new }
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_world
|
10
|
+
@proc.call || raise_nil_world
|
11
|
+
end
|
12
|
+
|
13
|
+
def raise_nil_world
|
14
|
+
raise NilWorld.new
|
15
|
+
rescue NilWorld => e
|
16
|
+
e.backtrace.clear
|
17
|
+
e.backtrace.push(Glue.backtrace_line(@proc, 'World'))
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/cucumber/hooks.rb
CHANGED
@@ -23,7 +23,7 @@ module Cucumber
|
|
23
23
|
build_hook_step(source, location, block, AfterStepHook, Core::Test::Action)
|
24
24
|
end
|
25
25
|
|
26
|
-
def around_hook(
|
26
|
+
def around_hook(_source, &block)
|
27
27
|
Core::Test::AroundHook.new(&block)
|
28
28
|
end
|
29
29
|
|
@@ -44,7 +44,7 @@ module Cucumber
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def name
|
47
|
-
|
47
|
+
'After hook'
|
48
48
|
end
|
49
49
|
|
50
50
|
def match_locations?(queried_locations)
|
@@ -64,7 +64,7 @@ module Cucumber
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def name
|
67
|
-
|
67
|
+
'Before hook'
|
68
68
|
end
|
69
69
|
|
70
70
|
def match_locations?(queried_locations)
|
@@ -84,7 +84,7 @@ module Cucumber
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def name
|
87
|
-
|
87
|
+
'AfterStep hook'
|
88
88
|
end
|
89
89
|
|
90
90
|
def match_locations?(queried_locations)
|
@@ -49,11 +49,11 @@ module Cucumber
|
|
49
49
|
@result
|
50
50
|
end
|
51
51
|
|
52
|
-
def doc_string(node, *
|
52
|
+
def doc_string(node, *_args)
|
53
53
|
@result = DocString.new(node)
|
54
54
|
end
|
55
55
|
|
56
|
-
def data_table(node, *
|
56
|
+
def data_table(node, *_args)
|
57
57
|
@result = DataTable.new(node)
|
58
58
|
end
|
59
59
|
end
|
@@ -3,6 +3,7 @@ require 'forwardable'
|
|
3
3
|
require 'cucumber/gherkin/data_table_parser'
|
4
4
|
require 'cucumber/gherkin/formatter/escaping'
|
5
5
|
require 'cucumber/core/ast/describes_itself'
|
6
|
+
require 'cucumber/multiline_argument/data_table/diff_matrices'
|
6
7
|
|
7
8
|
module Cucumber
|
8
9
|
module MultilineArgument
|
@@ -26,38 +27,10 @@ module Cucumber
|
|
26
27
|
# This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
|
27
28
|
#
|
28
29
|
class DataTable
|
29
|
-
class Different < StandardError
|
30
|
-
def initialize(table)
|
31
|
-
super("Tables were not identical:\n#{table}")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Builder
|
36
|
-
attr_reader :rows
|
37
|
-
|
38
|
-
def initialize
|
39
|
-
@rows = []
|
40
|
-
end
|
41
|
-
|
42
|
-
def row(row)
|
43
|
-
@rows << row
|
44
|
-
end
|
45
|
-
|
46
|
-
def eof
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
include Enumerable
|
51
30
|
include Core::Ast::DescribesItself
|
52
|
-
extend Forwardable
|
53
|
-
|
54
|
-
NULL_CONVERSIONS = Hash.new({ :strict => false, :proc => lambda{ |cell_value| cell_value } }).freeze
|
55
|
-
|
56
|
-
attr_accessor :file
|
57
|
-
def_delegator :@ast_table, :location
|
58
31
|
|
59
32
|
def self.default_arg_name #:nodoc:
|
60
|
-
|
33
|
+
'table'
|
61
34
|
end
|
62
35
|
|
63
36
|
class << self
|
@@ -68,11 +41,12 @@ module Cucumber
|
|
68
41
|
when String
|
69
42
|
parse(data, location)
|
70
43
|
else
|
71
|
-
raise ArgumentError,
|
44
|
+
raise ArgumentError, 'expected data to be a String or an Array.'
|
72
45
|
end
|
73
46
|
end
|
74
47
|
|
75
48
|
private
|
49
|
+
|
76
50
|
def parse(text, location = Core::Ast::Location.of_caller)
|
77
51
|
builder = Builder.new
|
78
52
|
parser = Cucumber::Gherkin::DataTableParser.new(builder)
|
@@ -85,13 +59,30 @@ module Cucumber
|
|
85
59
|
end
|
86
60
|
end
|
87
61
|
|
62
|
+
class Builder
|
63
|
+
attr_reader :rows
|
64
|
+
|
65
|
+
def initialize
|
66
|
+
@rows = []
|
67
|
+
end
|
68
|
+
|
69
|
+
def row(row)
|
70
|
+
@rows << row
|
71
|
+
end
|
72
|
+
|
73
|
+
def eof
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
NULL_CONVERSIONS = Hash.new({ :strict => false, :proc => lambda{ |cell_value| cell_value } }).freeze
|
88
79
|
|
89
80
|
# @param data [Core::Ast::DataTable] the data for the table
|
90
81
|
# @param conversion_procs [Hash] see map_columns!
|
91
82
|
# @param header_mappings [Hash] see map_headers!
|
92
83
|
# @param header_conversion_proc [Proc] see map_headers!
|
93
84
|
def initialize(data, conversion_procs = NULL_CONVERSIONS.dup, header_mappings = {}, header_conversion_proc = nil)
|
94
|
-
raise ArgumentError,
|
85
|
+
raise ArgumentError, 'data must be a Core::Ast::DataTable' unless data.kind_of? Core::Ast::DataTable
|
95
86
|
ast_table = data
|
96
87
|
# Verify that it's square
|
97
88
|
ast_table.transpose
|
@@ -110,6 +101,12 @@ module Cucumber
|
|
110
101
|
dup
|
111
102
|
end
|
112
103
|
|
104
|
+
attr_accessor :file
|
105
|
+
|
106
|
+
def location
|
107
|
+
@ast_table.location
|
108
|
+
end
|
109
|
+
|
113
110
|
# Creates a copy of this table, inheriting any column and header mappings
|
114
111
|
# registered with #map_column! and #map_headers!.
|
115
112
|
#
|
@@ -337,80 +334,22 @@ module Cucumber
|
|
337
334
|
# a Table argument, if you want to compare that table to some actual values.
|
338
335
|
#
|
339
336
|
def diff!(other_table, options={})
|
340
|
-
options = {
|
341
|
-
:missing_row => true,
|
342
|
-
:surplus_row => true,
|
343
|
-
:missing_col => true,
|
344
|
-
:surplus_col => false,
|
345
|
-
:misplaced_col => false
|
346
|
-
}.merge(options)
|
347
|
-
|
348
337
|
other_table = ensure_table(other_table)
|
349
338
|
other_table.convert_headers!
|
350
339
|
other_table.convert_columns!
|
351
|
-
ensure_green!
|
352
340
|
|
353
341
|
convert_headers!
|
354
342
|
convert_columns!
|
355
343
|
|
356
|
-
|
357
|
-
|
358
|
-
padded_width = cell_matrix[0].length
|
359
|
-
|
360
|
-
missing_col = cell_matrix[0].detect{|cell| cell.status == :undefined}
|
361
|
-
surplus_col = padded_width > original_width
|
362
|
-
misplaced_col = cell_matrix[0] != other_table.cell_matrix[0]
|
363
|
-
|
364
|
-
require_diff_lcs
|
365
|
-
cell_matrix.extend(Diff::LCS)
|
366
|
-
changes = cell_matrix.diff(other_table_cell_matrix).flatten
|
367
|
-
|
368
|
-
inserted = 0
|
369
|
-
missing = 0
|
370
|
-
|
371
|
-
row_indices = Array.new(other_table_cell_matrix.length) {|n| n}
|
372
|
-
|
373
|
-
last_change = nil
|
374
|
-
missing_row_pos = nil
|
375
|
-
insert_row_pos = nil
|
376
|
-
|
377
|
-
changes.each do |change|
|
378
|
-
if(change.action == '-')
|
379
|
-
missing_row_pos = change.position + inserted
|
380
|
-
cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
|
381
|
-
row_indices.insert(missing_row_pos, nil)
|
382
|
-
missing += 1
|
383
|
-
else # '+'
|
384
|
-
insert_row_pos = change.position + missing
|
385
|
-
inserted_row = change.element
|
386
|
-
inserted_row.each{|cell| cell.status = :comment}
|
387
|
-
cell_matrix.insert(insert_row_pos, inserted_row)
|
388
|
-
row_indices[insert_row_pos] = nil
|
389
|
-
inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change && last_change.action == '-'
|
390
|
-
inserted += 1
|
391
|
-
end
|
392
|
-
last_change = change
|
393
|
-
end
|
344
|
+
DiffMatrices.new(cell_matrix, other_table.cell_matrix, options).call
|
345
|
+
end
|
394
346
|
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
surplus_cell = other_row[col_index]
|
401
|
-
row[col_index].value = surplus_cell.value if row[col_index]
|
402
|
-
end
|
403
|
-
end
|
347
|
+
class Different < StandardError
|
348
|
+
attr_reader :table
|
349
|
+
def initialize(table)
|
350
|
+
@table = table
|
351
|
+
super("Tables were not identical:\n#{table}")
|
404
352
|
end
|
405
|
-
|
406
|
-
clear_cache!
|
407
|
-
should_raise =
|
408
|
-
missing_row_pos && options[:missing_row] ||
|
409
|
-
insert_row_pos && options[:surplus_row] ||
|
410
|
-
missing_col && options[:missing_col] ||
|
411
|
-
surplus_col && options[:surplus_col] ||
|
412
|
-
misplaced_col && options[:misplaced_col]
|
413
|
-
raise Different.new(self) if should_raise
|
414
353
|
end
|
415
354
|
|
416
355
|
def to_hash(cells) #:nodoc:
|
@@ -453,9 +392,7 @@ module Cucumber
|
|
453
392
|
cells_rows[0][col]
|
454
393
|
end
|
455
394
|
|
456
|
-
|
457
|
-
@cell_matrix
|
458
|
-
end
|
395
|
+
attr_reader :cell_matrix
|
459
396
|
|
460
397
|
def col_width(col) #:nodoc:
|
461
398
|
columns[col].__send__(:width)
|
@@ -476,7 +413,7 @@ module Cucumber
|
|
476
413
|
Formatter::LegacyApi::Ast::MultilineArg.for(self).accept(Formatter::Fanout.new([formatter]))
|
477
414
|
Cucumber::Term::ANSIColor.coloring = c
|
478
415
|
io.rewind
|
479
|
-
s = "\n" + io.read + (
|
416
|
+
s = "\n" + io.read + (' ' * (options[:indent] - 2))
|
480
417
|
s
|
481
418
|
end
|
482
419
|
|
@@ -494,11 +431,10 @@ module Cucumber
|
|
494
431
|
raw.to_json(*args)
|
495
432
|
end
|
496
433
|
|
497
|
-
private
|
498
|
-
|
499
434
|
TO_S_PREFIXES = Hash.new(' ')
|
500
435
|
TO_S_PREFIXES[:comment] = '(+) '
|
501
436
|
TO_S_PREFIXES[:undefined] = '(-) '
|
437
|
+
private_constant :TO_S_PREFIXES
|
502
438
|
|
503
439
|
protected
|
504
440
|
|
@@ -510,16 +446,6 @@ module Cucumber
|
|
510
446
|
end
|
511
447
|
end
|
512
448
|
|
513
|
-
def inspect_rows(missing_row, inserted_row) #:nodoc:
|
514
|
-
missing_row.each_with_index do |missing_cell, col|
|
515
|
-
inserted_cell = inserted_row[col]
|
516
|
-
if(missing_cell.value != inserted_cell.value && (missing_cell.value.to_s == inserted_cell.value.to_s))
|
517
|
-
missing_cell.inspect!
|
518
|
-
inserted_cell.inspect!
|
519
|
-
end
|
520
|
-
end
|
521
|
-
end
|
522
|
-
|
523
449
|
def create_cell_matrix(ast_table) #:nodoc:
|
524
450
|
ast_table.raw.map do |raw_row|
|
525
451
|
line = raw_row.line rescue -1
|
@@ -556,85 +482,21 @@ module Cucumber
|
|
556
482
|
raise "No headers matched #{pre.inspect}" if mapped_cells.empty?
|
557
483
|
raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map { |c| c.value }.inspect}" if mapped_cells.length > 1
|
558
484
|
mapped_cells[0].value = post
|
559
|
-
if @conversion_procs.
|
485
|
+
if @conversion_procs.key?(pre)
|
560
486
|
@conversion_procs[post] = @conversion_procs.delete(pre)
|
561
487
|
end
|
562
488
|
end
|
563
489
|
end
|
564
490
|
|
565
|
-
def require_diff_lcs #:nodoc:
|
566
|
-
begin
|
567
|
-
require 'diff/lcs'
|
568
|
-
rescue LoadError => e
|
569
|
-
e.message << "\n Please gem install diff-lcs\n"
|
570
|
-
raise e
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
491
|
def clear_cache! #:nodoc:
|
575
492
|
@hashes = @rows_hash = @col_names = @rows = @columns = nil
|
576
493
|
end
|
577
494
|
|
578
|
-
# Pads two cell matrices to same column width and matches columns according to header value.
|
579
|
-
# The first cell matrix is the reference matrix with the second matrix matched against it.
|
580
|
-
def pad_and_match(a_cell_matrix, other_cell_matrix) #:nodoc:
|
581
|
-
clear_cache!
|
582
|
-
cols = a_cell_matrix.transpose
|
583
|
-
unmatched_cols = other_cell_matrix.transpose
|
584
|
-
|
585
|
-
|
586
|
-
header_values = cols.map(&:first)
|
587
|
-
matched_cols = []
|
588
|
-
|
589
|
-
header_values.each_with_index do |v, i|
|
590
|
-
mapped_index = unmatched_cols.index{|unmapped_col| unmapped_col.first == v}
|
591
|
-
if (mapped_index)
|
592
|
-
matched_cols << unmatched_cols.delete_at(mapped_index)
|
593
|
-
else
|
594
|
-
mark_as_missing(cols[i])
|
595
|
-
empty_col = other_cell_matrix.collect {SurplusCell.new(nil, self, -1)}
|
596
|
-
empty_col.first.value = v
|
597
|
-
matched_cols << empty_col
|
598
|
-
end
|
599
|
-
end
|
600
|
-
|
601
|
-
|
602
|
-
empty_col = cell_matrix.collect {SurplusCell.new(nil, self, -1)}
|
603
|
-
unmatched_cols.each do
|
604
|
-
cols << empty_col
|
605
|
-
end
|
606
|
-
|
607
|
-
return cols.transpose, (matched_cols + unmatched_cols).transpose
|
608
|
-
end
|
609
|
-
|
610
495
|
def ensure_table(table_or_array) #:nodoc:
|
611
496
|
return table_or_array if DataTable === table_or_array
|
612
497
|
DataTable.from(table_or_array)
|
613
498
|
end
|
614
499
|
|
615
|
-
def ensure_array_of_array(array)
|
616
|
-
Hash === array[0] ? hashes_to_array(array) : array
|
617
|
-
end
|
618
|
-
|
619
|
-
def hashes_to_array(hashes) #:nodoc:
|
620
|
-
header = hashes[0].keys.sort
|
621
|
-
[header] + hashes.map{|hash| header.map{|key| hash[key]}}
|
622
|
-
end
|
623
|
-
|
624
|
-
def ensure_green! #:nodoc:
|
625
|
-
each_cell{|cell| cell.status = :passed}
|
626
|
-
end
|
627
|
-
|
628
|
-
def each_cell(&proc) #:nodoc:
|
629
|
-
cell_matrix.each{|row| row.each(&proc)}
|
630
|
-
end
|
631
|
-
|
632
|
-
def mark_as_missing(col) #:nodoc:
|
633
|
-
col.each do |cell|
|
634
|
-
cell.status = :undefined
|
635
|
-
end
|
636
|
-
end
|
637
|
-
|
638
500
|
def symbolize_key(key)
|
639
501
|
key.downcase.tr(' ', '_').to_sym
|
640
502
|
end
|
@@ -733,7 +595,7 @@ module Cucumber
|
|
733
595
|
:comment
|
734
596
|
end
|
735
597
|
|
736
|
-
def ==(
|
598
|
+
def ==(_o)
|
737
599
|
true
|
738
600
|
end
|
739
601
|
|