cucumber 4.0.0.rc.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf81b80049480e75914eab234ad671608f10a474e8850ecbda9e3cdca96f9e4e
4
- data.tar.gz: 4a692380408f3bd93ff079e192391bc921967ce96bf090f7cf010269c806a6a5
3
+ metadata.gz: fd820c5e08e32e33bba11e646e1e98d4382028b6e071914ddcb4982bb0657278
4
+ data.tar.gz: 13c93ab1fa304955ac45f8ce702eeb68dbcf2e316e383c9ae0ababe04a476762
5
5
  SHA512:
6
- metadata.gz: 3b1a3f2fcb5db9237bef23b510cadf0286ea61b19adab4fbcc67f4df14ded7adf2c33d2e4165f45be7361dce6fb418f74deadf3e0e1a7d4e8f2ba23c0e8a6c62
7
- data.tar.gz: 79d699ae305489e034fb16edf31d36304c2a0fb486bff4003f8e24abd786d81510eab5fdca6d32ca3348ce24b634cc6954d800b03494e3ef1dbba57ab7b9cc78
6
+ metadata.gz: ddd5940fbb47aaa12942842323cf81372051ddf0ad496d9213dd93d0538afbe80e5e35edf6a5d27ccdea2840a1091f86b6f65ec46e14e017cbbe724fd61e1269
7
+ data.tar.gz: 27e575d0c0730bf88574d7e42262e031ff34328b71a22af15d0a3c1dc8d3b14dacc7d62250a912de01dda4d85bdd22615d166faaa78b81dc5e24bb75a71374fd
@@ -9,6 +9,17 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
9
9
  Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CONTRIBUTING.md) for more info on how to contribute to Cucumber.
10
10
 
11
11
  ----
12
+
13
+ ## [4.0.0](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.5...v4.0.0)
14
+
15
+ ### Changed
16
+
17
+ * `log` method can now be called with non-string objects and will run `.to_s` on them. [#1410](https://github.com/cucumber/cucumber-ruby/issues/1410)
18
+
19
+ ### Improved
20
+
21
+ * Display snippet when using undefined parameter type [#1411](https://github.com/cucumber/cucumber-ruby/issues/1411)
22
+
12
23
  ## [4.0.0.rc.6](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.5...4.0.0.rc.6)
13
24
 
14
25
  ### Changed
@@ -302,9 +302,8 @@ Specify SEED to reproduce the shuffling from a previous run.
302
302
  "formatter's docs to see whether to pass a file, dir or URL.",
303
303
  "\n",
304
304
  'When using a URL, the output of the formatter will be sent as the HTTP request body.',
305
- 'HTTP headers and request method can be set with http- prefixed query parameters,',
306
- 'for example ?http-content-type=application/json&http-method=PUT.',
307
- 'All http- prefixed query parameters will be removed from the sent query parameters.'
305
+ 'HTTP headers and request method can be set with cURL like options.',
306
+ 'Example: --out "http://example.com -X POST -H Content-Type:text/json"'
308
307
  ]
309
308
  end
310
309
 
@@ -49,7 +49,4 @@ module Cucumber
49
49
  super(messages.join("\n"))
50
50
  end
51
51
  end
52
-
53
- class LogTypeInvalid < StandardError
54
- end
55
52
  end
@@ -38,7 +38,8 @@ module Cucumber
38
38
  TestStepCreated,
39
39
  TestStepFinished,
40
40
  TestStepStarted,
41
- Envelope
41
+ Envelope,
42
+ UndefinedParameterType
42
43
  )
43
44
  end
44
45
  end
@@ -0,0 +1,10 @@
1
+ require 'cucumber/core/events'
2
+
3
+ module Cucumber
4
+ module Events
5
+ class UndefinedParameterType < Core::Event.new(:type_name, :expression)
6
+ attr_reader :type_name
7
+ attr_reader :expression
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/ModuleLength
4
+
3
5
  require 'cucumber/formatter/ansicolor'
4
6
  require 'cucumber/formatter/duration'
5
7
  require 'cucumber/gherkin/i18n'
@@ -116,14 +118,21 @@ module Cucumber
116
118
  @snippets_input << Console::SnippetData.new(keyword, test_step)
117
119
  end
118
120
 
121
+ def collect_undefined_parameter_type_names(undefined_parameter_type)
122
+ @undefined_parameter_types << undefined_parameter_type.type_name
123
+ end
124
+
119
125
  def print_snippets(options)
