cucumber 4.0.0.rc.3 → 4.0.1

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 -2
  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 +116 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee911dfd2e4141ad61af0c67b5c9be6e169fe2d27bd2a9c407a590fe9eb0e72a
4
- data.tar.gz: 28fd680ef1f6f8d60bbcaba4a44c153d94d0a626c873aac9956b7ee8b36e8c7b
3
+ metadata.gz: 1c37c07474eae1f9984186ac8f920b7440a5865fb8581d56fe9299d794d6b6c2
4
+ data.tar.gz: 234b2ccdba26251b7017dab7f73eceb310057ab9e68c64686aee94d8e33fc818
5
5
  SHA512:
6
- metadata.gz: 75974422135d45e115c32f685e88971eeec3f1c13473a0fc312412c4f73b665e84d439840642c67b93076a7499cf0130e28caddbb6761e5780b8e29b66e767eb
7
- data.tar.gz: d0eebdfd398decebf6fd0982306f31d501794bb8c5866452e0e65354a3af10da9d50c49cd08a137ec87193902cc2934e70340bed5a41b23ee59f84191c66add8
6
+ metadata.gz: 7aefc0d27a3f54413f8c2f0e4810c32f96374925af78710caca6488617b699c190682eaf7da78fe77fc2060dae77d6ab15871d12025b3520dbed7ce8eb7232a6
7
+ data.tar.gz: 35a3d9a9ed8b5cb1e958a1c14e5bf4050743357382e2a9682645f90e0866c6285f23849217c15bdd71915f122307aabe15dc5dee2c6028abf195289583da522e
@@ -10,7 +10,78 @@ 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.2...v4.0.0.rc.3)
13
+ ## [4.0.1](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0...v4.0.1)
14
+
15
+ ### Fixed
16
+
17
+ * force reference to `diff-lcs` to 1.3 as 1.4 introduced breaking changes.
18
+
19
+ ## [4.0.0](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.5...v4.0.0)
20
+
21
+ ### Changed
22
+
23
+ * `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)
24
+
25
+ ### Improved
26
+
27
+ * Display snippet when using undefined parameter type [#1411](https://github.com/cucumber/cucumber-ruby/issues/1411)
28
+
29
+ ## [4.0.0.rc.6](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.5...4.0.0.rc.6)
30
+
31
+ ### Changed
32
+
33
+ * Code snippet for an undefined step with a Doc String will ouput `doc_string` instead of `string` in block params
34
+ ([#1401](https://github.com/cucumber/cucumber-ruby/issues/1401)
35
+ [#1402](https://github.com/cucumber/cucumber-ruby/pull/1402)
36
+ [karamosky](https://github.com/karamosky))
37
+
38
+ * Updated monorepo libraries:
39
+ - cucumber-gherkin ~> 13
40
+ - cucumber-html-formatter ~> 6
41
+ - cucumber-cucumber-expressions ~> 10
42
+
43
+ * Use `cucumber-ruby-core` 7.0.0
44
+
45
+ * Use `cucumber-ruby-wire` 3.0.0
46
+
47
+ * Use `body` field of attachments
48
+
49
+ ### Improved
50
+
51
+ * `--out url` updates:
52
+ * supports redirects
53
+ * use `PUT` method by default
54
+ * use a cURL like options (for example: `cucumber --out 'http://example.com -X POST -H Content-Type: json`)
55
+
56
+ ## [4.0.0.rc.5](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.4...4.0.0.rc.5)
57
+
58
+ ### Added
59
+
60
+ * New html formatter enabled by option `--format html --out report.html`.
61
+
62
+ * Accept `--out URL` to POST results to a web server
63
+ If a URL is used as output, the output will be sent with a POST request.
64
+ This can be overridden by specifying e.g. `http-method=PUT` as a query parameter.
65
+ Other `http-` prefixed query parameters will be converted to request headers
66
+ (with the `http-` prefix stripped off).
67
+
68
+
69
+ ## [4.0.0.rc.4](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.3...4.0.0.rc.4)
70
+
71
+ ### Added
72
+
73
+ * Add `message`formatter which produces `Cucumber::Messages` ndjson output.
74
+ * Comply with [`cucumber-compatibility-kit](https://github.com/cucumber/cucumber/tree/master/compatibility-kit)
75
+ * Methods `log` and `attach` can be used in step definitions to attach text or images
76
+
77
+ ### Deprecated
78
+
79
+ * `--format=json` in favor of the `message` formatter and the stand-alone JSON formatter
80
+ * `puts` in step definitions in favor of `log` ([cucumber#897](https://github.com/cucumber/cucumber/issues/897))
81
+ * `embed` in step definitions in favor of `attach` ([cucumber#897](https://github.com/cucumber/cucumber/issues/897))
82
+
83
+
84
+ ## [4.0.0.rc.3](https://github.com/cucumber/cucumber-ruby/compare/v4.0.0.rc.2...v4.0.0.rc.3)
14
85
 
15
86
  ### Changed
16
87
 
@@ -26,7 +97,7 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
26
97
  * If you wish to alter this, then you can set a top level config option: `Cucumber.use_legacy_autoloader`
27
98
  * Like most config options, setting this inside a `spec_helper.rb` or `env.rb` file is advised
28
99
  * For more information on this change, including why it was made. Please read this
29
- [Blog Post](www.google.com)
100
+ [Blog Post](https://cucumber.io/blog/open-source/tweaking-cucumber-rubys-auto-loader/)
30
101
  ([#1349](https://github.com/cucumber/cucumber-ruby/pull/1349),
31
102
  [#1043](https://github.com/cucumber/cucumber-ruby/issues/1043)
32
103
  [luke-hill](https://github.com/luke-hill))
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