cucumber-messages 22.0.0 → 27.2.0

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/README.md +1 -0
  4. data/VERSION +1 -1
  5. data/lib/cucumber/messages/attachment.rb +131 -0
  6. data/lib/cucumber/messages/attachment_content_encoding.rb +11 -0
  7. data/lib/cucumber/messages/background.rb +64 -0
  8. data/lib/cucumber/messages/ci.rb +62 -0
  9. data/lib/cucumber/messages/comment.rb +50 -0
  10. data/lib/cucumber/messages/data_table.rb +41 -0
  11. data/lib/cucumber/messages/doc_string.rb +51 -0
  12. data/lib/cucumber/messages/duration.rb +50 -0
  13. data/lib/cucumber/messages/envelope.rb +134 -0
  14. data/lib/cucumber/messages/examples.rb +74 -0
  15. data/lib/cucumber/messages/exception.rb +57 -0
  16. data/lib/cucumber/messages/feature.rb +87 -0
  17. data/lib/cucumber/messages/feature_child.rb +49 -0
  18. data/lib/cucumber/messages/gherkin_document.rb +62 -0
  19. data/lib/cucumber/messages/git.rb +54 -0
  20. data/lib/cucumber/messages/group.rb +46 -0
  21. data/lib/cucumber/messages/helpers/id_generator/incrementing.rb +20 -0
  22. data/lib/cucumber/messages/helpers/id_generator/uuid.rb +17 -0
  23. data/lib/cucumber/messages/helpers/id_generator.rb +4 -0
  24. data/lib/cucumber/messages/helpers/ndjson_to_message_enumerator.rb +30 -0
  25. data/lib/cucumber/messages/helpers/time_conversion.rb +31 -0
  26. data/lib/cucumber/messages/hook.rb +56 -0
  27. data/lib/cucumber/messages/hook_type.rb +15 -0
  28. data/lib/cucumber/messages/java_method.rb +46 -0
  29. data/lib/cucumber/messages/java_stack_trace_element.rb +46 -0
  30. data/lib/cucumber/messages/location.rb +44 -0
  31. data/lib/cucumber/messages/message.rb +93 -5
  32. data/lib/cucumber/messages/meta.rb +81 -0
  33. data/lib/cucumber/messages/parameter_type.rb +64 -0
  34. data/lib/cucumber/messages/parse_error.rb +41 -0
  35. data/lib/cucumber/messages/pickle.rb +107 -0
  36. data/lib/cucumber/messages/pickle_doc_string.rb +41 -0
  37. data/lib/cucumber/messages/pickle_step.rb +71 -0
  38. data/lib/cucumber/messages/pickle_step_argument.rb +43 -0
  39. data/lib/cucumber/messages/pickle_step_type.rb +13 -0
  40. data/lib/cucumber/messages/pickle_table.rb +36 -0
  41. data/lib/cucumber/messages/pickle_table_cell.rb +36 -0
  42. data/lib/cucumber/messages/pickle_table_row.rb +36 -0
  43. data/lib/cucumber/messages/pickle_tag.rb +47 -0
  44. data/lib/cucumber/messages/product.rb +49 -0
  45. data/lib/cucumber/messages/rule.rb +72 -0
  46. data/lib/cucumber/messages/rule_child.rb +44 -0
  47. data/lib/cucumber/messages/scenario.rb +74 -0
  48. data/lib/cucumber/messages/source.rb +63 -0
  49. data/lib/cucumber/messages/source_media_type.rb +11 -0
  50. data/lib/cucumber/messages/source_reference.rb +55 -0
  51. data/lib/cucumber/messages/step.rb +80 -0
  52. data/lib/cucumber/messages/step_definition.rb +46 -0
  53. data/lib/cucumber/messages/step_definition_pattern.rb +41 -0
  54. data/lib/cucumber/messages/step_definition_pattern_type.rb +11 -0
  55. data/lib/cucumber/messages/step_keyword_type.rb +14 -0
  56. data/lib/cucumber/messages/step_match_argument.rb +54 -0
  57. data/lib/cucumber/messages/step_match_arguments_list.rb +36 -0
  58. data/lib/cucumber/messages/table_cell.rb +49 -0
  59. data/lib/cucumber/messages/table_row.rb +54 -0
  60. data/lib/cucumber/messages/tag.rb +58 -0
  61. data/lib/cucumber/messages/test_case.rb +62 -0
  62. data/lib/cucumber/messages/test_case_finished.rb +46 -0
  63. data/lib/cucumber/messages/test_case_started.rb +69 -0
  64. data/lib/cucumber/messages/test_run_finished.rb +68 -0
  65. data/lib/cucumber/messages/test_run_hook_finished.rb +49 -0
  66. data/lib/cucumber/messages/test_run_hook_started.rb +60 -0
  67. data/lib/cucumber/messages/test_run_started.rb +41 -0
  68. data/lib/cucumber/messages/test_step.rb +74 -0
  69. data/lib/cucumber/messages/test_step_finished.rb +51 -0
  70. data/lib/cucumber/messages/test_step_result.rb +57 -0
  71. data/lib/cucumber/messages/test_step_result_status.rb +16 -0
  72. data/lib/cucumber/messages/test_step_started.rb +46 -0
  73. data/lib/cucumber/messages/timestamp.rb +52 -0
  74. data/lib/cucumber/messages/undefined_parameter_type.rb +41 -0
  75. data/lib/cucumber/messages.rb +9 -5
  76. metadata +140 -61
  77. data/lib/cucumber/messages/id_generator.rb +0 -24
  78. data/lib/cucumber/messages/message/deserialization.rb +0 -39
  79. data/lib/cucumber/messages/message/serialization.rb +0 -73
  80. data/lib/cucumber/messages/message/utils.rb +0 -46
  81. data/lib/cucumber/messages/ndjson_to_message_enumerator.rb +0 -21
  82. data/lib/cucumber/messages/time_conversion.rb +0 -33
  83. data/lib/cucumber/messages.deserializers.rb +0 -1207
  84. data/lib/cucumber/messages.dtos.rb +0 -2000
  85. data/spec/capture_warnings.rb +0 -74
  86. data/spec/cucumber/messages/acceptance_spec.rb +0 -33
  87. data/spec/cucumber/messages/id_generator_spec.rb +0 -29
  88. data/spec/cucumber/messages/message/deserialization_spec.rb +0 -30
  89. data/spec/cucumber/messages/message/dummy_messages.rb +0 -38
  90. data/spec/cucumber/messages/message/serialization_spec.rb +0 -89
  91. data/spec/cucumber/messages/message/utils_spec.rb +0 -30
  92. data/spec/cucumber/messages/ndjson_serialization_spec.rb +0 -56
  93. data/spec/cucumber/messages/time_conversion_spec.rb +0 -41
  94. data/spec/cucumber/messages/version_spec.rb +0 -11
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Examples message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ ##
10
+ class Examples < Message
11
+ ##
12
+ # The location of the `Examples` keyword
13
+ ##
14
+ attr_reader :location
15
+
16
+ attr_reader :tags
17
+
18
+ attr_reader :keyword
19
+
20
+ attr_reader :name
21
+
22
+ attr_reader :description
23
+
24
+ attr_reader :table_header
25
+
26
+ attr_reader :table_body
27
+
28
+ attr_reader :id
29
+
30
+ def initialize(
31
+ location: Location.new,
32
+ tags: [],
33
+ keyword: '',
34
+ name: '',
35
+ description: '',
36
+ table_header: nil,
37
+ table_body: [],
38
+ id: ''
39
+ )
40
+ @location = location
41
+ @tags = tags
42
+ @keyword = keyword
43
+ @name = name
44
+ @description = description
45
+ @table_header = table_header
46
+ @table_body = table_body
47
+ @id = id
48
+ super()
49
+ end
50
+
51
+ ##
52
+ # Returns a new Examples from the given hash.
53
+ # If the hash keys are camelCased, they are properly assigned to the
54
+ # corresponding snake_cased attributes.
55
+ #
56
+ # Cucumber::Messages::Examples.from_h(some_hash) # => #<Cucumber::Messages::Examples:0x... ...>
57
+ ##
58
+ def self.from_h(hash)
59
+ return nil if hash.nil?
60
+
61
+ new(
62
+ location: Location.from_h(hash[:location]),
63
+ tags: hash[:tags]&.map { |item| Tag.from_h(item) },
64
+ keyword: hash[:keyword],
65
+ name: hash[:name],
66
+ description: hash[:description],
67
+ table_header: TableRow.from_h(hash[:tableHeader]),
68
+ table_body: hash[:tableBody]&.map { |item| TableRow.from_h(item) },
69
+ id: hash[:id]
70
+ )
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Exception message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ #
10
+ # A simplified representation of an exception
11
+ ##
12
+ class Exception < Message
13
+ ##
14
+ # The type of the exception that caused this result. E.g. "Error" or "org.opentest4j.AssertionFailedError"
15
+ ##
16
+ attr_reader :type
17
+
18
+ ##
19
+ # The message of exception that caused this result. E.g. expected: "a" but was: "b"
20
+ ##
21
+ attr_reader :message
22
+
23
+ ##
24
+ # The stringified stack trace of the exception that caused this result
25
+ ##
26
+ attr_reader :stack_trace
27
+
28
+ def initialize(
29
+ type: '',
30
+ message: nil,
31
+ stack_trace: nil
32
+ )
33
+ @type = type
34
+ @message = message
35
+ @stack_trace = stack_trace
36
+ super()
37
+ end
38
+
39
+ ##
40
+ # Returns a new Exception from the given hash.
41
+ # If the hash keys are camelCased, they are properly assigned to the
42
+ # corresponding snake_cased attributes.
43
+ #
44
+ # Cucumber::Messages::Exception.from_h(some_hash) # => #<Cucumber::Messages::Exception:0x... ...>
45
+ ##
46
+ def self.from_h(hash)
47
+ return nil if hash.nil?
48
+
49
+ new(
50
+ type: hash[:type],
51
+ message: hash[:message],
52
+ stack_trace: hash[:stackTrace]
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Feature message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ ##
10
+ class Feature < Message
11
+ ##
12
+ # The location of the `Feature` keyword
13
+ ##
14
+ attr_reader :location
15
+
16
+ ##
17
+ # All the tags placed above the `Feature` keyword
18
+ ##
19
+ attr_reader :tags
20
+
21
+ ##
22
+ # The [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) language code of the Gherkin document
23
+ ##
24
+ attr_reader :language
25
+
26
+ ##
27
+ # The text of the `Feature` keyword (in the language specified by `language`)
28
+ ##
29
+ attr_reader :keyword
30
+
31
+ ##
32
+ # The name of the feature (the text following the `keyword`)
33
+ ##
34
+ attr_reader :name
35
+
36
+ ##
37
+ # The line(s) underneath the line with the `keyword` that are used as description
38
+ ##
39
+ attr_reader :description
40
+
41
+ ##
42
+ # Zero or more children
43
+ ##
44
+ attr_reader :children
45
+
46
+ def initialize(
47
+ location: Location.new,
48
+ tags: [],
49
+ language: '',
50
+ keyword: '',
51
+ name: '',
52
+ description: '',
53
+ children: []
54
+ )
55
+ @location = location
56
+ @tags = tags
57
+ @language = language
58
+ @keyword = keyword
59
+ @name = name
60
+ @description = description
61
+ @children = children
62
+ super()
63
+ end
64
+
65
+ ##
66
+ # Returns a new Feature from the given hash.
67
+ # If the hash keys are camelCased, they are properly assigned to the
68
+ # corresponding snake_cased attributes.
69
+ #
70
+ # Cucumber::Messages::Feature.from_h(some_hash) # => #<Cucumber::Messages::Feature:0x... ...>
71
+ ##
72
+ def self.from_h(hash)
73
+ return nil if hash.nil?
74
+
75
+ new(
76
+ location: Location.from_h(hash[:location]),
77
+ tags: hash[:tags]&.map { |item| Tag.from_h(item) },
78
+ language: hash[:language],
79
+ keyword: hash[:keyword],
80
+ name: hash[:name],
81
+ description: hash[:description],
82
+ children: hash[:children]&.map { |item| FeatureChild.from_h(item) }
83
+ )
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the FeatureChild message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ #
10
+ # *
11
+ # A child node of a `Feature` node
12
+ ##
13
+ class FeatureChild < Message
14
+ attr_reader :rule
15
+
16
+ attr_reader :background
17
+
18
+ attr_reader :scenario
19
+
20
+ def initialize(
21
+ rule: nil,
22
+ background: nil,
23
+ scenario: nil
24
+ )
25
+ @rule = rule
26
+ @background = background
27
+ @scenario = scenario
28
+ super()
29
+ end
30
+
31
+ ##
32
+ # Returns a new FeatureChild from the given hash.
33
+ # If the hash keys are camelCased, they are properly assigned to the
34
+ # corresponding snake_cased attributes.
35
+ #
36
+ # Cucumber::Messages::FeatureChild.from_h(some_hash) # => #<Cucumber::Messages::FeatureChild:0x... ...>
37
+ ##
38
+ def self.from_h(hash)
39
+ return nil if hash.nil?
40
+
41
+ new(
42
+ rule: Rule.from_h(hash[:rule]),
43
+ background: Background.from_h(hash[:background]),
44
+ scenario: Scenario.from_h(hash[:scenario])
45
+ )
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the GherkinDocument message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ #
10
+ # *
11
+ # The [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) of a Gherkin document.
12
+ # Cucumber implementations should *not* depend on `GherkinDocument` or any of its
13
+ # children for execution - use [Pickle](#io.cucumber.messages.Pickle) instead.
14
+ #
15
+ # The only consumers of `GherkinDocument` should only be formatters that produce
16
+ # "rich" output, resembling the original Gherkin document.
17
+ ##
18
+ class GherkinDocument < Message
19
+ ##
20
+ # *
21
+ # The [URI](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)
22
+ # of the source, typically a file path relative to the root directory
23
+ ##
24
+ attr_reader :uri
25
+
26
+ attr_reader :feature
27
+
28
+ ##
29
+ # All the comments in the Gherkin document
30
+ ##
31
+ attr_reader :comments
32
+
33
+ def initialize(
34
+ uri: nil,
35
+ feature: nil,
36
+ comments: []
37
+ )
38
+ @uri = uri
39
+ @feature = feature
40
+ @comments = comments
41
+ super()
42
+ end
43
+
44
+ ##
45
+ # Returns a new GherkinDocument from the given hash.
46
+ # If the hash keys are camelCased, they are properly assigned to the
47
+ # corresponding snake_cased attributes.
48
+ #
49
+ # Cucumber::Messages::GherkinDocument.from_h(some_hash) # => #<Cucumber::Messages::GherkinDocument:0x... ...>
50
+ ##
51
+ def self.from_h(hash)
52
+ return nil if hash.nil?
53
+
54
+ new(
55
+ uri: hash[:uri],
56
+ feature: Feature.from_h(hash[:feature]),
57
+ comments: hash[:comments]&.map { |item| Comment.from_h(item) }
58
+ )
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Git message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ #
10
+ # Information about Git, provided by the Build/CI server as environment
11
+ # variables.
12
+ ##
13
+ class Git < Message
14
+ attr_reader :remote
15
+
16
+ attr_reader :revision
17
+
18
+ attr_reader :branch
19
+
20
+ attr_reader :tag
21
+
22
+ def initialize(
23
+ remote: '',
24
+ revision: '',
25
+ branch: nil,
26
+ tag: nil
27
+ )
28
+ @remote = remote
29
+ @revision = revision
30
+ @branch = branch
31
+ @tag = tag
32
+ super()
33
+ end
34
+
35
+ ##
36
+ # Returns a new Git from the given hash.
37
+ # If the hash keys are camelCased, they are properly assigned to the
38
+ # corresponding snake_cased attributes.
39
+ #
40
+ # Cucumber::Messages::Git.from_h(some_hash) # => #<Cucumber::Messages::Git:0x... ...>
41
+ ##
42
+ def self.from_h(hash)
43
+ return nil if hash.nil?
44
+
45
+ new(
46
+ remote: hash[:remote],
47
+ revision: hash[:revision],
48
+ branch: hash[:branch],
49
+ tag: hash[:tag]
50
+ )
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Group message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ ##
10
+ class Group < Message
11
+ attr_reader :children
12
+
13
+ attr_reader :start
14
+
15
+ attr_reader :value
16
+
17
+ def initialize(
18
+ children: [],
19
+ start: nil,
20
+ value: nil
21
+ )
22
+ @children = children
23
+ @start = start
24
+ @value = value
25
+ super()
26
+ end
27
+
28
+ ##
29
+ # Returns a new Group from the given hash.
30
+ # If the hash keys are camelCased, they are properly assigned to the
31
+ # corresponding snake_cased attributes.
32
+ #
33
+ # Cucumber::Messages::Group.from_h(some_hash) # => #<Cucumber::Messages::Group:0x... ...>
34
+ ##
35
+ def self.from_h(hash)
36
+ return nil if hash.nil?
37
+
38
+ new(
39
+ children: hash[:children]&.map { |item| Group.from_h(item) },
40
+ start: hash[:start],
41
+ value: hash[:value]
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Messages
5
+ module Helpers
6
+ module IdGenerator
7
+ class Incrementing
8
+ def initialize
9
+ @index = -1
10
+ end
11
+
12
+ def new_id
13
+ @index += 1
14
+ @index.to_s
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Cucumber
6
+ module Messages
7
+ module Helpers
8
+ module IdGenerator
9
+ class UUID
10
+ def new_id
11
+ SecureRandom.uuid
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'id_generator/uuid'
4
+ require_relative 'id_generator/incrementing'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/messages'
4
+
5
+ module Cucumber
6
+ module Messages
7
+ module Helpers
8
+ class NdjsonToMessageEnumerator < Enumerator
9
+ def initialize(io)
10
+ super() do |yielder|
11
+ io.each_line do |line|
12
+ next if line.strip.empty?
13
+
14
+ message = extract_message(line)
15
+ yielder.yield(message)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def extract_message(json_line)
23
+ Envelope.from_json(json_line)
24
+ rescue StandardError
25
+ raise "Not JSON: #{json_line.strip}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cucumber
4
+ module Messages
5
+ module Helpers
6
+ module TimeConversion
7
+ NANOSECONDS_PER_SECOND = 1_000_000_000
8
+
9
+ def time_to_timestamp(time)
10
+ { 'seconds' => time.to_i, 'nanos' => time.nsec }
11
+ end
12
+
13
+ def timestamp_to_time(timestamp)
14
+ Time.at(timestamp['seconds'] + (timestamp['nanos'].to_f / NANOSECONDS_PER_SECOND))
15
+ end
16
+
17
+ def seconds_to_duration(seconds_float)
18
+ seconds, second_modulus = seconds_float.divmod(1)
19
+ nanos = second_modulus * NANOSECONDS_PER_SECOND
20
+ { 'seconds' => seconds, 'nanos' => nanos.to_i }
21
+ end
22
+
23
+ def duration_to_seconds(duration)
24
+ seconds_part = duration['seconds']
25
+ nanos_part = duration['nanos'].to_f / NANOSECONDS_PER_SECOND
26
+ seconds_part + nanos_part
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the Hook message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ ##
10
+ class Hook < Message
11
+ attr_reader :id
12
+
13
+ attr_reader :name
14
+
15
+ attr_reader :source_reference
16
+
17
+ attr_reader :tag_expression
18
+
19
+ attr_reader :type
20
+
21
+ def initialize(
22
+ id: '',
23
+ name: nil,
24
+ source_reference: SourceReference.new,
25
+ tag_expression: nil,
26
+ type: nil
27
+ )
28
+ @id = id
29
+ @name = name
30
+ @source_reference = source_reference
31
+ @tag_expression = tag_expression
32
+ @type = type
33
+ super()
34
+ end
35
+
36
+ ##
37
+ # Returns a new Hook from the given hash.
38
+ # If the hash keys are camelCased, they are properly assigned to the
39
+ # corresponding snake_cased attributes.
40
+ #
41
+ # Cucumber::Messages::Hook.from_h(some_hash) # => #<Cucumber::Messages::Hook:0x... ...>
42
+ ##
43
+ def self.from_h(hash)
44
+ return nil if hash.nil?
45
+
46
+ new(
47
+ id: hash[:id],
48
+ name: hash[:name],
49
+ source_reference: SourceReference.from_h(hash[:sourceReference]),
50
+ tag_expression: hash[:tagExpression],
51
+ type: hash[:type]
52
+ )
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ class HookType
7
+ BEFORE_TEST_RUN = 'BEFORE_TEST_RUN'
8
+ AFTER_TEST_RUN = 'AFTER_TEST_RUN'
9
+ BEFORE_TEST_CASE = 'BEFORE_TEST_CASE'
10
+ AFTER_TEST_CASE = 'AFTER_TEST_CASE'
11
+ BEFORE_TEST_STEP = 'BEFORE_TEST_STEP'
12
+ AFTER_TEST_STEP = 'AFTER_TEST_STEP'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The code was auto-generated by {this script}[https://github.com/cucumber/messages/blob/main/codegen/codegen.rb]
4
+ module Cucumber
5
+ module Messages
6
+ ##
7
+ # Represents the JavaMethod message in Cucumber's {message protocol}[https://github.com/cucumber/messages].
8
+ ##
9
+ ##
10
+ class JavaMethod < Message
11
+ attr_reader :class_name
12
+
13
+ attr_reader :method_name
14
+
15
+ attr_reader :method_parameter_types
16
+
17
+ def initialize(
18
+ class_name: '',
19
+ method_name: '',
20
+ method_parameter_types: []
21
+ )
22
+ @class_name = class_name
23
+ @method_name = method_name
24
+ @method_parameter_types = method_parameter_types
25
+ super()
26
+ end
27
+
28
+ ##
29
+ # Returns a new JavaMethod from the given hash.
30
+ # If the hash keys are camelCased, they are properly assigned to the
31
+ # corresponding snake_cased attributes.
32
+ #
33
+ # Cucumber::Messages::JavaMethod.from_h(some_hash) # => #<Cucumber::Messages::JavaMethod:0x... ...>
34
+ ##
35
+ def self.from_h(hash)
36
+ return nil if hash.nil?
37
+
38
+ new(
39
+ class_name: hash[:className],
40
+ method_name: hash[:methodName],
41
+ method_parameter_types: hash[:methodParameterTypes]
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end