cucumber 8.0.0 → 9.2.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +37 -36
- 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 +86 -242
- 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
|
|
@@ -75,7 +75,9 @@ module Cucumber
|
|
75
75
|
def eof; end
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
# This is a Hash being initialized with a default value of a Hash, DO NOT REFORMAT TO REMOVE {}
|
79
|
+
# Future versions [3.4.0+] of ruby will interpret these as keywords and break.
|
80
|
+
NULL_CONVERSIONS = Hash.new({ strict: false, proc: ->(cell_value) { cell_value } }).freeze
|
79
81
|
|
80
82
|
# @param data [Core::Test::DataTable] the data for the table
|
81
83
|
# @param conversion_procs [Hash] see map_column
|
@@ -194,17 +196,17 @@ module Cucumber
|
|
194
196
|
end
|
195
197
|
end
|
196
198
|
|
197
|
-
def column_names
|
199
|
+
def column_names
|
198
200
|
@column_names ||= cell_matrix[0].map(&:value)
|
199
201
|
end
|
200
202
|
|
201
203
|
def rows
|
202
204
|
hashes.map do |hash|
|
203
|
-
hash.values_at
|
205
|
+
hash.values_at(*headers)
|
204
206
|
end
|
205
207
|
end
|
206
208
|
|
207
|
-
def each_cells_row(&proc)
|
209
|
+
def each_cells_row(&proc)
|
208
210
|
cells_rows.each(&proc)
|
209
211
|
end
|
210
212
|
|
@@ -340,7 +342,7 @@ module Cucumber
|
|
340
342
|
cells_rows.map { |cells| cells.map(&:value) }
|
341
343
|
end
|
342
344
|
|
343
|
-
def cells_to_hash(cells)
|
345
|
+
def cells_to_hash(cells)
|
344
346
|
hash = Hash.new do |hash_inner, key|
|
345
347
|
hash_inner[key.to_s] if key.is_a?(Symbol)
|
346
348
|
end
|
@@ -350,51 +352,51 @@ module Cucumber
|
|
350
352
|
hash
|
351
353
|
end
|
352
354
|
|
353
|
-
def index(cells)
|
355
|
+
def index(cells)
|
354
356
|
cells_rows.index(cells)
|
355
357
|
end
|
356
358
|
|
357
|
-
def verify_column(column_name)
|
359
|
+
def verify_column(column_name)
|
358
360
|
raise %(The column named "#{column_name}" does not exist) unless raw[0].include?(column_name)
|
359
361
|
end
|
360
362
|
|
361
|
-
def verify_table_width(width)
|
363
|
+
def verify_table_width(width)
|
362
364
|
raise %(The table must have exactly #{width} columns) unless raw[0].size == width
|
363
365
|
end
|
364
366
|
|
365
367
|
# TODO: remove the below function if it's not actually being used.
|
366
368
|
# Nothing else in this repo calls it.
|
367
|
-
def text?(text)
|
369
|
+
def text?(text)
|
368
370
|
raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
|
369
371
|
end
|
370
372
|
|
371
|
-
def cells_rows
|
372
|
-
@rows ||= cell_matrix.map do |cell_row|
|
373
|
+
def cells_rows
|
374
|
+
@rows ||= cell_matrix.map do |cell_row|
|
373
375
|
Cells.new(self, cell_row)
|
374
376
|
end
|
375
377
|
end
|
376
378
|
|
377
|
-
def headers
|
379
|
+
def headers
|
378
380
|
raw.first
|
379
381
|
end
|
380
382
|
|
381
|
-
def header_cell(col)
|
383
|
+
def header_cell(col)
|
382
384
|
cells_rows[0][col]
|
383
385
|
end
|
384
386
|
|
385
387
|
attr_reader :cell_matrix
|
386
388
|
|
387
|
-
def col_width(col)
|
389
|
+
def col_width(col)
|
388
390
|
columns[col].__send__(:width)
|
389
391
|
end
|
390
392
|
|
391
|
-
def to_s(options = {})
|
393
|
+
def to_s(options = {})
|
392
394
|
indentation = options.key?(:indent) ? options[:indent] : 2
|
393
395
|
prefixes = options.key?(:prefixes) ? options[:prefixes] : TO_S_PREFIXES
|
394
396
|
DataTablePrinter.new(self, indentation, prefixes).to_s
|
395
397
|
end
|
396
398
|
|
397
|
-
class DataTablePrinter
|
399
|
+
class DataTablePrinter
|
398
400
|
include Cucumber::Gherkin::Formatter::Escaping
|
399
401
|
attr_reader :data_table, :indentation, :prefixes
|
400
402
|
private :data_table, :indentation, :prefixes
|
@@ -433,7 +435,7 @@ module Cucumber
|
|
433
435
|
end
|
434
436
|
end
|
435
437
|
|
436
|
-
def columns
|
438
|
+
def columns
|
437
439
|
@columns ||= cell_matrix.transpose.map do |cell_row|
|
438
440
|
Cells.new(self, cell_row)
|
439
441
|
end
|
@@ -456,7 +458,7 @@ module Cucumber
|
|
456
458
|
cells_rows[1..].map(&:to_hash)
|
457
459
|
end
|
458
460
|
|
459
|
-
def create_cell_matrix(ast_table)
|
461
|
+
def create_cell_matrix(ast_table)
|
460
462
|
ast_table.raw.map do |raw_row|
|
461
463
|
line = begin
|
462
464
|
raw_row.line
|
@@ -469,7 +471,7 @@ module Cucumber
|
|
469
471
|
end
|
470
472
|
end
|
471
473
|
|
472
|
-
def convert_columns!
|
474
|
+
def convert_columns!
|
473
475
|
@conversion_procs.each do |column_name, conversion_proc|
|
474
476
|
verify_column(column_name) if conversion_proc[:strict]
|
475
477
|
end
|
@@ -483,7 +485,7 @@ module Cucumber
|
|
483
485
|
end
|
484
486
|
end
|
485
487
|
|
486
|
-
def convert_headers!
|
488
|
+
def convert_headers!
|
487
489
|
header_cells = cell_matrix[0]
|
488
490
|
|
489
491
|
if @header_conversion_proc
|
@@ -501,12 +503,12 @@ module Cucumber
|
|
501
503
|
end
|
502
504
|
end
|
503
505
|
|
504
|
-
def clear_cache!
|
506
|
+
def clear_cache!
|
505
507
|
@hashes = @rows_hash = @column_names = @rows = @columns = nil
|
506
508
|
end
|
507
509
|
|
508
|
-
def ensure_table(table_or_array)
|
509
|
-
return table_or_array if
|
510
|
+
def ensure_table(table_or_array)
|
511
|
+
return table_or_array if table_or_array.instance_of?(DataTable)
|
510
512
|
|
511
513
|
DataTable.from(table_or_array)
|
512
514
|
end
|
@@ -516,7 +518,7 @@ module Cucumber
|
|
516
518
|
end
|
517
519
|
|
518
520
|
# Represents a row of cells or columns of cells
|
519
|
-
class Cells
|
521
|
+
class Cells
|
520
522
|
include Enumerable
|
521
523
|
include Cucumber::Gherkin::Formatter::Escaping
|
522
524
|
|
@@ -536,21 +538,20 @@ module Cucumber
|
|
536
538
|
nil
|
537
539
|
end
|
538
540
|
|
539
|
-
|
540
|
-
def to_sexp # :nodoc:
|
541
|
+
def to_sexp
|
541
542
|
[:row, line, *@cells.map(&:to_sexp)]
|
542
543
|
end
|
543
544
|
|
544
|
-
def to_hash
|
545
|
+
def to_hash
|
545
546
|
@to_hash ||= @table.cells_to_hash(self)
|
546
547
|
end
|
547
548
|
|
548
|
-
def value(
|
549
|
-
self[
|
549
|
+
def value(index)
|
550
|
+
self[index].value
|
550
551
|
end
|
551
552
|
|
552
|
-
def [](
|
553
|
-
@cells[
|
553
|
+
def [](index)
|
554
|
+
@cells[index]
|
554
555
|
end
|
555
556
|
|
556
557
|
def line
|
@@ -576,7 +577,7 @@ module Cucumber
|
|
576
577
|
end
|
577
578
|
end
|
578
579
|
|
579
|
-
class Cell
|
580
|
+
class Cell
|
580
581
|
attr_reader :line, :table
|
581
582
|
attr_accessor :status, :value
|
582
583
|
|
@@ -591,7 +592,7 @@ module Cucumber
|
|
591
592
|
end
|
592
593
|
|
593
594
|
def ==(other)
|
594
|
-
|
595
|
+
other.class == SurplusCell || value == other.value
|
595
596
|
end
|
596
597
|
|
597
598
|
def eql?(other)
|
@@ -603,12 +604,12 @@ module Cucumber
|
|
603
604
|
end
|
604
605
|
|
605
606
|
# For testing only
|
606
|
-
def to_sexp
|
607
|
+
def to_sexp
|
607
608
|
[:cell, @value]
|
608
609
|
end
|
609
610
|
end
|
610
611
|
|
611
|
-
class SurplusCell < Cell
|
612
|
+
class SurplusCell < Cell
|
612
613
|
def status
|
613
614
|
:comment
|
614
615
|
end
|