120
126
  return unless options[:snippets]
121
- return if @snippets_input.empty?
122
127
 
123
128
  snippet_text_proc = lambda do |step_keyword, step_name, multiline_arg|
124
129
  snippet_text(step_keyword, step_name, multiline_arg)
125
130
  end
126
- do_print_snippets(snippet_text_proc)
131
+ do_print_snippets(snippet_text_proc) unless @snippets_input.empty?
132
+
133
+ @undefined_parameter_types.map do |type_name|
134
+ do_print_undefined_parameter_type_snippet(type_name)
135
+ end
127
136
  end
128
137
 
129
138
  def do_print_snippets(snippet_text_proc)
@@ -181,6 +190,24 @@ module Cucumber
181
190
  @io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size > 1}..."
182
191
  end
183
192
 
193
+ def do_print_undefined_parameter_type_snippet(type_name)
194
+ camelized = type_name.split(/_|-/).collect(&:capitalize).join
195
+
196
+ @io.puts [
197
+ "The parameter #{type_name} is not defined. You can define a new one with:",
198
+ '',
199
+ 'ParameterType(',
200
+ " name: '#{type_name}',",
201
+ ' regexp: /some regexp here/,',
202
+ " type: #{camelized},",
203
+ ' # The transformer takes as many arguments as there are capture groups in the regexp,',
204
+ ' # or just one if there are none.',
205
+ " transformer: ->(s) { #{camelized}.new(s) }",
206
+ ')',
207
+ ''
208
+ ].join("\n")
209
+ end
210
+
184
211
  private
185
212
 
186
213
  FORMATS = Hash.new { |hash, format| hash[format] = method(format).to_proc }
@@ -219,3 +246,4 @@ module Cucumber
219
246
  end
220
247
  end
221
248
  end
249
+ # rubocop:enable Metrics/ModuleLength
@@ -29,6 +29,7 @@ module Cucumber
29
29
  config.on_event :test_step_finished, &method(:on_test_step_finished)
30
30
  config.on_event :test_case_finished, &method(:on_test_case_finished)
31
31
  config.on_event :test_run_finished, &method(:on_test_run_finished)
32
+ config.on_event :undefined_parameter_type, &method(:on_undefined_parameter_type)
32
33
 
33
34
  @test_case_by_step_id = {}
34
35
  @current_test_case_started_id = nil
@@ -235,6 +236,17 @@ module Cucumber
235
236
  output_envelope(message)
236
237
  end
237
238
 
239
+ def on_undefined_parameter_type(event)
240
+ message = Cucumber::Messages::Envelope.new(
241
+ undefined_parameter_type: Cucumber::Messages::UndefinedParameterType.new(
242
+ name: event.type_name,
243
+ expression: event.expression
244
+ )
245
+ )
246
+
247
+ output_envelope(message)
248
+ end
249
+
238
250
  def test_case_started_id(test_case)
239
251
  @test_case_started_by_test_case.test_case_started_id_by_test_case(test_case)
240
252
  end
@@ -36,6 +36,7 @@ module Cucumber
36
36
  @config = config
37
37
  @options = config.to_hash
38
38
  @snippets_input = []
39
+ @undefined_parameter_types = []
39
40
  @total_duration = 0
40
41
  @exceptions = []
41
42
  @gherkin_sources = {}
@@ -54,6 +55,11 @@ module Cucumber
54
55
  @passed_test_cases = []
55
56
  @source_indent = 0
56
57
  @next_comment_to_be_printed = 0
58
+
59
+ bind_events(config)
60
+ end
61
+
62
+ def bind_events(config)
57
63
  config.on_event :gherkin_source_read, &method(:on_gherkin_source_read)
58
64
  config.on_event :step_activated, &method(:on_step_activated)
59
65
  config.on_event :test_case_started, &method(:on_test_case_started)
@@ -61,6 +67,7 @@ module Cucumber
61
67
  config.on_event :test_step_finished, &method(:on_test_step_finished)
62
68
  config.on_event :test_case_finished, &method(:on_test_case_finished)
63
69
  config.on_event :test_run_finished, &method(:on_test_run_finished)
70
+ config.on_event :undefined_parameter_type, &method(:collect_undefined_parameter_type_names)
64
71
  end
65
72
 
66
73
  def on_gherkin_source_read(event)
