deimos-ruby 2.4.0.pre.beta10 → 2.4.0.pre.beta11
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +12 -0
- data/lib/deimos/test_helpers.rb +20 -3
- data/lib/deimos/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7fce6eb5c1a318cb1db6bb88959dda28ec211ecd9e7866d84672f10586bb3037
|
|
4
|
+
data.tar.gz: d3dcca658acaae61aff1d21f9d54681355b7c5ef6486f0164f5df21bd4966bcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee764fed91bd6f9270e7f2fbc4d7a4969ffe4a982ea94f32f7d02b37464ded4e29179b96efeef1be165589fecd703ebc0051ba98139987e0a4847c19e3c896c3
|
|
7
|
+
data.tar.gz: 3b5d631165932f13f338c225420d943ae8c52463b2a74b6f035323b4298f14351f8e69e34c15b49267d50e2c5c0b98c54f18b3cc65b358601d02da066de3d88b
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
## UNRELEASED
|
|
9
9
|
|
|
10
10
|
- Major change: Switch from using `avro_turf` and `proto_turf` to use `schema_registry_client`, which handles both Avro and Protobuf.
|
|
11
|
+
- Added `have_sent_including` RSpec matcher to allow for Protobuf messages that use default values to be checked.
|
|
11
12
|
|
|
12
13
|
# 2.3.0 - 2026-01-13
|
|
13
14
|
|
data/README.md
CHANGED
|
@@ -1074,6 +1074,18 @@ end
|
|
|
1074
1074
|
# topic, without having to know which class produced it.
|
|
1075
1075
|
expect(topic_name).to have_sent(payload, key=nil, partition_key=nil, headers=nil)
|
|
1076
1076
|
|
|
1077
|
+
# You can use regular hash matching:
|
|
1078
|
+
expect(topic_name).to have_sent({'some_key' => 'some-value', 'message_id' => anything})
|
|
1079
|
+
|
|
1080
|
+
# For Protobufs, default values are stripped from the hash so you need to use actual Protobuf
|
|
1081
|
+
# objects:
|
|
1082
|
+
expect(topic.name).to have_sent(MyMessage.new(some_key: 'some-value', message_id: 'my-message-id'))
|
|
1083
|
+
|
|
1084
|
+
# However, Protobufs don't allow RSpec-style matching, so you can at least do a
|
|
1085
|
+
# simple `include`-style matcher:
|
|
1086
|
+
|
|
1087
|
+
expect(topic.name).to have_sent_including(MyMessage.new(some_key: 'some-value'))
|
|
1088
|
+
|
|
1077
1089
|
# Inspect sent messages
|
|
1078
1090
|
message = Deimos::TestHelpers.sent_messages[0]
|
|
1079
1091
|
expect(message).to eq({
|
data/lib/deimos/test_helpers.rb
CHANGED
|
@@ -115,7 +115,7 @@ module Deimos
|
|
|
115
115
|
str + "\nAll Messages received:\n#{message_string}"
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
RSpec::Matchers.define :have_sent do |msg, key=nil, partition_key=nil, headers=nil|
|
|
118
|
+
RSpec::Matchers.define :have_sent do |msg, key=nil, partition_key=nil, headers=nil, including: false|
|
|
119
119
|
message = Deimos::TestHelpers.normalize_message(msg)
|
|
120
120
|
match do |topic|
|
|
121
121
|
message_key = Deimos::TestHelpers.normalize_message(key)
|
|
@@ -127,8 +127,12 @@ module Deimos
|
|
|
127
127
|
if m.respond_to?(:[]) && m[:payload].respond_to?(:[]) && m[:payload][:payload_key].nil?
|
|
128
128
|
m[:payload].delete(:payload_key)
|
|
129
129
|
end
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
if including
|
|
131
|
+
next false unless RSpec::Matchers::BuiltIn::Include.new(message).matches?(m[:payload])
|
|
132
|
+
else
|
|
133
|
+
next false unless hash_matcher.send(:match, message, m[:payload])
|
|
134
|
+
end
|
|
135
|
+
topic == m[:topic] &&
|
|
132
136
|
(key.present? ? message_key == m[:key] : true) &&
|
|
133
137
|
(partition_key.present? ? partition_key == m[:partition_key] : true) &&
|
|
134
138
|
if headers.present?
|
|
@@ -149,6 +153,19 @@ module Deimos
|
|
|
149
153
|
end
|
|
150
154
|
end
|
|
151
155
|
|
|
156
|
+
RSpec::Matchers.define :have_sent_including do |msg, key=nil, partition_key=nil, headers=nil|
|
|
157
|
+
message = Deimos::TestHelpers.normalize_message(msg)
|
|
158
|
+
match do |topic|
|
|
159
|
+
expect(topic).to have_sent(msg, key, partition_key, headers, including: true)
|
|
160
|
+
end
|
|
161
|
+
failure_message do |topic|
|
|
162
|
+
_frk_failure_message(topic, message, key, partition_key)
|
|
163
|
+
end
|
|
164
|
+
failure_message_when_negated do |topic|
|
|
165
|
+
_frk_failure_message(topic, message, key, partition_key, true)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
152
169
|
# Clear all sent messages - e.g. if we want to check that
|
|
153
170
|
# particular messages were sent or not sent after a point in time.
|
|
154
171
|
# @return [void]
|
data/lib/deimos/version.rb
CHANGED