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
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
- # With thanks to @myronmarston
3
- # https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
4
-
5
- module CaptureWarnings
6
- def report_warnings(&block)
7
- current_dir = Dir.pwd
8
- warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
9
- project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
10
-
11
- if errors.any?
12
- puts errors.join("\n")
13
- end
14
-
15
- if other_warnings.any?
16
- puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
17
- print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
18
- end
19
-
20
- # Until they fix https://bugs.ruby-lang.org/issues/10661
21
- if RUBY_VERSION == "2.2.0"
22
- project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
23
- end
24
-
25
- if project_warnings.any?
26
- puts "#{ project_warnings.count } warnings detected"
27
- print_warnings('cucumber-expressions', project_warnings)
28
- fail "Please remove all cucumber-expressions warnings."
29
- end
30
-
31
- ensure_system_exit_if_required
32
- end
33
-
34
- def capture_error(&block)
35
- old_stderr = STDERR.clone
36
- pipe_r, pipe_w = IO.pipe
37
- pipe_r.sync = true
38
- error = String.new
39
- reader = Thread.new do
40
- begin
41
- loop do
42
- error << pipe_r.readpartial(1024)
43
- end
44
- rescue EOFError
45
- end
46
- end
47
- STDERR.reopen(pipe_w)
48
- block.call
49
- ensure
50
- capture_system_exit
51
- STDERR.reopen(old_stderr)
52
- pipe_w.close
53
- reader.join
54
- return error.split("\n")
55
- end
56
-
57
- def print_warnings(type, warnings)
58
- puts
59
- puts "-" * 30 + " #{type} warnings: " + "-" * 30
60
- puts
61
- puts warnings.join("\n")
62
- puts
63
- puts "-" * 75
64
- puts
65
- end
66
-
67
- def ensure_system_exit_if_required
68
- raise @system_exit if @system_exit
69
- end
70
-
71
- def capture_system_exit
72
- @system_exit = $!
73
- end
74
- end
@@ -1,33 +0,0 @@
1
- require 'json'
2
- require 'cucumber/messages'
3
- require 'cucumber-compatibility-kit'
4
-
5
- module Cucumber
6
- module Messages
7
- describe 'messages acdeptance tests' do
8
- ndjson_files = Dir["#{Cucumber::CompatibilityKit::examples_path}/**/*.ndjson"]
9
-
10
- it 'must have ndjson_files as reference messages' do
11
- expect(ndjson_files).not_to be_empty
12
- end
13
-
14
- ndjson_files.each do |ndjson_file|
15
- it "deserialises and serialises messages in #{ndjson_file}" do
16
- File.open(ndjson_file, 'r:utf-8') do |io|
17
- io.each_line do |json|
18
- check(json)
19
- end
20
- end
21
- end
22
- end
23
-
24
- def check(json)
25
- hash = JSON.parse(json)
26
- envelope = Envelope.from_json(json)
27
- new_json = envelope.to_json
28
- new_hash = JSON.parse(new_json)
29
- expect(new_hash).to eq(hash)
30
- end
31
- end
32
- end
33
- end
@@ -1,29 +0,0 @@
1
- require 'rspec'
2
- require 'cucumber/messages'
3
-
4
- describe Cucumber::Messages::IdGenerator::Incrementing do
5
- subject { Cucumber::Messages::IdGenerator::Incrementing.new }
6
-
7
- context '#new_id' do
8
- it 'returns 0 the first time' do
9
- expect(subject.new_id).to eq("0")
10
- end
11
-
12
- it 'increments on every call' do
13
- expect(subject.new_id).to eq("0")
14
- expect(subject.new_id).to eq("1")
15
- expect(subject.new_id).to eq("2")
16
- end
17
- end
18
- end
19
-
20
- describe Cucumber::Messages::IdGenerator::UUID do
21
- subject { Cucumber::Messages::IdGenerator::UUID.new }
22
-
23
- context '#new_id' do
24
- it 'generates a UUID' do
25
- allowed_characters = "[0-9a-fA-F]"
26
- expect(subject.new_id).to match(/#{allowed_characters}{8}\-#{allowed_characters}{4}\-#{allowed_characters}{4}\-#{allowed_characters}{4}\-#{allowed_characters}{12}/)
27
- end
28
- end
29
- end
@@ -1,30 +0,0 @@
1
- require 'rspec'
2
- require 'cucumber/messages/message/dummy_messages'
3
-
4
- describe Cucumber::Messages::Message::Deserialization do
5
- describe '#from_json' do
6
- subject { Cucumber::Messages::Message.from_json(json_document) }
7
-
8
- let(:json_document) { '' }
9
-
10
- context 'with a valid JSON document' do
11
- let(:json_document) { '{"simpleMessage":{"isString":"answer"}}' }
12
-
13
- it 'deserialize the message using #from_h' do
14
- allow(Cucumber::Messages::Message).to receive(:from_h)
15
-
16
- subject
17
-
18
- expect(Cucumber::Messages::Message)
19
- .to have_received(:from_h)
20
- .with({ simpleMessage: { isString: "answer" } })
21
- end
22
- end
23
-
24
- context 'with an invalid JSON document' do
25
- let(:json_document) { '{foo: bar}' }
26
-
27
- it { expect { subject }.to raise_error(JSON::ParserError) }
28
- end
29
- end
30
- end
@@ -1,38 +0,0 @@
1
- require 'cucumber/messages/message'
2
-
3
- module Cucumber::Messages
4
- class SimpleMessage < Message
5
- attr_reader :is_nil, :is_string, :is_array, :is_number
6
-
7
- def initialize(is_nil: nil, is_string: '', is_array: [], is_number: 0)
8
- @is_nil = is_nil
9
- @is_string = is_string
10
- @is_array = is_array
11
- @is_number = is_number
12
- end
13
- end
14
-
15
- class EnumMessage
16
- ENUM = 'an enum'
17
- end
18
-
19
- class ComprehensiveMessage < Message
20
- attr_reader :simple_message, :message_array, :is_enum
21
-
22
- def initialize(
23
- simple_message: SimpleMessage.new,
24
- message_array: [SimpleMessage.new, SimpleMessage.new],
25
- is_enum: EnumMessage::ENUM
26
- )
27
- @simple_message = simple_message
28
- @message_array = message_array
29
- @is_enum = is_enum
30
- end
31
-
32
- private
33
-
34
- def self.message_array_from_h(hash)
35
- SimpleMessage.from_h(hash)
36
- end
37
- end
38
- end
@@ -1,89 +0,0 @@
1
- require 'rspec'
2
- require 'cucumber/messages/message/dummy_messages'
3
-
4
- describe Cucumber::Messages::Message::Serialization do
5
- context 'with a simple message' do
6
- describe '#to_h' do
7
- subject { Cucumber::Messages::SimpleMessage.new.to_h }
8
-
9
- it 'returns a Hash with all the attributes of the Message' do
10
- expect(subject).to eq({ is_nil: nil, is_string: '', is_array: [], is_number: 0 })
11
- end
12
-
13
- context 'whith camelize: true' do
14
- subject { Cucumber::Messages::SimpleMessage.new.to_h(camelize: true) }
15
-
16
- it 'camelize the keys of the resulting hash' do
17
- expect(subject).to eq({ isNil: nil, isString: '', isArray: [], isNumber: 0 })
18
- end
19
- end
20
-
21
- context 'with reject_nil_values: true' do
22
- subject { Cucumber::Messages::SimpleMessage.new.to_h(reject_nil_values: true) }
23
-
24
- it 'rejects nil values from the resulting hash' do
25
- expect(subject).to eq({ is_string: '', is_array: [], is_number: 0 })
26
- end
27
- end
28
- end
29
-
30
- describe '#to_json' do
31
- subject { Cucumber::Messages::SimpleMessage.new.to_json }
32
-
33
- it 'returns a JSON document with all the attributes of the Message except nil values' do
34
- expect(subject).to eq({ isString: '', isArray: [], isNumber: 0 }.to_json)
35
- end
36
- end
37
- end
38
-
39
- context 'with a message which embeds other messages' do
40
- describe '#to_h' do
41
- subject { Cucumber::Messages::ComprehensiveMessage.new.to_h }
42
-
43
- it 'includes hash representation of embedded messages' do
44
- expect(subject[:simple_message]).to eq({ is_nil: nil, is_string: '', is_array: [], is_number: 0 })
45
- expect(subject[:is_enum]).to eq 'an enum'
46
- end
47
-
48
- it 'includes hash representation of messages arrays' do
49
- expect(subject[:message_array]).to eq([
50
- { is_nil: nil, is_string: '', is_array: [], is_number: 0 },
51
- { is_nil: nil, is_string: '', is_array: [], is_number: 0 }
52
- ])
53
- end
54
-
55
- context 'whith camelize: true' do
56
- subject { Cucumber::Messages::ComprehensiveMessage.new.to_h(camelize: true) }
57
-
58
- it 'camelize the keys of the embedded messages resulting hashes' do
59
- expect(subject[:simpleMessage]).to eq({ isNil: nil, isString: '', isArray: [], isNumber: 0 })
60
- end
61
-
62
- it 'camelize the keys of hashes for messages arrays' do
63
- expect(subject[:messageArray]).to eq([
64
- { isNil: nil, isString: '', isArray: [], isNumber: 0 },
65
- { isNil: nil, isString: '', isArray: [], isNumber: 0 }
66
- ])
67
- end
68
- end
69
- end
70
-
71
- describe '#to_json' do
72
- subject { Cucumber::Messages::ComprehensiveMessage.new.to_json }
73
-
74
- it 'returns a JSON document with embedded messages' do
75
- expect(subject).to include({ isString: '', isArray: [], isNumber: 0}.to_json)
76
- expect(subject).to include('"isEnum":"an enum"')
77
- end
78
-
79
- it 'returns a JSON document with messages arrays' do
80
- expect(subject).to include(
81
- [
82
- { isString: '', isArray: [], isNumber: 0},
83
- { isString: '', isArray: [], isNumber: 0}
84
- ].to_json
85
- )
86
- end
87
- end
88
- end
89
- end
@@ -1,30 +0,0 @@
1
- require 'rspec'
2
- require 'cucumber/messages/message/utils'
3
-
4
- class DummyTestClass
5
- include Cucumber::Messages::Message::Utils
6
- end
7
-
8
- describe Cucumber::Messages::Message::Utils do
9
- subject { DummyTestClass }
10
-
11
- describe '#underscore' do
12
- it { expect(subject.underscore('test')).to eq 'test' }
13
- it { expect(subject.underscore('testTest')).to eq 'test_test' }
14
- it { expect(subject.underscore('')).to eq '' }
15
- it { expect(subject.underscore('T')).to eq 't' }
16
- it { expect(subject.underscore('test123test456Test')).to eq 'test123test456_test' }
17
- it { expect(subject.underscore('test-test')).to eq 'test_test' }
18
- it { expect(subject.underscore('TEST_Test')).to eq 'test_test' }
19
- it { expect(subject.underscore('test-Test')).to eq 'test_test' }
20
- end
21
-
22
- describe '#camelize' do
23
- it { expect(subject.camelize('test')).to eq 'test' }
24
- it { expect(subject.camelize('test_test')).to eq 'testTest' }
25
- it { expect(subject.camelize('Test_TeSt')).to eq 'TestTest' }
26
- it { expect(subject.camelize('')).to eq '' }
27
- it { expect(subject.camelize('test123test4_5_6_test')).to eq 'test123test456Test' }
28
- it { expect(subject.camelize('test-test')).to eq 'test-test' }
29
- end
30
- end
@@ -1,56 +0,0 @@
1
- require 'cucumber/messages'
2
-
3
- module Cucumber
4
- module Messages
5
- describe 'messages' do
6
- let(:outgoing_messages) do
7
- [
8
- Envelope.new(
9
- source: Source.new(data: 'Feature: Hello')
10
- ),
11
- Envelope.new(
12
- attachment: Attachment.new(body: 'Hello', content_encoding: AttachmentContentEncoding::IDENTITY)
13
- )
14
- ]
15
- end
16
-
17
- it "can be serialised over an ndjson stream" do
18
- io = StringIO.new
19
- write_outgoing_messages(outgoing_messages, io)
20
-
21
- io.rewind
22
- incoming_messages = NdjsonToMessageEnumerator.new(io)
23
-
24
- expect(incoming_messages.to_a.map(&:to_h)).to(eq(outgoing_messages.map(&:to_h)))
25
- end
26
-
27
- it "ignores empty lines" do
28
- io = StringIO.new
29
- write_outgoing_messages(outgoing_messages, io)
30
- io.write("\n\n")
31
-
32
- io.rewind
33
- incoming_messages = NdjsonToMessageEnumerator.new(io)
34
-
35
- expect(incoming_messages.to_a.map(&:to_h)).to(eq(outgoing_messages.map(&:to_h)))
36
- end
37
-
38
- it "includes offending line in error message" do
39
- io = StringIO.new
40
- io.puts('BLA BLA')
41
-
42
- io.rewind
43
- incoming_messages = NdjsonToMessageEnumerator.new(io)
44
-
45
- expect { incoming_messages.to_a }.to(raise_error('Not JSON: BLA BLA'))
46
- end
47
-
48
- def write_outgoing_messages(messages, out)
49
- messages.each do |message|
50
- out.write(message.to_json)
51
- out.write("\n")
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,41 +0,0 @@
1
- require 'cucumber/messages'
2
-
3
- module Cucumber
4
- module Messages
5
- describe TimeConversion do
6
- include TimeConversion
7
-
8
- it 'converts to and from milliseconds since epoch' do
9
- time = Time.now
10
- timestamp = time_to_timestamp(time)
11
- time_again = timestamp_to_time(timestamp)
12
-
13
- expect(time).to be_within(0.000001).of(time_again)
14
- end
15
-
16
- it 'converts to and from seconds duration' do
17
- duration_in_seconds = 1234
18
- duration = seconds_to_duration(duration_in_seconds)
19
- duration_in_seconds_again = duration_to_seconds(duration)
20
-
21
- expect(duration_in_seconds_again).to eq(duration_in_seconds)
22
- end
23
-
24
- it 'converts to and from seconds duration (with decimal places)' do
25
- duration_in_seconds = 3.000161
26
- duration = seconds_to_duration(duration_in_seconds)
27
- duration_in_seconds_again = duration_to_seconds(duration)
28
-
29
- expect(duration_in_seconds_again).to be_within(0.000000001).of(duration_in_seconds)
30
- end
31
-
32
- it 'converts to a hash where seconds and nanos are integers' do
33
- duration_in_seconds = 3.000161
34
- duration = seconds_to_duration(duration_in_seconds)
35
-
36
- expect(duration['seconds']).to be_integer
37
- expect(duration['nanos']).to be_integer
38
- end
39
- end
40
- end
41
- end
@@ -1,11 +0,0 @@
1
- require 'cucumber/messages'
2
-
3
- module Cucumber
4
- module Messages
5
- describe VERSION do
6
- it 'should be defined' do
7
- expect(subject).to match(/\d+\.\d+\.\d+/)
8
- end
9
- end
10
- end
11
- end