cucumber 3.1.0 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -3
- data/CONTRIBUTING.md +1 -0
- data/README.md +6 -7
- data/lib/autotest/cucumber.rb +1 -0
- data/lib/autotest/cucumber_mixin.rb +1 -0
- data/lib/autotest/cucumber_rails.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec.rb +1 -0
- data/lib/autotest/cucumber_rails_rspec2.rb +1 -0
- data/lib/autotest/cucumber_rspec.rb +1 -0
- data/lib/autotest/cucumber_rspec2.rb +1 -0
- data/lib/autotest/discover.rb +1 -0
- data/lib/cucumber.rb +1 -0
- data/lib/cucumber/cli/configuration.rb +1 -0
- data/lib/cucumber/cli/main.rb +2 -2
- data/lib/cucumber/cli/options.rb +54 -52
- data/lib/cucumber/cli/profile_loader.rb +5 -7
- data/lib/cucumber/cli/rerun_file.rb +1 -0
- data/lib/cucumber/configuration.rb +8 -7
- data/lib/cucumber/constantize.rb +6 -5
- data/lib/cucumber/core_ext/string.rb +1 -0
- data/lib/cucumber/deprecate.rb +1 -1
- data/lib/cucumber/encoding.rb +2 -1
- data/lib/cucumber/errors.rb +1 -0
- data/lib/cucumber/events.rb +1 -1
- data/lib/cucumber/events/gherkin_source_parsed.rb~ +14 -0
- data/lib/cucumber/events/gherkin_source_read.rb +1 -4
- data/lib/cucumber/events/step_activated.rb +4 -5
- data/lib/cucumber/events/step_definition_registered.rb +4 -8
- data/lib/cucumber/events/test_case_finished.rb +0 -4
- data/lib/cucumber/events/test_case_started.rb +0 -4
- data/lib/cucumber/events/test_run_finished.rb +2 -3
- data/lib/cucumber/events/test_run_started.rb +2 -4
- data/lib/cucumber/events/test_step_finished.rb +0 -4
- data/lib/cucumber/events/test_step_started.rb +1 -5
- data/lib/cucumber/file_specs.rb +2 -1
- data/lib/cucumber/filters.rb +1 -0
- data/lib/cucumber/filters/activate_steps.rb +1 -1
- data/lib/cucumber/filters/apply_after_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_after_step_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_around_hooks.rb +1 -0
- data/lib/cucumber/filters/apply_before_hooks.rb +1 -0
- data/lib/cucumber/filters/broadcast_test_run_started_event.rb +2 -1
- data/lib/cucumber/filters/gated_receiver.rb +1 -2
- data/lib/cucumber/filters/prepare_world.rb +2 -5
- data/lib/cucumber/filters/quit.rb +2 -3
- data/lib/cucumber/filters/randomizer.rb +6 -7
- data/lib/cucumber/filters/retry.rb +2 -2
- data/lib/cucumber/filters/tag_limits.rb +2 -2
- data/lib/cucumber/filters/tag_limits/test_case_index.rb +1 -2
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -2
- data/lib/cucumber/formatter/ansicolor.rb +13 -12
- data/lib/cucumber/formatter/ast_lookup.rb~ +9 -0
- data/lib/cucumber/formatter/backtrace_filter.rb +1 -2
- data/lib/cucumber/formatter/console.rb +11 -12
- data/lib/cucumber/formatter/console_counts.rb +4 -4
- data/lib/cucumber/formatter/console_issues.rb +3 -3
- data/lib/cucumber/formatter/duration.rb +1 -0
- data/lib/cucumber/formatter/duration_extractor.rb +1 -1
- data/lib/cucumber/formatter/fail_fast.rb +9 -6
- data/lib/cucumber/formatter/fanout.rb +1 -3
- data/lib/cucumber/formatter/hook_query_visitor.rb +1 -0
- data/lib/cucumber/formatter/html.rb +27 -31
- data/lib/cucumber/formatter/html_builder.rb +2 -1
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -2
- data/lib/cucumber/formatter/interceptor.rb +18 -5
- data/lib/cucumber/formatter/io.rb +1 -0
- data/lib/cucumber/formatter/json.rb +3 -2
- data/lib/cucumber/formatter/json_pretty.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +16 -15
- data/lib/cucumber/formatter/pretty.rb +4 -3
- data/lib/cucumber/formatter/progress.rb +3 -2
- data/lib/cucumber/formatter/rerun.rb +1 -0
- data/lib/cucumber/formatter/stepdefs.rb +1 -0
- data/lib/cucumber/formatter/steps.rb +2 -2
- data/lib/cucumber/formatter/summary.rb +1 -1
- data/lib/cucumber/formatter/unicode.rb +2 -2
- data/lib/cucumber/formatter/usage.rb +22 -19
- data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +86 -85
- data/lib/cucumber/gherkin/formatter/escaping.rb +13 -12
- data/lib/cucumber/gherkin/i18n.rb +1 -0
- data/lib/cucumber/gherkin/steps_parser.rb +1 -0
- data/lib/cucumber/glue/dsl.rb +1 -0
- data/lib/cucumber/glue/hook.rb +1 -0
- data/lib/cucumber/glue/invoke_in_world.rb +3 -3
- data/lib/cucumber/glue/proto_world.rb +8 -9
- data/lib/cucumber/glue/registry_and_more.rb +13 -12
- data/lib/cucumber/glue/snippet.rb +1 -5
- data/lib/cucumber/glue/step_definition.rb +9 -9
- data/lib/cucumber/glue/world_factory.rb +0 -2
- data/lib/cucumber/hooks.rb +1 -3
- data/lib/cucumber/load_path.rb +1 -0
- data/lib/cucumber/multiline_argument.rb +2 -2
- data/lib/cucumber/multiline_argument/data_table.rb +10 -10
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +7 -10
- data/lib/cucumber/multiline_argument/doc_string.rb +1 -0
- data/lib/cucumber/platform.rb +2 -1
- data/lib/cucumber/project_initializer.rb +1 -1
- data/lib/cucumber/rake/task.rb +8 -5
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -0
- data/lib/cucumber/rspec/doubles.rb +1 -0
- data/lib/cucumber/running_test_case.rb +2 -1
- data/lib/cucumber/runtime.rb +6 -6
- data/lib/cucumber/runtime/after_hooks.rb +1 -0
- data/lib/cucumber/runtime/before_hooks.rb +1 -0
- data/lib/cucumber/runtime/for_programming_languages.rb +8 -7
- data/lib/cucumber/runtime/step_hooks.rb +2 -0
- data/lib/cucumber/runtime/support_code.rb +3 -7
- data/lib/cucumber/runtime/user_interface.rb +2 -3
- data/lib/cucumber/step_argument.rb +1 -0
- data/lib/cucumber/step_definition_light.rb +2 -1
- data/lib/cucumber/step_definitions.rb +1 -0
- data/lib/cucumber/step_match.rb +5 -7
- data/lib/cucumber/step_match_search.rb +7 -8
- data/lib/cucumber/term/ansicolor.rb +30 -30
- data/lib/cucumber/unit.rb +1 -0
- data/lib/cucumber/version +1 -1
- data/lib/simplecov_setup.rb +1 -0
- metadata +64 -118
@@ -26,7 +26,7 @@ module Cucumber
|
|
26
26
|
@original_header = other_table_cell_matrix[0]
|
27
27
|
pad_and_match
|
28
28
|
@padded_width = cell_matrix[0].length
|
29
|
-
@row_indices = Array.new(other_table_cell_matrix.length) {|n| n}
|
29
|
+
@row_indices = Array.new(other_table_cell_matrix.length) { |n| n }
|
30
30
|
end
|
31
31
|
|
32
32
|
# Pads two cell matrices to same column width and matches columns according to header value.
|
@@ -38,19 +38,19 @@ module Cucumber
|
|
38
38
|
matched_cols = []
|
39
39
|
|
40
40
|
header_values.each_with_index do |v, i|
|
41
|
-
mapped_index = unmatched_cols.index{|unmapped_col| unmapped_col.first == v}
|
41
|
+
mapped_index = unmatched_cols.index { |unmapped_col| unmapped_col.first == v }
|
42
42
|
if mapped_index
|
43
43
|
matched_cols << unmatched_cols.delete_at(mapped_index)
|
44
44
|
else
|
45
45
|
mark_as_missing(cols[i])
|
46
|
-
empty_col = ensure_2d(other_table_cell_matrix).collect {SurplusCell.new(nil, self, -1)}
|
46
|
+
empty_col = ensure_2d(other_table_cell_matrix).collect { SurplusCell.new(nil, self, -1) }
|
47
47
|
empty_col.first.value = v
|
48
48
|
matched_cols << empty_col
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
unmatched_cols.each do
|
53
|
-
empty_col = cell_matrix.collect {SurplusCell.new(nil, self, -1)}
|
53
|
+
empty_col = cell_matrix.collect { SurplusCell.new(nil, self, -1) }
|
54
54
|
cols << empty_col
|
55
55
|
end
|
56
56
|
|
@@ -68,7 +68,6 @@ module Cucumber
|
|
68
68
|
array[0].is_a?(Array) ? array : [array]
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
71
|
def perform_diff
|
73
72
|
inserted = 0
|
74
73
|
missing = 0
|
@@ -77,13 +76,13 @@ module Cucumber
|
|
77
76
|
changes.each do |change|
|
78
77
|
if change.action == '-'
|
79
78
|
@missing_row_pos = change.position + inserted
|
80
|
-
cell_matrix[missing_row_pos].each{|cell| cell.status = :undefined}
|
79
|
+
cell_matrix[missing_row_pos].each { |cell| cell.status = :undefined }
|
81
80
|
row_indices.insert(missing_row_pos, nil)
|
82
81
|
missing += 1
|
83
82
|
else # '+'
|
84
83
|
@insert_row_pos = change.position + missing
|
85
84
|
inserted_row = change.element
|
86
|
-
inserted_row.each{|cell| cell.status = :comment}
|
85
|
+
inserted_row.each { |cell| cell.status = :comment }
|
87
86
|
cell_matrix.insert(insert_row_pos, inserted_row)
|
88
87
|
row_indices[insert_row_pos] = nil
|
89
88
|
inspect_rows(cell_matrix[missing_row_pos], inserted_row) if last_change == '-'
|
@@ -109,7 +108,6 @@ module Cucumber
|
|
109
108
|
end
|
110
109
|
end
|
111
110
|
|
112
|
-
|
113
111
|
def fill_in_missing_values
|
114
112
|
other_table_cell_matrix.each_with_index do |other_row, i|
|
115
113
|
row_index = row_indices.index(i)
|
@@ -123,7 +121,7 @@ module Cucumber
|
|
123
121
|
end
|
124
122
|
|
125
123
|
def missing_col
|
126
|
-
cell_matrix[0].find{|cell| cell.status == :undefined}
|
124
|
+
cell_matrix[0].find { |cell| cell.status == :undefined }
|
127
125
|
end
|
128
126
|
|
129
127
|
def surplus_col
|
@@ -134,7 +132,6 @@ module Cucumber
|
|
134
132
|
cell_matrix[0] != original_header
|
135
133
|
end
|
136
134
|
|
137
|
-
|
138
135
|
def raise_error
|
139
136
|
table = DataTable.from([[]])
|
140
137
|
table.instance_variable_set :@cell_matrix, cell_matrix
|
data/lib/cucumber/platform.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Detect the platform we're running on so we can tweak behaviour
|
3
4
|
# in various places.
|
4
5
|
require 'rbconfig'
|
@@ -17,7 +18,7 @@ module Cucumber
|
|
17
18
|
attr_accessor :use_full_backtrace
|
18
19
|
|
19
20
|
# @private
|
20
|
-
def file_mode(m, encoding='UTF-8')
|
21
|
+
def file_mode(m, encoding = 'UTF-8')
|
21
22
|
"#{m}:#{encoding}"
|
22
23
|
end
|
23
24
|
end
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/platform'
|
3
4
|
require 'cucumber/gherkin/formatter/ansi_escapes'
|
4
5
|
begin
|
5
6
|
# Support Rake > 0.8.7
|
6
7
|
require 'rake/dsl_definition'
|
8
|
+
# rubocop:disable Lint/HandleExceptions
|
7
9
|
rescue LoadError
|
10
|
+
# rubocop:enable Lint/HandleExceptions
|
8
11
|
end
|
9
12
|
|
10
13
|
module Cucumber
|
@@ -36,7 +39,7 @@ module Cucumber
|
|
36
39
|
|
37
40
|
def initialize(libs, cucumber_opts, feature_files)
|
38
41
|
raise 'libs must be an Array when running in-process' unless Array === libs
|
39
|
-
libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
|
42
|
+
libs.reverse.each { |lib| $LOAD_PATH.unshift(lib) }
|
40
43
|
@args = (
|
41
44
|
cucumber_opts +
|
42
45
|
feature_files
|
@@ -82,7 +85,7 @@ module Cucumber
|
|
82
85
|
def cmd
|
83
86
|
if use_bundler
|
84
87
|
[
|
85
|
-
Cucumber::RUBY_BINARY,'-S', 'bundle', 'exec', 'cucumber',
|
88
|
+
Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber',
|
86
89
|
@cucumber_opts, @feature_files
|
87
90
|
].flatten
|
88
91
|
else
|
@@ -151,14 +154,14 @@ module Cucumber
|
|
151
154
|
|
152
155
|
def runner(_task_args = nil) #:nodoc:
|
153
156
|
cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
|
154
|
-
if
|
157
|
+
if @fork
|
155
158
|
return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files)
|
156
159
|
end
|
157
160
|
InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
|
158
161
|
end
|
159
162
|
|
160
163
|
def cucumber_opts_with_profile #:nodoc:
|
161
|
-
Array(cucumber_opts).concat Array(@profile).flat_map {|p| ['--profile', p] }
|
164
|
+
Array(cucumber_opts).concat Array(@profile).flat_map { |p| ['--profile', p] }
|
162
165
|
end
|
163
166
|
|
164
167
|
def feature_files #:nodoc:
|
@@ -166,7 +169,7 @@ module Cucumber
|
|
166
169
|
end
|
167
170
|
|
168
171
|
def make_command_line_safe(list)
|
169
|
-
list.map{|string| string.gsub(' ', '\ ')}
|
172
|
+
list.map { |string| string.gsub(' ', '\ ') }
|
170
173
|
end
|
171
174
|
end
|
172
175
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'delegate'
|
3
4
|
|
4
5
|
module Cucumber
|
5
|
-
#
|
6
|
+
# Represents the current status of a running test case.
|
6
7
|
#
|
7
8
|
# This wraps a `Cucumber::Core::Test::Case` and delegates
|
8
9
|
# many methods to that object.
|
data/lib/cucumber/runtime.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
require 'fileutils'
|
4
5
|
require 'multi_json'
|
5
6
|
require 'cucumber/configuration'
|
@@ -105,7 +106,7 @@ module Cucumber
|
|
105
106
|
|
106
107
|
# Returns Ast::DocString for +string_without_triple_quotes+.
|
107
108
|
#
|
108
|
-
def doc_string(string_without_triple_quotes, content_type='', _line_offset=0)
|
109
|
+
def doc_string(string_without_triple_quotes, content_type = '', _line_offset = 0)
|
109
110
|
location = Core::Ast::Location.of_caller
|
110
111
|
Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
|
111
112
|
end
|
@@ -214,7 +215,8 @@ module Cucumber
|
|
214
215
|
formatter = factory.new(runtime_facade, path_or_io, cli_options)
|
215
216
|
Formatter::LegacyApi::Adapter.new(
|
216
217
|
Formatter::IgnoreMissingMessages.new(formatter),
|
217
|
-
results, @configuration
|
218
|
+
results, @configuration
|
219
|
+
)
|
218
220
|
end
|
219
221
|
|
220
222
|
def accept_options?(factory)
|
@@ -245,7 +247,7 @@ module Cucumber
|
|
245
247
|
filters << Cucumber::Core::Test::NameFilter.new(name_regexps)
|
246
248
|
filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations)
|
247
249
|
filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize?
|
248
|
-
#
|
250
|
+
# TODO: can we just use Glue::RegistryAndMore's step definitions directly?
|
249
251
|
step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration)
|
250
252
|
filters << Filters::ActivateSteps.new(step_match_search, @configuration)
|
251
253
|
@configuration.filters.each do |filter|
|
@@ -271,13 +273,11 @@ module Cucumber
|
|
271
273
|
end
|
272
274
|
|
273
275
|
def install_wire_plugin
|
274
|
-
Cucumber::Wire::Plugin.new(@configuration).install if @configuration.all_files_to_load.any? {|f| f =~ %r{\.wire$} }
|
276
|
+
Cucumber::Wire::Plugin.new(@configuration).install if @configuration.all_files_to_load.any? { |f| f =~ %r{\.wire$} }
|
275
277
|
end
|
276
278
|
|
277
279
|
def log
|
278
280
|
Cucumber.logger
|
279
281
|
end
|
280
|
-
|
281
282
|
end
|
282
|
-
|
283
283
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'forwardable'
|
3
4
|
require 'cucumber/core/ast/doc_string'
|
4
5
|
|
@@ -18,15 +19,15 @@ module Cucumber
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def_delegators :@user_interface,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
:embed,
|
23
|
+
:ask,
|
24
|
+
:puts,
|
25
|
+
:features_paths,
|
26
|
+
:step_match
|
26
27
|
|
27
28
|
def_delegators :@support_code,
|
28
|
-
|
29
|
-
|
29
|
+
:invoke_dynamic_steps,
|
30
|
+
:invoke_dynamic_step
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Cucumber
|
3
4
|
class Runtime
|
4
5
|
class StepHooks
|
@@ -13,6 +14,7 @@ module Cucumber
|
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
17
|
+
|
16
18
|
def after_step_hooks(test_step)
|
17
19
|
@hooks.map do |hook|
|
18
20
|
action = ->(*args) { hook.invoke('AfterStep', [args, test_step]) }
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/constantize'
|
3
4
|
require 'cucumber/runtime/for_programming_languages'
|
4
5
|
require 'cucumber/runtime/step_hooks'
|
@@ -8,14 +9,10 @@ require 'cucumber/gherkin/steps_parser'
|
|
8
9
|
require 'cucumber/step_match_search'
|
9
10
|
|
10
11
|
module Cucumber
|
11
|
-
|
12
12
|
class Runtime
|
13
|
-
|
14
13
|
class SupportCode
|
15
|
-
|
16
14
|
require 'forwardable'
|
17
15
|
class StepInvoker
|
18
|
-
|
19
16
|
def initialize(support_code)
|
20
17
|
@support_code = support_code
|
21
18
|
end
|
@@ -48,7 +45,7 @@ module Cucumber
|
|
48
45
|
|
49
46
|
attr_reader :registry
|
50
47
|
|
51
|
-
def initialize(user_interface, configuration=Configuration.default)
|
48
|
+
def initialize(user_interface, configuration = Configuration.default)
|
52
49
|
@configuration = configuration
|
53
50
|
# TODO: needs a better name, or inlining its methods
|
54
51
|
@runtime_facade = Runtime::ForProgrammingLanguages.new(self, user_interface)
|
@@ -76,7 +73,7 @@ module Cucumber
|
|
76
73
|
# steps which are compiled into test steps before execution.
|
77
74
|
#
|
78
75
|
# These are commonly called nested steps.
|
79
|
-
def invoke_dynamic_step(step_name, multiline_argument, _location=nil)
|
76
|
+
def invoke_dynamic_step(step_name, multiline_argument, _location = nil)
|
80
77
|
matches = step_matches(step_name)
|
81
78
|
raise UndefinedDynamicStep, step_name if matches.empty?
|
82
79
|
matches.first.invoke(multiline_argument)
|
@@ -150,7 +147,6 @@ module Cucumber
|
|
150
147
|
def log
|
151
148
|
Cucumber.logger
|
152
149
|
end
|
153
|
-
|
154
150
|
end
|
155
151
|
end
|
156
152
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'timeout'
|
3
4
|
|
4
5
|
module Cucumber
|
5
6
|
class Runtime
|
6
|
-
|
7
7
|
module UserInterface
|
8
8
|
attr_writer :visitor
|
9
9
|
|
@@ -33,7 +33,7 @@ module Cucumber
|
|
33
33
|
STDOUT.flush
|
34
34
|
puts(question)
|
35
35
|
|
36
|
-
answer = if
|
36
|
+
answer = if Cucumber::JRUBY
|
37
37
|
jruby_gets(timeout_seconds)
|
38
38
|
else
|
39
39
|
mri_gets(timeout_seconds)
|
@@ -74,6 +74,5 @@ module Cucumber
|
|
74
74
|
answer
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
78
77
|
end
|
79
78
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Cucumber
|
3
4
|
# TODO: pointless, ancient, kill with fire.
|
4
5
|
# Only used for keeping track of available and invoked step definitions
|
@@ -16,7 +17,7 @@ module Cucumber
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def hash
|
19
|
-
regexp_source.hash + 31*location.to_s.hash
|
20
|
+
regexp_source.hash + 31 * location.to_s.hash
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
data/lib/cucumber/step_match.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'cucumber/multiline_argument'
|
3
4
|
|
4
5
|
module Cucumber
|
5
|
-
|
6
6
|
# Represents the match found between a Test Step and its activation
|
7
7
|
class StepMatch #:nodoc:
|
8
8
|
attr_reader :step_definition, :step_arguments
|
@@ -46,7 +46,7 @@ module Cucumber
|
|
46
46
|
#
|
47
47
|
# lambda { |param| "[#{param}]" }
|
48
48
|
#
|
49
|
-
def format_args(format = lambda{|a| a}, &proc)
|
49
|
+
def format_args(format = lambda { |a| a }, &proc)
|
50
50
|
replace_arguments(@name_to_match, @step_arguments, format, &proc)
|
51
51
|
end
|
52
52
|
|
@@ -66,7 +66,7 @@ module Cucumber
|
|
66
66
|
@step_definition.expression.source.to_s.unpack('U*').length
|
67
67
|
end
|
68
68
|
|
69
|
-
def replace_arguments(string, step_arguments, format
|
69
|
+
def replace_arguments(string, step_arguments, format)
|
70
70
|
s = string.dup
|
71
71
|
offset = past_offset = 0
|
72
72
|
step_arguments.each do |step_argument|
|
@@ -74,7 +74,7 @@ module Cucumber
|
|
74
74
|
next if group.value.nil? || group.start < past_offset
|
75
75
|
|
76
76
|
replacement = if block_given?
|
77
|
-
|
77
|
+
yield(group.value)
|
78
78
|
elsif Proc === format
|
79
79
|
format.call(group.value)
|
80
80
|
else
|
@@ -93,6 +93,7 @@ module Cucumber
|
|
93
93
|
end
|
94
94
|
|
95
95
|
private
|
96
|
+
|
96
97
|
def deep_clone_args
|
97
98
|
Marshal.load( Marshal.dump( args ) )
|
98
99
|
end
|
@@ -145,7 +146,6 @@ module Cucumber
|
|
145
146
|
end
|
146
147
|
|
147
148
|
class AmbiguousStepMatch
|
148
|
-
|
149
149
|
def initialize(error)
|
150
150
|
@error = error
|
151
151
|
end
|
@@ -153,7 +153,5 @@ module Cucumber
|
|
153
153
|
def activate(test_step)
|
154
154
|
return test_step.with_action { raise @error }
|
155
155
|
end
|
156
|
-
|
157
156
|
end
|
158
|
-
|
159
157
|
end
|