cucumber 9.0.2 → 9.1.1
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 +4 -8
- data/VERSION +1 -1
- data/lib/cucumber/cli/main.rb +1 -1
- data/lib/cucumber/cli/options.rb +8 -8
- data/lib/cucumber/cli/profile_loader.rb +5 -5
- data/lib/cucumber/configuration.rb +1 -1
- data/lib/cucumber/deprecate.rb +6 -47
- data/lib/cucumber/formatter/ansicolor.rb +9 -9
- data/lib/cucumber/formatter/ast_lookup.rb +14 -6
- data/lib/cucumber/formatter/console.rb +7 -2
- data/lib/cucumber/formatter/json.rb +2 -2
- data/lib/cucumber/formatter/message_builder.rb +14 -5
- data/lib/cucumber/formatter/pretty.rb +7 -3
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +16 -16
- data/lib/cucumber/glue/invoke_in_world.rb +1 -1
- data/lib/cucumber/glue/proto_world.rb +17 -22
- data/lib/cucumber/glue/registry_and_more.rb +7 -4
- data/lib/cucumber/multiline_argument/data_table.rb +28 -28
- data/lib/cucumber/rake/task.rb +1 -5
- data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
- data/lib/cucumber/runtime/meta_message_builder.rb +2 -2
- data/lib/cucumber/runtime/user_interface.rb +2 -2
- data/lib/cucumber/runtime.rb +1 -1
- metadata +35 -241
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81294b0304068bde0d87c31fc0d58451d79a59c73bc743bf4ea282dcf5c2ba2c
|
4
|
+
data.tar.gz: 9f8e3297cfd2fdf1f977a1e748abf2a2cd08f742709884042d56213ab4ff6499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 380511f8909d71467d326c13510820ed9e16517c4aaf68e3bcc6bf14a9a7e9588060e04238e970a1e4d37ed8dd4b725347c4153dd12357dae2c7ffcf548e6949
|
7
|
+
data.tar.gz: 3ee41bcacdfb4b040cd5cab60c3c94c5a7fcb533b06fc73d2a58e49aa12652b0e834298931425e537ef15b51f528a4469c833044dc577e277374175a9fbdbacc
|
data/README.md
CHANGED
@@ -5,9 +5,7 @@
|
|
5
5
|
[](https://vshymanskyy.github.io/StandWithUkraine)
|
6
6
|
[](https://opencollective.com/cucumber)
|
7
7
|
[](https://opencollective.com/cucumber)
|
8
|
-
[](https://oselvar.com/github/cucumber/oselvar-github-metrics/main/cucumber/cucumber-ruby)
|
10
|
-
[](https://github.com/cucumber/cucumber-ruby/actions/workflows/cucumber-ruby.yml)
|
8
|
+
[](https://github.com/cucumber/cucumber-ruby/actions/workflows/test.yaml)
|
11
9
|
[](https://codeclimate.com/github/cucumber/cucumber-ruby)
|
12
10
|
[](https://coveralls.io/r/cucumber/cucumber-ruby?branch=main)
|
13
11
|
|
@@ -56,8 +54,7 @@ Later in this document, bundler is considered being used so all commands are usi
|
|
56
54
|
|
57
55
|
### Ruby on Rails
|
58
56
|
|
59
|
-
Using Ruby on Rails? You can use [cucumber-rails](https://github.com/cucumber/cucumber-rails)
|
60
|
-
to bring Cucumber into your Rails project.
|
57
|
+
Using Ruby on Rails? You can use [cucumber-rails](https://github.com/cucumber/cucumber-rails) to bring Cucumber into your Rails project.
|
61
58
|
|
62
59
|
## Usage
|
63
60
|
|
@@ -133,7 +130,7 @@ To execute a single example, indicates the line of the name of the example:
|
|
133
130
|
|
134
131
|
$ bundle exec cucumber features/rule.feature:5
|
135
132
|
|
136
|
-
To summarize the results on the standard output, and
|
133
|
+
To summarize the results on the standard output, and generate a HTML report on disk:
|
137
134
|
|
138
135
|
$ bundle exec cucumber --format summary --format html --out report.html
|
139
136
|
|
@@ -141,8 +138,7 @@ For more command line options
|
|
141
138
|
|
142
139
|
$ bundle exec cucumber --help
|
143
140
|
|
144
|
-
You can also find documentation on the command line possibilities in
|
145
|
-
[features/docs/cli](features/docs/cli).
|
141
|
+
You can also find documentation on the command line possibilities in [features/docs/cli](features/docs/cli).
|
146
142
|
|
147
143
|
## Documentation and support
|
148
144
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
9.
|
1
|
+
9.1.1
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -49,7 +49,7 @@ module Cucumber
|
|
49
49
|
rescue Errno::EACCES, Errno::ENOENT => e
|
50
50
|
@err.puts("#{e.message} (#{e.class})")
|
51
51
|
exit_unable_to_finish
|
52
|
-
rescue Exception => e
|
52
|
+
rescue Exception => e
|
53
53
|
@err.puts("#{e.message} (#{e.class})")
|
54
54
|
@err.puts(e.backtrace.join("\n"))
|
55
55
|
exit_unable_to_finish
|
data/lib/cucumber/cli/options.rb
CHANGED
@@ -92,13 +92,13 @@ module Cucumber
|
|
92
92
|
@options[key] = value
|
93
93
|
end
|
94
94
|
|
95
|
-
def parse!(args)
|
95
|
+
def parse!(args)
|
96
96
|
@args = args
|
97
97
|
@expanded_args = @args.dup
|
98
98
|
|
99
99
|
@args.extend(::OptionParser::Arguable)
|
100
100
|
|
101
|
-
@args.options do |opts|
|
101
|
+
@args.options do |opts|
|
102
102
|
opts.banner = banner
|
103
103
|
opts.on('--publish', 'Publish a report to https://reports.cucumber.io') do
|
104
104
|
set_option :publish_enabled, true
|
@@ -143,11 +143,11 @@ module Cucumber
|
|
143
143
|
opts.on('-x', '--expand', 'Expand Scenario Outline Tables in output.') { set_option :expand }
|
144
144
|
|
145
145
|
opts.on('--order TYPE[:SEED]', 'Run examples in the specified order. Available types:',
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
Specify SEED to reproduce the shuffling from a previous run.
|
150
|
-
|
146
|
+
*<<~TEXT.split("\n")) do |order|
|
147
|
+
[defined] Run scenarios in the order they were defined (default).
|
148
|
+
[random] Shuffle scenarios before running.
|
149
|
+
Specify SEED to reproduce the shuffling from a previous run.
|
150
|
+
e.g. --order random:5738
|
151
151
|
TEXT
|
152
152
|
@options[:order], @options[:seed] = *order.split(':')
|
153
153
|
raise "'#{@options[:order]}' is not a recognised order type. Please use one of #{ORDER_TYPES.join(', ')}." unless ORDER_TYPES.include?(@options[:order])
|
@@ -522,7 +522,7 @@ Specify SEED to reproduce the shuffling from a previous run.
|
|
522
522
|
@profile_loader ||= ProfileLoader.new
|
523
523
|
end
|
524
524
|
|
525
|
-
def reverse_merge(other_options)
|
525
|
+
def reverse_merge(other_options)
|
526
526
|
@options = other_options.options.merge(@options)
|
527
527
|
@options[:require] += other_options[:require]
|
528
528
|
@options[:excludes] += other_options[:excludes]
|
@@ -11,11 +11,11 @@ module Cucumber
|
|
11
11
|
|
12
12
|
def args_from(profile)
|
13
13
|
unless cucumber_yml.key?(profile)
|
14
|
-
raise(ProfileNotFound,
|
15
|
-
Could not find profile: '#{profile}'
|
14
|
+
raise(ProfileNotFound, <<~END_OF_ERROR)
|
15
|
+
Could not find profile: '#{profile}'
|
16
16
|
|
17
|
-
Defined profiles in cucumber.yml:
|
18
|
-
|
17
|
+
Defined profiles in cucumber.yml:
|
18
|
+
* #{cucumber_yml.keys.sort.join("\n * ")}
|
19
19
|
END_OF_ERROR
|
20
20
|
end
|
21
21
|
|
@@ -84,7 +84,7 @@ Defined profiles in cucumber.yml:
|
|
84
84
|
def load_configuration
|
85
85
|
require 'yaml'
|
86
86
|
begin
|
87
|
-
@cucumber_yml = YAML.load(@cucumber_erb)
|
87
|
+
@cucumber_yml = YAML.load(@cucumber_erb)
|
88
88
|
rescue StandardError
|
89
89
|
raise(YmlLoadError, "cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
|
90
90
|
end
|
@@ -213,7 +213,7 @@ module Cucumber
|
|
213
213
|
yield factory,
|
214
214
|
formatter_options,
|
215
215
|
path_or_io
|
216
|
-
rescue Exception => e
|
216
|
+
rescue Exception => e
|
217
217
|
raise e, "#{e.message}\nError creating formatter: #{format}", e.backtrace
|
218
218
|
end
|
219
219
|
end
|
data/lib/cucumber/deprecate.rb
CHANGED
@@ -4,52 +4,11 @@ require 'cucumber/platform'
|
|
4
4
|
require 'cucumber/gherkin/formatter/ansi_escapes'
|
5
5
|
|
6
6
|
module Cucumber
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def failure_message(message)
|
16
|
-
failed + message + reset
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class CliOption
|
21
|
-
def self.deprecate(stream, option, message, remove_after_version)
|
22
|
-
return if stream.nil?
|
23
|
-
|
24
|
-
stream.puts(
|
25
|
-
AnsiString.failure_message(
|
26
|
-
"\nWARNING: #{option} is deprecated" \
|
27
|
-
" and will be removed after version #{remove_after_version}.\n#{message}.\n"
|
28
|
-
)
|
29
|
-
)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
module ForUsers
|
34
|
-
def self.call(message, method, remove_after_version)
|
35
|
-
$stderr.puts AnsiString.failure_message(
|
36
|
-
"\nWARNING: ##{method} is deprecated" \
|
37
|
-
" and will be removed after version #{remove_after_version}. #{message}.\n" \
|
38
|
-
"(Called from #{caller(3..3).first})"
|
39
|
-
)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
module ForDevelopers
|
44
|
-
def self.call(_message, _method, remove_after_version)
|
45
|
-
raise "This method is due for removal after version #{remove_after_version}" if remove_after_version <= Cucumber::VERSION
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
STRATEGY = $PROGRAM_NAME =~ /rspec$/ ? ForDevelopers : ForUsers
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.deprecate(*args)
|
53
|
-
Deprecate::STRATEGY.call(*args)
|
7
|
+
def self.deprecate(message, method, remove_after_version)
|
8
|
+
$stderr.puts(
|
9
|
+
"\nWARNING: ##{method} is deprecated" \
|
10
|
+
" and will be removed after version #{remove_after_version}. #{message}.\n" \
|
11
|
+
"(Called from #{caller(3..3).first})"
|
12
|
+
)
|
54
13
|
end
|
55
14
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'cucumber/platform'
|
4
4
|
require 'cucumber/term/ansicolor'
|
5
5
|
|
6
|
-
Cucumber::Term::ANSIColor.coloring = false
|
6
|
+
Cucumber::Term::ANSIColor.coloring = false unless $stdout.tty?
|
7
7
|
|
8
8
|
module Cucumber
|
9
9
|
module Formatter
|
@@ -70,14 +70,14 @@ module Cucumber
|
|
70
70
|
"#{h[Regexp.last_match(1)]},bold"
|
71
71
|
end.merge(
|
72
72
|
'undefined' => 'yellow',
|
73
|
-
'pending'
|
74
|
-
'flaky'
|
75
|
-
'failed'
|
76
|
-
'passed'
|
77
|
-
'outline'
|
78
|
-
'skipped'
|
79
|
-
'comment'
|
80
|
-
'tag'
|
73
|
+
'pending' => 'yellow',
|
74
|
+
'flaky' => 'yellow',
|
75
|
+
'failed' => 'red',
|
76
|
+
'passed' => 'green',
|
77
|
+
'outline' => 'cyan',
|
78
|
+
'skipped' => 'cyan',
|
79
|
+
'comment' => 'grey',
|
80
|
+
'tag' => 'cyan'
|
81
81
|
)
|
82
82
|
# :startdoc:
|
83
83
|
|
@@ -112,16 +112,24 @@ module Cucumber
|
|
112
112
|
if child.respond_to?(:rule) && child.rule
|
113
113
|
process_scenario_container(child.rule)
|
114
114
|
elsif child.respond_to?(:scenario) && child.scenario
|
115
|
-
child.scenario
|
116
|
-
@lookup_hash[step.location.line] = StepSource.new(:Step, step)
|
117
|
-
end
|
115
|
+
store_scenario_source_steps(child.scenario)
|
118
116
|
elsif !child.background.nil?
|
119
|
-
child.background
|
120
|
-
@lookup_hash[step.location.line] = StepSource.new(:Step, step)
|
121
|
-
end
|
117
|
+
store_background_source_steps(child.background)
|
122
118
|
end
|
123
119
|
end
|
124
120
|
end
|
121
|
+
|
122
|
+
def store_scenario_source_steps(scenario)
|
123
|
+
scenario.steps.each do |step|
|
124
|
+
@lookup_hash[step.location.line] = StepSource.new(:Step, step)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def store_background_source_steps(background)
|
129
|
+
background.steps.each do |step|
|
130
|
+
@lookup_hash[step.location.line] = StepSource.new(:Step, step)
|
131
|
+
end
|
132
|
+
end
|
125
133
|
end
|
126
134
|
|
127
135
|
KeywordSearchNode = Struct.new(:keyword, :previous_node)
|
@@ -169,12 +169,17 @@ module Cucumber
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
def attach(src, media_type)
|
172
|
+
def attach(src, media_type, filename)
|
173
173
|
return unless media_type == 'text/x.cucumber.log+plain'
|
174
174
|
return unless @io
|
175
175
|
|
176
176
|
@io.puts
|
177
|
-
|
177
|
+
if filename
|
178
|
+
@io.puts("#{filename}: #{format_string(src, :tag)}")
|
179
|
+
else
|
180
|
+
@io.puts(format_string(src, :tag))
|
181
|
+
end
|
182
|
+
|
178
183
|
@io.flush
|
179
184
|
end
|
180
185
|
|
@@ -85,7 +85,7 @@ module Cucumber
|
|
85
85
|
@io.write(JSON.pretty_generate(@feature_hashes))
|
86
86
|
end
|
87
87
|
|
88
|
-
def attach(src, mime_type)
|
88
|
+
def attach(src, mime_type, _filename)
|
89
89
|
if mime_type == 'text/x.cucumber.log+plain'
|
90
90
|
test_step_output << src
|
91
91
|
return
|
@@ -114,7 +114,7 @@ module Cucumber
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def current_feature
|
117
|
-
@feature_hash ||= {}
|
117
|
+
@feature_hash ||= {}
|
118
118
|
end
|
119
119
|
|
120
120
|
def feature_elements
|
@@ -42,11 +42,12 @@ module Cucumber
|
|
42
42
|
raise 'To be implemented'
|
43
43
|
end
|
44
44
|
|
45
|
-
def attach(src, media_type)
|
45
|
+
def attach(src, media_type, filename)
|
46
46
|
attachment_data = {
|
47
47
|
test_step_id: @current_test_step_id,
|
48
48
|
test_case_started_id: @current_test_case_started_id,
|
49
|
-
media_type: media_type
|
49
|
+
media_type: media_type,
|
50
|
+
file_name: filename
|
50
51
|
}
|
51
52
|
|
52
53
|
if media_type.start_with?('text/')
|
@@ -192,10 +193,13 @@ module Cucumber
|
|
192
193
|
|
193
194
|
result_message = result.to_message
|
194
195
|
if result.failed? || result.pending?
|
196
|
+
message_element = result.failed? ? result.exception : result
|
197
|
+
|
195
198
|
result_message = Cucumber::Messages::TestStepResult.new(
|
196
199
|
status: result_message.status,
|
197
200
|
duration: result_message.duration,
|
198
|
-
message: create_error_message(
|
201
|
+
message: create_error_message(message_element),
|
202
|
+
exception: create_exception_object(result, message_element)
|
199
203
|
)
|
200
204
|
end
|
201
205
|
|
@@ -211,12 +215,17 @@ module Cucumber
|
|
211
215
|
output_envelope(message)
|
212
216
|
end
|
213
217
|
|
214
|
-
def create_error_message(
|
215
|
-
message_element = result.failed? ? result.exception : result
|
218
|
+
def create_error_message(message_element)
|
216
219
|
message = "#{message_element.message} (#{message_element.class})"
|
217
220
|
([message] + message_element.backtrace).join("\n")
|
218
221
|
end
|
219
222
|
|
223
|
+
def create_exception_object(result, message_element)
|
224
|
+
return unless result.failed?
|
225
|
+
|
226
|
+
Cucumber::Messages::Exception.from_h({ type: message_element.class, message: message_element.message })
|
227
|
+
end
|
228
|
+
|
220
229
|
def on_test_case_finished(event)
|
221
230
|
message = Cucumber::Messages::Envelope.new(
|
222
231
|
test_case_finished: Cucumber::Messages::TestCaseFinished.new(
|
@@ -140,10 +140,14 @@ 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
|
@@ -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]
|
@@ -41,30 +41,30 @@ module Cucumber
|
|
41
41
|
# Although not listed, you can also use <tt>grey</tt>
|
42
42
|
module AnsiEscapes
|
43
43
|
COLORS = {
|
44
|
-
'black'
|
45
|
-
'red'
|
46
|
-
'green'
|
47
|
-
'yellow'
|
48
|
-
'blue'
|
44
|
+
'black' => "\e[30m",
|
45
|
+
'red' => "\e[31m",
|
46
|
+
'green' => "\e[32m",
|
47
|
+
'yellow' => "\e[33m",
|
48
|
+
'blue' => "\e[34m",
|
49
49
|
'magenta' => "\e[35m",
|
50
|
-
'cyan'
|
51
|
-
'white'
|
52
|
-
'grey'
|
53
|
-
'bold'
|
50
|
+
'cyan' => "\e[36m",
|
51
|
+
'white' => "\e[37m",
|
52
|
+
'grey' => "\e[90m",
|
53
|
+
'bold' => "\e[1m"
|
54
54
|
}.freeze
|
55
55
|
|
56
56
|
ALIASES = Hash.new do |h, k|
|
57
57
|
"#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/
|
58
58
|
end.merge(
|
59
59
|
'undefined' => 'yellow',
|
60
|
-
'pending'
|
60
|
+
'pending' => 'yellow',
|
61
61
|
'executing' => 'grey',
|
62
|
-
'failed'
|
63
|
-
'passed'
|
64
|
-
'outline'
|
65
|
-
'skipped'
|
66
|
-
'comments'
|
67
|
-
'tag'
|
62
|
+
'failed' => 'red',
|
63
|
+
'passed' => 'green',
|
64
|
+
'outline' => 'cyan',
|
65
|
+
'skipped' => 'cyan',
|
66
|
+
'comments' => 'grey',
|
67
|
+
'tag' => 'cyan'
|
68
68
|
)
|
69
69
|
|
70
70
|
# Example: export GHERKIN_COLORS="passed=red:failed=yellow"
|
@@ -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
|
@@ -7,7 +7,7 @@ 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
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,8 +125,8 @@ module Cucumber
|
|
126
125
|
inspect
|
127
126
|
end
|
128
127
|
|
129
|
-
#
|
130
|
-
def self.for(runtime, language)
|
128
|
+
# Dynamically generate the API module, closuring the dependencies
|
129
|
+
def self.for(runtime, language)
|
131
130
|
Module.new do
|
132
131
|
def self.extended(object)
|
133
132
|
# wrap the dynamically generated module so that we can document the methods
|
@@ -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
|
@@ -198,16 +198,19 @@ module Cucumber
|
|
198
198
|
private
|
199
199
|
|
200
200
|
def parameter_type_envelope(parameter_type)
|
201
|
-
# TODO: should
|
201
|
+
# TODO: should this be moved to Cucumber::Expression::ParameterType#to_envelope ??
|
202
202
|
# Note: that would mean that cucumber-expression would depend on cucumber-messages
|
203
|
-
|
204
203
|
Cucumber::Messages::Envelope.new(
|
205
204
|
parameter_type: Cucumber::Messages::ParameterType.new(
|
206
205
|
id: @configuration.id_generator.new_id,
|
207
206
|
name: parameter_type.name,
|
208
207
|
regular_expressions: parameter_type.regexps.map(&:to_s),
|
209
|
-
prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match
|
210
|
-
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
|
+
)
|
211
214
|
)
|
212
215
|
)
|
213
216
|
end
|