@@ -21,6 +21,7 @@ module Cucumber
21
21
  @config = config
22
22
  @io = ensure_io(config.out_stream)
23
23
  @snippets_input = []
24
+ @undefined_parameter_types = []
24
25
  @total_duration = 0
25
26
  @matches = {}
26
27
  @pending_step_matches = []
@@ -36,6 +37,7 @@ module Cucumber
36
37
  config.on_event :test_step_finished, &method(:on_test_step_finished)
37
38
  config.on_event :test_case_finished, &method(:on_test_case_finished)
38
39
  config.on_event :test_run_finished, &method(:on_test_run_finished)
40
+ config.on_event :undefined_parameter_type, &method(:collect_undefined_parameter_type_names)
39
41
  end
40
42
 
41
43
  def on_step_activated(event)
@@ -107,9 +107,8 @@ module Cucumber
107
107
  attach(file, mime_type)
108
108
  end
109
109
 
110
- def log(message)
111
- raise Cucumber::LogTypeInvalid unless message.is_a?(String)
112
- attach(message.dup, 'text/x.cucumber.log+plain')
110
+ def log(*messages)
111
+ messages.each { |message| attach(message.to_s.dup, 'text/x.cucumber.log+plain') }
113
112
  end
114
113
 
115
114
  def attach(file, media_type)
@@ -93,12 +93,7 @@ module Cucumber
93
93
  # TODO: add a way to extract the parameter type directly from the error.
94
94
  type_name = e.message.match(/^Undefined parameter type \{(.*)\}$/)[1]
95
95
 
96
- @configuration.notify :envelope, Cucumber::Messages::Envelope.new(
97
- undefined_parameter_type: Cucumber::Messages::UndefinedParameterType.new(
98
- name: type_name,
99
- expression: string_or_regexp
100
- )
101
- )
96
+ @configuration.notify :undefined_parameter_type, type_name, string_or_regexp
102
97
  end
103
98
 
104
99
  def build_rb_world_factory(world_modules, namespaced_world_modules, proc)
@@ -156,7 +156,7 @@ module Cucumber
156
156
 
157
157
  def runner(_task_args = nil) #:nodoc:
158
158
  cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
159
- return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if @fork
159
+ return ForkedCucumberRunner.new(libs, binary, cucumber_opts, bundler, feature_files) if fork
160
160
  InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
161
161
  end
162
162
 
@@ -1 +1 @@
1
- 4.0.0.rc.6
1
+ 4.0.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc.6
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-04-24 00:00:00.000000000 Z
13
+ date: 2020-06-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: builder
@@ -212,26 +212,6 @@ dependencies:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: 1.0.2
215
- - !ruby/object:Gem::Dependency
216
- name: aruba
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- version: 1.0.0
222
- - - "~>"
223
- - !ruby/object:Gem::Version
224
- version: '1.0'
225
- type: :development
226
- prerelease: false
227
- version_requirements: !ruby/object:Gem::Requirement
228
- requirements:
229
- - - ">="
230
- - !ruby/object:Gem::Version
231
- version: 1.0.0
232
- - - "~>"
233
- - !ruby/object:Gem::Version
234
- version: '1.0'
235
215
  - !ruby/object:Gem::Dependency
236
216
  name: nokogiri
237
217
  requirement: !ruby/object:Gem::Requirement
@@ -514,6 +494,7 @@ files:
514
494
  - lib/cucumber/events/test_step_created.rb
515
495
  - lib/cucumber/events/test_step_finished.rb
516
496
  - lib/cucumber/events/test_step_started.rb
497
+ - lib/cucumber/events/undefined_parameter_type.rb
517
498
  - lib/cucumber/file_specs.rb
518
499
  - lib/cucumber/filters.rb
519
500
  - lib/cucumber/filters/activate_steps.rb
@@ -625,12 +606,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
625
606
  version: '2.3'
626
607
  required_rubygems_version: !ruby/object:Gem::Requirement
627
608
  requirements:
628
- - - ">"
609
+ - - ">="
629
610
  - !ruby/object:Gem::Version
630
- version: 1.3.1
611
+ version: '0'
631
612
  requirements: []
632
613
  rubygems_version: 3.0.6
633
614
  signing_key:
634
615
  specification_version: 4
635
- summary: cucumber-4.0.0.rc.6
616
+ summary: cucumber-4.0.0
636
617
  test_files: []