cucumber 8.0.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -23
- data/VERSION +1 -0
- data/lib/cucumber/cli/main.rb +1 -1
- data/lib/cucumber/cli/options.rb +66 -66
- data/lib/cucumber/cli/profile_loader.rb +5 -5
- data/lib/cucumber/configuration.rb +7 -2
- data/lib/cucumber/deprecate.rb +6 -47
- data/lib/cucumber/errors.rb +2 -1
- data/lib/cucumber/events/envelope.rb +2 -0
- data/lib/cucumber/events/gherkin_source_parsed.rb +2 -0
- data/lib/cucumber/events/gherkin_source_read.rb +2 -0
- data/lib/cucumber/events/test_case_finished.rb +2 -0
- data/lib/cucumber/events/test_case_started.rb +2 -0
- data/lib/cucumber/events/test_step_finished.rb +2 -0
- data/lib/cucumber/events/test_step_started.rb +2 -0
- data/lib/cucumber/events/undefined_parameter_type.rb +2 -0
- data/lib/cucumber/file_specs.rb +1 -1
- data/lib/cucumber/filters/retry.rb +20 -1
- data/lib/cucumber/formatter/ansicolor.rb +19 -27
- data/lib/cucumber/formatter/ast_lookup.rb +14 -6
- data/lib/cucumber/formatter/console.rb +16 -14
- data/lib/cucumber/formatter/console_counts.rb +3 -1
- data/lib/cucumber/formatter/console_issues.rb +4 -2
- data/lib/cucumber/formatter/curl_option_parser.rb +49 -0
- data/lib/cucumber/formatter/errors.rb +2 -0
- data/lib/cucumber/formatter/fail_fast.rb +1 -1
- data/lib/cucumber/formatter/html.rb +2 -0
- data/lib/cucumber/formatter/http_io.rb +10 -142
- data/lib/cucumber/formatter/io_http_buffer.rb +88 -0
- data/lib/cucumber/formatter/json.rb +2 -6
- data/lib/cucumber/formatter/junit.rb +4 -4
- data/lib/cucumber/formatter/message_builder.rb +21 -6
- data/lib/cucumber/formatter/pretty.rb +9 -5
- data/lib/cucumber/formatter/publish_banner_printer.rb +0 -2
- data/lib/cucumber/formatter/query/hook_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/pickle_by_test.rb +2 -0
- data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +2 -0
- data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +2 -0
- data/lib/cucumber/formatter/rerun.rb +3 -3
- data/lib/cucumber/formatter/unicode.rb +3 -3
- data/lib/cucumber/formatter/url_reporter.rb +3 -1
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +23 -25
- data/lib/cucumber/glue/invoke_in_world.rb +2 -2
- data/lib/cucumber/glue/proto_world.rb +20 -25
- data/lib/cucumber/glue/registry_and_more.rb +9 -5
- data/lib/cucumber/glue/snippet.rb +4 -2
- data/lib/cucumber/glue/world_factory.rb +2 -0
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +2 -0
- data/lib/cucumber/multiline_argument/data_table.rb +34 -35
- data/lib/cucumber/platform.rb +11 -16
- data/lib/cucumber/rake/task.rb +2 -6
- data/lib/cucumber/running_test_case.rb +1 -1
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
- data/lib/cucumber/runtime/meta_message_builder.rb +4 -2
- data/lib/cucumber/runtime/user_interface.rb +2 -2
- data/lib/cucumber/runtime.rb +5 -5
- data/lib/cucumber/step_match.rb +1 -1
- data/lib/cucumber/term/ansicolor.rb +1 -1
- data/lib/cucumber/term/banner.rb +2 -0
- metadata +83 -239
- data/CHANGELOG.md +0 -3231
- data/CONTRIBUTING.md +0 -246
- data/lib/autotest/cucumber.rb +0 -8
- data/lib/autotest/cucumber_mixin.rb +0 -133
- data/lib/autotest/cucumber_rails.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec.rb +0 -8
- data/lib/autotest/cucumber_rails_rspec2.rb +0 -8
- data/lib/autotest/cucumber_rspec.rb +0 -8
- data/lib/autotest/cucumber_rspec2.rb +0 -8
- data/lib/autotest/discover.rb +0 -14
- data/lib/cucumber/version +0 -1
@@ -19,7 +19,7 @@ module Cucumber
|
|
19
19
|
#
|
20
20
|
# If the output is STDOUT (and not a file), there are bright colours to watch too.
|
21
21
|
#
|
22
|
-
class Pretty
|
22
|
+
class Pretty
|
23
23
|
include FileUtils
|
24
24
|
include Console
|
25
25
|
include Io
|
@@ -140,16 +140,20 @@ module Cucumber
|
|
140
140
|
print_summary
|
141
141
|
end
|
142
142
|
|
143
|
-
def attach(src, media_type)
|
143
|
+
def attach(src, media_type, filename)
|
144
144
|
return unless media_type == 'text/x.cucumber.log+plain'
|
145
145
|
|
146
|
-
|
146
|
+
if filename
|
147
|
+
@test_step_output.push("#{filename}: #{src}")
|
148
|
+
else
|
149
|
+
@test_step_output.push(src)
|
150
|
+
end
|
147
151
|
end
|
148
152
|
|
149
153
|
private
|
150
154
|
|
151
155
|
def find_exception_to_be_printed(result)
|
152
|
-
return nil if result.ok?(options[:strict])
|
156
|
+
return nil if result.ok?(strict: options[:strict])
|
153
157
|
|
154
158
|
result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
|
155
159
|
exception = result.failed? ? result.exception : result
|
@@ -391,7 +395,7 @@ module Cucumber
|
|
391
395
|
end
|
392
396
|
end
|
393
397
|
|
394
|
-
def print_outline_data(scenario_outline)
|
398
|
+
def print_outline_data(scenario_outline)
|
395
399
|
print_comments(scenario_outline.location.line, 2)
|
396
400
|
print_tags(scenario_outline.tags, 2)
|
397
401
|
@source_indent = calculate_source_indent_for_ast_node(scenario_outline) if options[:source]
|
@@ -15,7 +15,6 @@ module Cucumber
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
18
|
def display_publish_ad(io)
|
20
19
|
display_banner(
|
21
20
|
[
|
@@ -59,7 +58,6 @@ module Cucumber
|
|
59
58
|
io
|
60
59
|
)
|
61
60
|
end
|
62
|
-
# rubocop:enable Metrics/MethodLength
|
63
61
|
|
64
62
|
def highlight(text)
|
65
63
|
[text, :cyan]
|
@@ -14,7 +14,7 @@ module Cucumber
|
|
14
14
|
config.on_event :test_case_finished do |event|
|
15
15
|
test_case, result = *event.attributes
|
16
16
|
if @config.strict.strict?(:flaky)
|
17
|
-
next if result.ok?(@config.strict)
|
17
|
+
next if result.ok?(strict: @config.strict)
|
18
18
|
|
19
19
|
add_to_failures(test_case)
|
20
20
|
else
|
@@ -22,11 +22,11 @@ module Cucumber
|
|
22
22
|
if @latest_failed_test_case != test_case
|
23
23
|
add_to_failures(@latest_failed_test_case)
|
24
24
|
@latest_failed_test_case = nil
|
25
|
-
elsif result.ok?(@config.strict)
|
25
|
+
elsif result.ok?(strict: @config.strict)
|
26
26
|
@latest_failed_test_case = nil
|
27
27
|
end
|
28
28
|
end
|
29
|
-
@latest_failed_test_case = test_case unless result.ok?(@config.strict)
|
29
|
+
@latest_failed_test_case = test_case unless result.ok?(strict: @config.strict)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
config.on_event :test_run_finished do
|
@@ -10,13 +10,13 @@ if Cucumber::WINDOWS
|
|
10
10
|
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
|
11
11
|
elsif `cmd /c chcp` =~ /(\d+)/
|
12
12
|
if [65_000, 65_001].include? Regexp.last_match(1).to_i
|
13
|
-
Cucumber::CODEPAGE = 'UTF-8'
|
13
|
+
Cucumber::CODEPAGE = 'UTF-8'
|
14
14
|
ENV['ANSICON_API'] = 'ruby'
|
15
15
|
else
|
16
|
-
Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}"
|
16
|
+
Cucumber::CODEPAGE = "cp#{Regexp.last_match(1).to_i}"
|
17
17
|
end
|
18
18
|
else
|
19
|
-
Cucumber::CODEPAGE = 'cp1252'
|
19
|
+
Cucumber::CODEPAGE = 'cp1252'
|
20
20
|
$stderr.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
|
21
21
|
end
|
22
22
|
|
@@ -5,8 +5,7 @@ module Cucumber
|
|
5
5
|
module Formatter
|
6
6
|
# Defines aliases for ANSI coloured output. Default colours can be overridden by defining
|
7
7
|
# a <tt>GHERKIN_COLORS</tt> variable in your shell, very much like how you can
|
8
|
-
# tweak the familiar POSIX command <tt>ls</tt> with
|
9
|
-
# $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
8
|
+
# tweak the familiar POSIX command <tt>ls</tt> with $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
10
9
|
#
|
11
10
|
# The colours that you can change are:
|
12
11
|
#
|
@@ -41,37 +40,36 @@ module Cucumber
|
|
41
40
|
# Although not listed, you can also use <tt>grey</tt>
|
42
41
|
module AnsiEscapes
|
43
42
|
COLORS = {
|
44
|
-
'black'
|
45
|
-
'red'
|
46
|
-
'green'
|
47
|
-
'yellow'
|
48
|
-
'blue'
|
43
|
+
'black' => "\e[30m",
|
44
|
+
'red' => "\e[31m",
|
45
|
+
'green' => "\e[32m",
|
46
|
+
'yellow' => "\e[33m",
|
47
|
+
'blue' => "\e[34m",
|
49
48
|
'magenta' => "\e[35m",
|
50
|
-
'cyan'
|
51
|
-
'white'
|
52
|
-
'grey'
|
53
|
-
'bold'
|
49
|
+
'cyan' => "\e[36m",
|
50
|
+
'white' => "\e[37m",
|
51
|
+
'grey' => "\e[90m",
|
52
|
+
'bold' => "\e[1m"
|
54
53
|
}.freeze
|
55
54
|
|
56
55
|
ALIASES = Hash.new do |h, k|
|
57
56
|
"#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/
|
58
57
|
end.merge(
|
59
58
|
'undefined' => 'yellow',
|
60
|
-
'pending'
|
59
|
+
'pending' => 'yellow',
|
61
60
|
'executing' => 'grey',
|
62
|
-
'failed'
|
63
|
-
'passed'
|
64
|
-
'outline'
|
65
|
-
'skipped'
|
66
|
-
'comments'
|
67
|
-
'tag'
|
61
|
+
'failed' => 'red',
|
62
|
+
'passed' => 'green',
|
63
|
+
'outline' => 'cyan',
|
64
|
+
'skipped' => 'cyan',
|
65
|
+
'comments' => 'grey',
|
66
|
+
'tag' => 'cyan'
|
68
67
|
)
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
69
|
+
# Example: export GHERKIN_COLORS="passed=red:failed=yellow"
|
70
|
+
ENV.fetch('GHERKIN_COLORS', '').split(':').each do |pair|
|
71
|
+
rule, colour = pair.split('=')
|
72
|
+
ALIASES[colour] = rule
|
75
73
|
end
|
76
74
|
|
77
75
|
ALIASES.each_key do |key|
|
@@ -88,8 +86,8 @@ module Cucumber
|
|
88
86
|
"\e[0m"
|
89
87
|
end
|
90
88
|
|
91
|
-
def up(
|
92
|
-
"\e[#{
|
89
|
+
def up(amount)
|
90
|
+
"\e[#{amount}A"
|
93
91
|
end
|
94
92
|
end
|
95
93
|
end
|
@@ -28,7 +28,7 @@ module Cucumber
|
|
28
28
|
if check_arity && !cucumber_compatible_arity?(args, block)
|
29
29
|
world.instance_exec do
|
30
30
|
ari = block.arity
|
31
|
-
ari = ari
|
31
|
+
ari = ari.negative? ? "#{ari.abs - 1}+" : ari
|
32
32
|
s1 = ari == 1 ? '' : 's'
|
33
33
|
s2 = args.length == 1 ? '' : 's'
|
34
34
|
raise ArityMismatchError, "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
|
@@ -48,7 +48,7 @@ module Cucumber
|
|
48
48
|
|
49
49
|
def self.cucumber_run_with_backtrace_filtering(pseudo_method)
|
50
50
|
yield
|
51
|
-
rescue Exception => e
|
51
|
+
rescue Exception => e
|
52
52
|
instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
|
53
53
|
replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
|
54
54
|
raise e
|
@@ -3,11 +3,11 @@
|
|
3
3
|
require 'cucumber/gherkin/formatter/ansi_escapes'
|
4
4
|
require 'cucumber/core/test/data_table'
|
5
5
|
require 'cucumber/deprecate'
|
6
|
-
require '
|
6
|
+
require 'mini_mime'
|
7
7
|
|
8
8
|
module Cucumber
|
9
9
|
module Glue
|
10
|
-
# Defines the basic API methods
|
10
|
+
# Defines the basic API methods available in all Cucumber step definitions.
|
11
11
|
#
|
12
12
|
# You can, and probably should, extend this API with your own methods that
|
13
13
|
# make sense in your domain. For more on that, see {Cucumber::Glue::Dsl#World}
|
@@ -26,7 +26,7 @@ module Cucumber
|
|
26
26
|
# @example Passing a multiline string
|
27
27
|
# step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
|
28
28
|
# @param [String] name The name of the step
|
29
|
-
# @param [String,Cucumber::Test::DocString,Cucumber::Ast::Table]
|
29
|
+
# @param [String, Cucumber::Test::DocString, Cucumber::Ast::Table] raw_multiline_arg
|
30
30
|
def step(name, raw_multiline_arg = nil)
|
31
31
|
super
|
32
32
|
end
|
@@ -84,17 +84,19 @@ module Cucumber
|
|
84
84
|
|
85
85
|
# Attach a file to the output
|
86
86
|
# @param file [string|io] the file to attach.
|
87
|
-
# It can be a string containing the file content itself,
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
87
|
+
# It can be a string containing the file content itself, the file path, or an IO ready to be read.
|
88
|
+
# @param media_type [string] the media type.
|
89
|
+
# If file is a valid path, media_type can be omitted, it will then be inferred from the file name.
|
90
|
+
# @param filename [string] the name of the file you wish to specify.
|
91
|
+
# This is only needed in situations where you want to rename a PDF download e.t.c. - In most situations
|
92
|
+
# you should not need to pass a filename
|
93
|
+
def attach(file, media_type = nil, filename = nil)
|
92
94
|
return super unless File.file?(file)
|
93
95
|
|
94
96
|
content = File.read(file, mode: 'rb')
|
95
|
-
media_type =
|
97
|
+
media_type = MiniMime.lookup_by_filename(file)&.content_type if media_type.nil?
|
96
98
|
|
97
|
-
super(content, media_type.to_s)
|
99
|
+
super(content, media_type.to_s, filename)
|
98
100
|
rescue StandardError
|
99
101
|
super
|
100
102
|
end
|
@@ -103,12 +105,9 @@ module Cucumber
|
|
103
105
|
def pending(message = 'TODO')
|
104
106
|
raise Pending, message unless block_given?
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
raise Pending, message
|
110
|
-
end
|
111
|
-
raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
|
108
|
+
yield
|
109
|
+
rescue Exception
|
110
|
+
raise Pending, message
|
112
111
|
end
|
113
112
|
|
114
113
|
# Skips this step and the remaining steps in the scenario
|
@@ -126,9 +125,9 @@ module Cucumber
|
|
126
125
|
inspect
|
127
126
|
end
|
128
127
|
|
129
|
-
#
|
130
|
-
def self.for(runtime, language)
|
131
|
-
Module.new do
|
128
|
+
# Dynamically generate the API module, closuring the dependencies
|
129
|
+
def self.for(runtime, language)
|
130
|
+
Module.new do
|
132
131
|
def self.extended(object)
|
133
132
|
# wrap the dynamically generated module so that we can document the methods
|
134
133
|
# for yardoc, which doesn't like define_method.
|
@@ -156,8 +155,8 @@ module Cucumber
|
|
156
155
|
runtime.ask(question, timeout_seconds)
|
157
156
|
end
|
158
157
|
|
159
|
-
define_method(:attach) do |file, media_type|
|
160
|
-
runtime.attach(file, media_type)
|
158
|
+
define_method(:attach) do |file, media_type, filename|
|
159
|
+
runtime.attach(file, media_type, filename)
|
161
160
|
end
|
162
161
|
|
163
162
|
# Prints the list of modules that are included in the World
|
@@ -172,14 +171,12 @@ module Cucumber
|
|
172
171
|
|
173
172
|
private
|
174
173
|
|
175
|
-
# @private
|
176
174
|
def add_world_modules!(modules)
|
177
175
|
modules.each do |world_module|
|
178
176
|
extend(world_module)
|
179
177
|
end
|
180
178
|
end
|
181
179
|
|
182
|
-
# @private
|
183
180
|
def add_namespaced_modules!(modules)
|
184
181
|
@__namespaced_modules = modules
|
185
182
|
modules.each do |namespace, world_modules|
|
@@ -199,7 +196,6 @@ module Cucumber
|
|
199
196
|
end
|
200
197
|
end
|
201
198
|
|
202
|
-
# @private
|
203
199
|
def stringify_namespaced_modules
|
204
200
|
return '' if @__namespaced_modules.nil?
|
205
201
|
|
@@ -208,7 +204,6 @@ module Cucumber
|
|
208
204
|
end
|
209
205
|
end
|
210
206
|
|
211
|
-
# @private
|
212
207
|
AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
|
213
208
|
end
|
214
209
|
end
|
@@ -29,7 +29,8 @@ module Cucumber
|
|
29
29
|
# Raised if there are 2 or more World blocks.
|
30
30
|
class MultipleWorld < StandardError
|
31
31
|
def initialize(first_proc, second_proc)
|
32
|
-
|
32
|
+
# TODO: [LH] - Just use a heredoc here to fix this up
|
33
|
+
message = String.new
|
33
34
|
message << "You can only pass a proc to #World once, but it's happening\n"
|
34
35
|
message << "in 2 places:\n\n"
|
35
36
|
message << Glue.backtrace_line(first_proc, 'World') << "\n"
|
@@ -197,16 +198,19 @@ module Cucumber
|
|
197
198
|
private
|
198
199
|
|
199
200
|
def parameter_type_envelope(parameter_type)
|
200
|
-
# TODO: should
|
201
|
+
# TODO: should this be moved to Cucumber::Expression::ParameterType#to_envelope ??
|
201
202
|
# Note: that would mean that cucumber-expression would depend on cucumber-messages
|
202
|
-
|
203
203
|
Cucumber::Messages::Envelope.new(
|
204
204
|
parameter_type: Cucumber::Messages::ParameterType.new(
|
205
205
|
id: @configuration.id_generator.new_id,
|
206
206
|
name: parameter_type.name,
|
207
207
|
regular_expressions: parameter_type.regexps.map(&:to_s),
|
208
|
-
prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match
|
209
|
-
use_for_snippets: parameter_type.use_for_snippets
|
208
|
+
prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match,
|
209
|
+
use_for_snippets: parameter_type.use_for_snippets,
|
210
|
+
source_reference: Cucumber::Messages::SourceReference.new(
|
211
|
+
uri: parameter_type.transformer.source_location[0],
|
212
|
+
location: Cucumber::Messages::Location.new(line: parameter_type.transformer.source_location[1])
|
213
|
+
)
|
210
214
|
)
|
211
215
|
)
|
212
216
|
end
|
@@ -61,7 +61,8 @@ module Cucumber
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def do_block
|
64
|
-
|
64
|
+
# TODO: [LH] - Just use a heredoc here to fix this up
|
65
|
+
do_block = String.new
|
65
66
|
do_block << "do#{parameters}\n"
|
66
67
|
multiline_argument.append_comment_to(do_block)
|
67
68
|
do_block << " pending # Write code here that turns the phrase above into concrete actions\n"
|
@@ -95,7 +96,8 @@ module Cucumber
|
|
95
96
|
"#{prefix}#{code_keyword}('#{expr.source}') do#{parameters(expr)}"
|
96
97
|
end.join("\n")
|
97
98
|
|
98
|
-
|
99
|
+
# TODO: [LH] - Just use a heredoc here to fix this up
|
100
|
+
body = String.new
|
99
101
|
multiline_argument.append_comment_to(body)
|
100
102
|
body << " pending # Write code here that turns the phrase above into concrete actions\n"
|
101
103
|
body << 'end'
|
@@ -27,7 +27,7 @@ module Cucumber
|
|
27
27
|
# This will store <tt>[['a', 'b'], ['c', 'd']]</tt> in the <tt>data</tt> variable.
|
28
28
|
#
|
29
29
|
class DataTable
|
30
|
-
def self.default_arg_name
|
30
|
+
def self.default_arg_name
|
31
31
|
'table'
|
32
32
|
end
|
33
33
|
|
@@ -194,17 +194,17 @@ module Cucumber
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
def column_names
|
197
|
+
def column_names
|
198
198
|
@column_names ||= cell_matrix[0].map(&:value)
|
199
199
|
end
|
200
200
|
|
201
201
|
def rows
|
202
202
|
hashes.map do |hash|
|
203
|
-
hash.values_at
|
203
|
+
hash.values_at(*headers)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
def each_cells_row(&proc)
|
207
|
+
def each_cells_row(&proc)
|
208
208
|
cells_rows.each(&proc)
|
209
209
|
end
|
210
210
|
|
@@ -340,7 +340,7 @@ module Cucumber
|
|
340
340
|
cells_rows.map { |cells| cells.map(&:value) }
|
341
341
|
end
|
342
342
|
|
343
|
-
def cells_to_hash(cells)
|
343
|
+
def cells_to_hash(cells)
|
344
344
|
hash = Hash.new do |hash_inner, key|
|
345
345
|
hash_inner[key.to_s] if key.is_a?(Symbol)
|
346
346
|
end
|
@@ -350,51 +350,51 @@ module Cucumber
|
|
350
350
|
hash
|
351
351
|
end
|
352
352
|
|
353
|
-
def index(cells)
|
353
|
+
def index(cells)
|
354
354
|
cells_rows.index(cells)
|
355
355
|
end
|
356
356
|
|
357
|
-
def verify_column(column_name)
|
357
|
+
def verify_column(column_name)
|
358
358
|
raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name)
|
359
359
|
end
|
360
360
|
|
361
|
-
def verify_table_width(width)
|
361
|
+
def verify_table_width(width)
|
362
362
|
raise %(The table must have exactly #{width} columns) unless raw[0].size == width
|
363
363
|
end
|
364
364
|
|
365
365
|
# TODO: remove the below function if it's not actually being used.
|
366
366
|
# Nothing else in this repo calls it.
|
367
|
-
def text?(text)
|
367
|
+
def text?(text)
|
368
368
|
raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
|
369
369
|
end
|
370
370
|
|
371
|
-
def cells_rows
|
372
|
-
@rows ||= cell_matrix.map do |cell_row|
|
371
|
+
def cells_rows
|
372
|
+
@rows ||= cell_matrix.map do |cell_row|
|
373
373
|
Cells.new(self, cell_row)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
377
|
-
def headers
|
377
|
+
def headers
|
378
378
|
raw.first
|
379
379
|
end
|
380
380
|
|
381
|
-
def header_cell(col)
|
381
|
+
def header_cell(col)
|
382
382
|
cells_rows[0][col]
|
383
383
|
end
|
384
384
|
|
385
385
|
attr_reader :cell_matrix
|
386
386
|
|
387
|
-
def col_width(col)
|
387
|
+
def col_width(col)
|
388
388
|
columns[col].__send__(:width)
|
389
389
|
end
|
390
390
|
|
391
|
-
def to_s(options = {})
|
391
|
+
def to_s(options = {})
|
392
392
|
indentation = options.key?(:indent) ? options[:indent] : 2
|
393
393
|
prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES
|
394
394
|
DataTablePrinter.new(self, indentation, prefixes).to_s
|
395
395
|
end
|
396
396
|
|
397
|
-
class DataTablePrinter
|
397
|
+
class DataTablePrinter
|
398
398
|
include Cucumber::Gherkin::Formatter::Escaping
|
399
399
|
attr_reader :data_table, :indentation, :prefixes
|
400
400
|
private :data_table, :indentation, :prefixes
|
@@ -433,7 +433,7 @@ module Cucumber
|
|
433
433
|
end
|
434
434
|
end
|
435
435
|
|
436
|
-
def columns
|
436
|
+
def columns
|
437
437
|
@columns ||= cell_matrix.transpose.map do |cell_row|
|
438
438
|
Cells.new(self, cell_row)
|
439
439
|
end
|
@@ -456,7 +456,7 @@ module Cucumber
|
|
456
456
|
cells_rows[1..].map(&:to_hash)
|
457
457
|
end
|
458
458
|
|
459
|
-
def create_cell_matrix(ast_table)
|
459
|
+
def create_cell_matrix(ast_table)
|
460
460
|
ast_table.raw.map do |raw_row|
|
461
461
|
line = begin
|
462
462
|
raw_row.line
|
@@ -469,7 +469,7 @@ module Cucumber
|
|
469
469
|
end
|
470
470
|
end
|
471
471
|
|
472
|
-
def convert_columns!
|
472
|
+
def convert_columns!
|
473
473
|
@conversion_procs.each do |column_name, conversion_proc|
|
474
474
|
verify_column(column_name) if conversion_proc[:strict]
|
475
475
|
end
|
@@ -483,7 +483,7 @@ module Cucumber
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
def convert_headers!
|
486
|
+
def convert_headers!
|
487
487
|
header_cells = cell_matrix[0]
|
488
488
|
|
489
489
|
if @header_conversion_proc
|
@@ -501,12 +501,12 @@ module Cucumber
|
|
501
501
|
end
|
502
502
|
end
|
503
503
|
|
504
|
-
def clear_cache!
|
504
|
+
def clear_cache!
|
505
505
|
@hashes = @rows_hash = @column_names = @rows = @columns = nil
|
506
506
|
end
|
507
507
|
|
508
|
-
def ensure_table(table_or_array)
|
509
|
-
return table_or_array if
|
508
|
+
def ensure_table(table_or_array)
|
509
|
+
return table_or_array if table_or_array.instance_of?(DataTable)
|
510
510
|
|
511
511
|
DataTable.from(table_or_array)
|
512
512
|
end
|
@@ -516,7 +516,7 @@ module Cucumber
|
|
516
516
|
end
|
517
517
|
|
518
518
|
# Represents a row of cells or columns of cells
|
519
|
-
class Cells
|
519
|
+
class Cells
|
520
520
|
include Enumerable
|
521
521
|
include Cucumber::Gherkin::Formatter::Escaping
|
522
522
|
|
@@ -536,21 +536,20 @@ module Cucumber
|
|
536
536
|
nil
|
537
537
|
end
|
538
538
|
|
539
|
-
|
540
|
-
def to_sexp # :nodoc:
|
539
|
+
def to_sexp
|
541
540
|
[:row, line, *@cells.map(&:to_sexp)]
|
542
541
|
end
|
543
542
|
|
544
|
-
def to_hash
|
543
|
+
def to_hash
|
545
544
|
@to_hash ||= @table.cells_to_hash(self)
|
546
545
|
end
|
547
546
|
|
548
|
-
def value(
|
549
|
-
self[
|
547
|
+
def value(index)
|
548
|
+
self[index].value
|
550
549
|
end
|
551
550
|
|
552
|
-
def [](
|
553
|
-
@cells[
|
551
|
+
def [](index)
|
552
|
+
@cells[index]
|
554
553
|
end
|
555
554
|
|
556
555
|
def line
|
@@ -576,7 +575,7 @@ module Cucumber
|
|
576
575
|
end
|
577
576
|
end
|
578
577
|
|
579
|
-
class Cell
|
578
|
+
class Cell
|
580
579
|
attr_reader :line, :table
|
581
580
|
attr_accessor :status, :value
|
582
581
|
|
@@ -591,7 +590,7 @@ module Cucumber
|
|
591
590
|
end
|
592
591
|
|
593
592
|
def ==(other)
|
594
|
-
|
593
|
+
other.class == SurplusCell || value == other.value
|
595
594
|
end
|
596
595
|
|
597
596
|
def eql?(other)
|
@@ -603,12 +602,12 @@ module Cucumber
|
|
603
602
|
end
|
604
603
|
|
605
604
|
# For testing only
|
606
|
-
def to_sexp
|
605
|
+
def to_sexp
|
607
606
|
[:cell, @value]
|
608
607
|
end
|
609
608
|
end
|
610
609
|
|
611
|
-
class SurplusCell < Cell
|
610
|
+
class SurplusCell < Cell
|
612
611
|
def status
|
613
612
|
:comment
|
614
613
|
end
|