cucumber 4.0.0.rc.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +73 -1
  3. data/README.md +2 -2
  4. data/lib/cucumber/cli/options.rb +10 -4
  5. data/lib/cucumber/configuration.rb +5 -0
  6. data/lib/cucumber/deprecate.rb +29 -5
  7. data/lib/cucumber/events.rb +13 -7
  8. data/lib/cucumber/events/envelope.rb +9 -0
  9. data/lib/cucumber/events/hook_test_step_created.rb +13 -0
  10. data/lib/cucumber/events/test_case_created.rb +13 -0
  11. data/lib/cucumber/events/test_case_ready.rb +12 -0
  12. data/lib/cucumber/events/test_step_created.rb +13 -0
  13. data/lib/cucumber/events/undefined_parameter_type.rb +10 -0
  14. data/lib/cucumber/filters.rb +1 -0
  15. data/lib/cucumber/filters/broadcast_test_case_ready_event.rb +12 -0
  16. data/lib/cucumber/formatter/console.rb +33 -10
  17. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  18. data/lib/cucumber/formatter/errors.rb +6 -0
  19. data/lib/cucumber/formatter/html.rb +24 -0
  20. data/lib/cucumber/formatter/http_io.rb +146 -0
  21. data/lib/cucumber/formatter/interceptor.rb +3 -8
  22. data/lib/cucumber/formatter/io.rb +14 -8
  23. data/lib/cucumber/formatter/json.rb +17 -8
  24. data/lib/cucumber/formatter/junit.rb +1 -1
  25. data/lib/cucumber/formatter/message.rb +22 -0
  26. data/lib/cucumber/formatter/message_builder.rb +255 -0
  27. data/lib/cucumber/formatter/pretty.rb +10 -4
  28. data/lib/cucumber/formatter/progress.rb +2 -0
  29. data/lib/cucumber/formatter/query/hook_by_test_step.rb +31 -0
  30. data/lib/cucumber/formatter/query/pickle_by_test.rb +26 -0
  31. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +26 -0
  32. data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +40 -0
  33. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +40 -0
  34. data/lib/cucumber/gherkin/data_table_parser.rb +1 -1
  35. data/lib/cucumber/gherkin/steps_parser.rb +1 -1
  36. data/lib/cucumber/glue/hook.rb +18 -2
  37. data/lib/cucumber/glue/proto_world.rb +29 -18
  38. data/lib/cucumber/glue/registry_and_more.rb +27 -2
  39. data/lib/cucumber/glue/snippet.rb +1 -1
  40. data/lib/cucumber/glue/step_definition.rb +28 -4
  41. data/lib/cucumber/hooks.rb +8 -8
  42. data/lib/cucumber/multiline_argument.rb +1 -1
  43. data/lib/cucumber/multiline_argument/data_table.rb +17 -13
  44. data/lib/cucumber/platform.rb +1 -1
  45. data/lib/cucumber/rake/task.rb +1 -1
  46. data/lib/cucumber/runtime.rb +29 -3
  47. data/lib/cucumber/runtime/after_hooks.rb +6 -2
  48. data/lib/cucumber/runtime/before_hooks.rb +6 -2
  49. data/lib/cucumber/runtime/for_programming_languages.rb +1 -0
  50. data/lib/cucumber/runtime/step_hooks.rb +3 -2
  51. data/lib/cucumber/runtime/support_code.rb +3 -3
  52. data/lib/cucumber/runtime/user_interface.rb +2 -10
  53. data/lib/cucumber/version +1 -1
  54. metadata +108 -91
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63fada72f4a011868619082a74f21360edd8751372c468509d2c56db437c29e1
4
- data.tar.gz: 5a0454b1251822723b3f5d6f777907e7c49751201f292357730350816a09123a
3
+ metadata.gz: fd820c5e08e32e33bba11e646e1e98d4382028b6e071914ddcb4982bb0657278
4
+ data.tar.gz: 13c93ab1fa304955ac45f8ce702eeb68dbcf2e316e383c9ae0ababe04a476762
5
5
  SHA512:
6
- metadata.gz: 6947dbe7784aa7068e892762c1f96faced5842feb16e1b756a2a5c181a46f021f1c0df56229a266003137ef0009d97c9e5489e971ceeed24bf0b432c3fd16769
7
- data.tar.gz: fa930e37ce5a05ee31e270d1f20642defb0b771142969d8945550543e60dd8546afdd272e5707319a7b00ce9bfa9d28e01e6da8f2585a8e97a25b08072a31b75
6
+ metadata.gz: ddd5940fbb47aaa12942842323cf81372051ddf0ad496d9213dd93d0538afbe80e5e35edf6a5d27ccdea2840a1091f86b6f65ec46e14e017cbbe724fd61e1269
7
+ data.tar.gz: 27e575d0c0730bf88574d7e42262e031ff34328b71a22af15d0a3c1dc8d3b14dacc7d62250a912de01dda4d85bdd22615d166faaa78b81dc5e24bb75a71374fd
@@ -10,7 +10,79 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
10
10
 
11
11
  ----
12
12
 
13
- ## [4.0.0.rc.2](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.1...v4.0.0.rc.2) (Not released)
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
+
23
+ ## [4.0.0.rc.6](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.5...4.0.0.rc.6)
24
+
25
+ ### Changed
26
+
27
+ * Code snippet for an undefined step with a Doc String will ouput `doc_string` instead of `string` in block params
28
+ ([#1401](https://github.com/cucumber/cucumber-ruby/issues/1401)
29
+ [#1402](https://github.com/cucumber/cucumber-ruby/pull/1402)
30
+ [karamosky](https://github.com/karamosky))
31
+
32
+ * Updated monorepo libraries:
33
+ - cucumber-gherkin ~> 13
34
+ - cucumber-html-formatter ~> 6
35
+ - cucumber-cucumber-expressions ~> 10
36
+
37
+ * Use `cucumber-ruby-core` 7.0.0
38
+
39
+ * Use `cucumber-ruby-wire` 3.0.0
40
+
41
+ * Use `body` field of attachments
42
+
43
+ ### Improved
44
+
45
+ * `--out url` updates:
46
+ * supports redirects
47
+ * use `PUT` method by default
48
+ * use a cURL like options (for example: `cucumber --out 'http://example.com -X POST -H Content-Type: json`)
49
+
50
+ ## [4.0.0.rc.5](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.4...4.0.0.rc.5)
51
+
52
+ ### Added
53
+
54
+ * New html formatter enabled by option `--format html --out report.html`.
55
+
56
+ * Accept `--out URL` to POST results to a web server
57
+ If a URL is used as output, the output will be sent with a POST request.
58
+ This can be overridden by specifying e.g. `http-method=PUT` as a query parameter.
59
+ Other `http-` prefixed query parameters will be converted to request headers
60
+ (with the `http-` prefix stripped off).
61
+
62
+
63
+ ## [4.0.0.rc.4](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.3...4.0.0.rc.4)
64
+
65
+ ### Added
66
+
67
+ * Add `message`formatter which produces `Cucumber::Messages` ndjson output.
68
+ * Comply with [`cucumber-compatibility-kit](https://github.com/cucumber/cucumber/tree/master/compatibility-kit)
69
+ * Methods `log` and `attach` can be used in step definitions to attach text or images
70
+
71
+ ### Deprecated
72
+
73
+ * `--format=json` in favor of the `message` formatter and the stand-alone JSON formatter
74
+ * `puts` in step definitions in favor of `log` ([cucumber#897](https://github.com/cucumber/cucumber/issues/897))
75
+ * `embed` in step definitions in favor of `attach` ([cucumber#897](https://github.com/cucumber/cucumber/issues/897))
76
+
77
+
78
+ ## [4.0.0.rc.3](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.2...v4.0.0.rc.3)
79
+
80
+ ### Changed
81
+
82
+ * Update to cucumber-wire 1.1.
83
+
84
+
85
+ ## [4.0.0.rc.2](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.1...v4.0.0.rc.2)
14
86
 
15
87
  ### Added
16
88
  * There is a new methodology in Cucumber for how the auto-loader works
data/README.md CHANGED
@@ -15,7 +15,7 @@ your team.
15
15
 
16
16
  Where to get more info:
17
17
 
18
- * The main website: https://cucumber.io/
18
+ * The main website: https://cucumber.io/
19
19
  * Documentation: https://cucumber.io/docs
20
20
  * Ruby API Documentation: http://www.rubydoc.info/github/cucumber/cucumber-ruby/
21
21
  * Support forum: https://groups.google.com/group/cukes
@@ -28,7 +28,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for info on contributing to Cucumber.
28
28
  * Ruby 2.5
29
29
  * Ruby 2.4
30
30
  * Ruby 2.3
31
- * JRuby 9.1
31
+ * JRuby 9.2 (with [some limitations](https://github.com/cucumber/cucumber-ruby/blob/master/docs/jruby-limitations.md))
32
32
 
33
33
  ## Code of Conduct
34
34
 
@@ -22,7 +22,9 @@ module Cucumber
22
22
  'stepdefs' => ['Cucumber::Formatter::Stepdefs', "Prints All step definitions with their locations. Same as\n" \
23
23
  "#{INDENT}the usage formatter, except that steps are not printed."],
24
24
  'junit' => ['Cucumber::Formatter::Junit', 'Generates a report similar to Ant+JUnit.'],
25
- 'json' => ['Cucumber::Formatter::Json', 'Prints the feature as JSON'],
25
+ 'json' => ['Cucumber::Formatter::Json', '[DEPRECATED] Prints the feature as JSON'],
26
+ 'message' => ['Cucumber::Formatter::Message', 'Outputs protobuf messages'],
27
+ 'html' => ['Cucumber::Formatter::HTML', 'Outputs HTML report'],
26
28
  'summary' => ['Cucumber::Formatter::Summary', 'Summary output of feature and scenarios']
27
29
  }.freeze
28
30
  max = BUILTIN_FORMATS.keys.map(&:length).max
@@ -103,7 +105,7 @@ module Cucumber
103
105
  add_option :formats, [*parse_formats(v), @out_stream]
104
106
  end
105
107
  opts.on('--init', *init_msg) { |_v| initialize_project }
106
- opts.on('-o', '--out [FILE|DIR]', *out_msg) { |v| out_stream v }
108
+ opts.on('-o', '--out [FILE|DIR|URL]', *out_msg) { |v| out_stream v }
107
109
  opts.on('-t TAG_EXPRESSION', '--tags TAG_EXPRESSION', *tags_msg) { |v| add_tag v }
108
110
  opts.on('-n NAME', '--name NAME', *name_msg) { |v| add_option :name_regexps, /#{v}/ }
109
111
  opts.on('-e', '--exclude PATTERN', *exclude_msg) { |v| add_option :excludes, Regexp.new(v) }
@@ -294,10 +296,14 @@ Specify SEED to reproduce the shuffling from a previous run.
294
296
 
295
297
  def out_msg
296
298
  [
297
- 'Write output to a file/directory instead of STDOUT. This option',
299
+ 'Write output to a file/directory/URL instead of STDOUT. This option',
298
300
  'applies to the previously specified --format, or the',
299
301
  'default format if no format is specified. Check the specific',
300
- "formatter's docs to see whether to pass a file or a dir."
302
+ "formatter's docs to see whether to pass a file, dir or URL.",
303
+ "\n",
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 cURL like options.',
306
+ 'Example: --out "http://example.com -X POST -H Content-Type:text/json"'
301
307
  ]
302
308
  end
303
309
 
@@ -3,6 +3,7 @@
3
3
  require 'cucumber/constantize'
4
4
  require 'cucumber/cli/rerun_file'
5
5
  require 'cucumber/events'
6
+ require 'cucumber/messages'
6
7
  require 'cucumber/core/event_bus'
7
8
  require 'cucumber/core/test/result'
8
9
  require 'forwardable'
@@ -242,6 +243,10 @@ module Cucumber
242
243
  @options[:event_bus]
243
244
  end
244
245
 
246
+ def id_generator
247
+ @id_generator ||= Cucumber::Messages::IdGenerator::UUID.new
248
+ end
249
+
245
250
  private
246
251
 
247
252
  def default_options
@@ -5,13 +5,37 @@ require 'cucumber/gherkin/formatter/ansi_escapes'
5
5
 
6
6
  module Cucumber
7
7
  module Deprecate
8
- module ForUsers
9
- AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
8
+ class AnsiString
9
+ include Cucumber::Gherkin::Formatter::AnsiEscapes
10
+
11
+ def self.failure_message(message)
12
+ AnsiString.new.failure_message(message)
13
+ end
14
+
15
+ def failure_message(message)
16
+ failed + message + reset
17
+ end
18
+ end
10
19
 
20
+ class CliOption
21
+ def self.deprecate(stream, option, message, remove_after_version)
22
+ return if stream.nil?
23
+ stream.puts(
24
+ AnsiString.failure_message(
25
+ "\nWARNING: #{option} is deprecated" \
26
+ " and will be removed after version #{remove_after_version}.\n#{message}.\n"
27
+ )
28
+ )
29
+ end
30
+ end
31
+
32
+ module ForUsers
11
33
  def self.call(message, method, remove_after_version)
12
- STDERR.puts AnsiEscapes.failed + "\nWARNING: ##{method} is deprecated" \
13
- " and will be removed after version #{remove_after_version}. #{message}.\n" \
14
- "(Called from #{caller(3..3).first})" + AnsiEscapes.reset
34
+ STDERR.puts AnsiString.failure_message(
35
+ "\nWARNING: ##{method} is deprecated" \
36
+ " and will be removed after version #{remove_after_version}. #{message}.\n" \
37
+ "(Called from #{caller(3..3).first})"
38
+ )
15
39
  end
16
40
  end
17
41
 
@@ -24,16 +24,22 @@ module Cucumber
24
24
 
25
25
  def self.registry
26
26
  Core::Events.build_registry(
27
- TestCaseStarted,
27
+ GherkinSourceParsed,
28
+ GherkinSourceRead,
29
+ HookTestStepCreated,
30
+ StepActivated,
31
+ StepDefinitionRegistered,
32
+ TestCaseCreated,
28
33
  TestCaseFinished,
34
+ TestCaseStarted,
35
+ TestCaseReady,
36
+ TestRunFinished,
37
+ TestRunStarted,
38
+ TestStepCreated,
29
39
  TestStepFinished,
30
40
  TestStepStarted,
31
- StepDefinitionRegistered,
32
- StepActivated,
33
- TestRunFinished,
34
- GherkinSourceRead,
35
- GherkinSourceParsed,
36
- TestRunStarted
41
+ Envelope,
42
+ UndefinedParameterType
37
43
  )
38
44
  end
39
45
  end
@@ -0,0 +1,9 @@
1
+ require 'cucumber/core/events'
2
+
3
+ module Cucumber
4
+ module Events
5
+ class Envelope < Core::Event.new(:envelope)
6
+ attr_reader :envelope
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/events'
4
+
5
+ module Cucumber
6
+ module Events
7
+ # Event fired when a step is created from a hook
8
+ class HookTestStepCreated < Core::Event.new(:test_step, :hook)
9
+ attr_reader :test_step
10
+ attr_reader :hook
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/events'
4
+
5
+ module Cucumber
6
+ module Events
7
+ # Event fired when a Test::Case is created from a Pickle
8
+ class TestCaseCreated < Core::Event.new(:test_case, :pickle)
9
+ attr_reader :test_case
10
+ attr_reader :pickle
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/events'
4
+
5
+ module Cucumber
6
+ module Events
7
+ # Event fired when a Test::Case is ready to be ran (matching has been done, hooks added etc)
8
+ class TestCaseReady < Core::Event.new(:test_case)
9
+ attr_reader :test_case
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/events'
4
+
5
+ module Cucumber
6
+ module Events
7
+ # Event fired when a TestStep is created from a PickleStep
8
+ class TestStepCreated < Core::Event.new(:test_step, :pickle_step)
9
+ attr_reader :test_step
10
+ attr_reader :pickle_step
11
+ end
12
+ end
13
+ 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
@@ -11,3 +11,4 @@ require 'cucumber/filters/quit'
11
11
  require 'cucumber/filters/randomizer'
12
12
  require 'cucumber/filters/retry'
13
13
  require 'cucumber/filters/tag_limits'
14
+ require 'cucumber/filters/broadcast_test_case_ready_event'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Filters
5
+ class BroadcastTestCaseReadyEvent < Core::Filter.new(:config)
6
+ def test_case(test_case)
7
+ config.notify :test_case_ready, test_case
8
+ test_case.describe_to(receiver)
9
+ end
10
+ end
11
+ end
12
+ 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)
@@ -158,16 +167,11 @@ module Cucumber
158
167
  end
159
168
  end
160
169
 
161
- def embed(file, mime_type, label)
162
- # no-op
163
- end
164
-
165
- def puts(*messages)
170
+ def attach(src, media_type)
171
+ return unless media_type == 'text/x.cucumber.log+plain'
166
172
  return unless @io
167
173
  @io.puts
168
- messages.each do |message|
169
- @io.puts(format_string(message, :tag))
170
- end
174
+ @io.puts(format_string(src, :tag))
171
175
  @io.flush
172
176
  end
173
177
 
@@ -186,6 +190,24 @@ module Cucumber
186
190
  @io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size > 1}..."
187
191
  end
188
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
+
189
211
  private
190
212
 
191
213
  FORMATS = Hash.new { |hash, format| hash[format] = method(format).to_proc }
@@ -224,3 +246,4 @@ module Cucumber
224
246
  end
225
247
  end
226
248
  end
249
+ # rubocop:enable Metrics/ModuleLength
@@ -25,7 +25,7 @@ module Cucumber
25
25
  duration.tap { |dur| @result_duration = dur.nanoseconds / 10**9.0 }
26
26
  end
27
27
 
28
- def embed(*) end
28
+ def attach(*) end
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,6 @@
1
+ module Cucumber
2
+ module Formatter
3
+ class TestCaseUnknownError < StandardError; end
4
+ class TestStepUnknownError < StandardError; end
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ require 'cucumber/formatter/io'
2
+ require 'cucumber/html_formatter'
3
+ require 'cucumber/formatter/message_builder'
4
+
5
+ module Cucumber
6
+ module Formatter
7
+ class HTML < MessageBuilder
8
+ include Io
9
+
10
+ def initialize(config)
11
+ @io = ensure_io(config.out_stream)
12
+ @html_formatter = Cucumber::HTMLFormatter::Formatter.new(@io)
13
+ @html_formatter.write_pre_message
14
+
15
+ super(config)
16
+ end
17
+
18
+ def output_envelope(envelope)
19
+ @html_formatter.write_message(envelope)
20
+ @html_formatter.write_post_message if envelope.test_run_finished
21
+ end
22
+ end
23
+ end
24
+ end