rspec-sse-matchers 0.0.1

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.
@@ -0,0 +1,404 @@
1
+ # Generated from lib/rspec/sse/matchers.rb with RBS::Inline
2
+
3
+ module RSpec
4
+ module Matchers
5
+ # Matches if the response body ends with "\n\n" (SSE graceful close)
6
+ # @rbs return: RSpec::SSE::Matchers::BeGracefullyClosed
7
+ def be_gracefully_closed: () -> RSpec::SSE::Matchers::BeGracefullyClosed
8
+
9
+ # Matches if the response indicates successfully SSE connection opened
10
+ #
11
+ # @rbs return: RSpec::SSE::Matchers::BeSuccessfullyOpened
12
+ def be_successfully_opened: () -> RSpec::SSE::Matchers::BeSuccessfullyOpened
13
+
14
+ # Matches if the response's events match the expected events in order
15
+ #
16
+ # @rbs *events: ssePayload | Array[ssePayload]
17
+ # @rbs json: bool
18
+ # @rbs return: RSpec::SSE::Matchers::BeEvents
19
+ def be_events: (*ssePayload | Array[ssePayload] events, ?json: bool) -> RSpec::SSE::Matchers::BeEvents
20
+
21
+ # Matches if the response's event types match the expected types in order
22
+ #
23
+ # @rbs *types: String | Array[String]
24
+ # @rbs return: RSpec::SSE::Matchers::BeEventTypes
25
+ def be_event_types: (*String | Array[String] types) -> RSpec::SSE::Matchers::BeEventTypes
26
+
27
+ # Matches if the response's event data match the expected data in order
28
+ #
29
+ # @rbs *data: String | Array[String] | Array[Hash[String, untyped]]
30
+ # @rbs json: bool
31
+ # @rbs return: RSpec::SSE::Matchers::BeEventData
32
+ def be_event_data: (*String | Array[String] | Array[Hash[String, untyped]] data, ?json: bool) -> RSpec::SSE::Matchers::BeEventData
33
+
34
+ # Matches if the response's event IDs match the expected IDs in order
35
+ #
36
+ # @rbs *ids: String
37
+ # @rbs return: RSpec::SSE::Matchers::BeEventIds
38
+ def be_event_ids: (*String ids) -> RSpec::SSE::Matchers::BeEventIds
39
+
40
+ # Matches if the response's reconnection times match the expected times in order
41
+ #
42
+ # @rbs *times: Integer | Array[Integer]
43
+ # @rbs return: RSpec::SSE::Matchers::BeReconnectionTimes
44
+ def be_reconnection_times: (*Integer | Array[Integer] times) -> RSpec::SSE::Matchers::BeReconnectionTimes
45
+
46
+ # Matches if the response's events contain the expected events regardless of order
47
+ #
48
+ # @rbs *events: ssePayload | Array[ssePayload]
49
+ # @rbs json: bool
50
+ # @rbs return: RSpec::SSE::Matchers::ContainExactlyEvents
51
+ def contain_exactly_events: (*ssePayload | Array[ssePayload] events, ?json: bool) -> RSpec::SSE::Matchers::ContainExactlyEvents
52
+
53
+ # Matches if the response's event types contain the expected types regardless of order
54
+ #
55
+ # @rbs *types: String | Array[String]
56
+ # @rbs return: RSpec::SSE::Matchers::ContainExactlyEventTypes
57
+ def contain_exactly_event_types: (*String | Array[String] types) -> RSpec::SSE::Matchers::ContainExactlyEventTypes
58
+
59
+ # Matches if the response's event data contain the expected data regardless of order
60
+ #
61
+ # @rbs *data: String | Array[String] | Array[Hash[String, untyped]]
62
+ # @rbs json: bool
63
+ # @rbs return: RSpec::SSE::Matchers::ContainExactlyEventData
64
+ def contain_exactly_event_data: (*String | Array[String] | Array[Hash[String, untyped]] data, ?json: bool) -> RSpec::SSE::Matchers::ContainExactlyEventData
65
+
66
+ # Matches if the response's event IDs contain the expected IDs regardless of order
67
+ #
68
+ # @rbs *ids: String | Array[String]
69
+ # @rbs return: RSpec::SSE::Matchers::ContainExactlyEventIds
70
+ def contain_exactly_event_ids: (*String | Array[String] ids) -> RSpec::SSE::Matchers::ContainExactlyEventIds
71
+
72
+ # Matches if the response's reconnection times contain the expected times regardless of order
73
+ #
74
+ # @rbs *times: Integer | Array[Integer]
75
+ # @rbs return: RSpec::SSE::Matchers::ContainExactlyReconnectionTimes
76
+ def contain_exactly_reconnection_times: (*Integer | Array[Integer] times) -> RSpec::SSE::Matchers::ContainExactlyReconnectionTimes
77
+
78
+ # Matches if the response's events include all the expected events
79
+ #
80
+ # @rbs *events: ssePayload
81
+ # @rbs json: bool
82
+ # @rbs return: RSpec::SSE::Matchers::HaveEvents
83
+ def have_events: (*ssePayload events, ?json: bool) -> RSpec::SSE::Matchers::HaveEvents
84
+
85
+ # Matches if the response's event types include all the expected types
86
+ #
87
+ # @rbs *types: String | Array[String]
88
+ # @rbs return: RSpec::SSE::Matchers::HaveEventTypes
89
+ def have_event_types: (*String | Array[String] types) -> RSpec::SSE::Matchers::HaveEventTypes
90
+
91
+ # Matches if the response's event data include all the expected data
92
+ #
93
+ # @rbs *data: String | Array[String] | Array[Hash[String, untyped]]
94
+ # @rbs json: bool
95
+ # @rbs return: RSpec::SSE::Matchers::HaveEventData
96
+ def have_event_data: (*String | Array[String] | Array[Hash[String, untyped]] data, ?json: bool) -> RSpec::SSE::Matchers::HaveEventData
97
+
98
+ # Matches if the response's event IDs include all the expected IDs
99
+ #
100
+ # @rbs *ids: String
101
+ # @rbs return: RSpec::SSE::Matchers::HaveEventIds
102
+ def have_event_ids: (*String ids) -> RSpec::SSE::Matchers::HaveEventIds
103
+
104
+ # Matches if the response's reconnection times include all the expected times
105
+ #
106
+ # @rbs *times: Integer
107
+ # @rbs return: RSpec::SSE::Matchers::HaveReconnectionTimes
108
+ def have_reconnection_times: (*Integer times) -> RSpec::SSE::Matchers::HaveReconnectionTimes
109
+ end
110
+ end
111
+
112
+ module RSpec
113
+ module SSE
114
+ module Matchers
115
+ class SseParser
116
+ # @rbs body: String
117
+ # @rbs return: Array[ssePayload]
118
+ def self.parse: (String body) -> Array[ssePayload]
119
+ end
120
+
121
+ class BaseMatcher
122
+ @expected: Array[Object]
123
+
124
+ @actual: Object
125
+
126
+ @parsed_events: Array[ssePayload]
127
+
128
+ @json: bool
129
+
130
+ # Initialize the matcher with expected values
131
+ #
132
+ # @rbs expected: Array[Object]
133
+ # @rbs return: RSpec::SSE::Matchers::BaseMatcher
134
+ def initialize: (Array[Object] expected, ?json: untyped) -> RSpec::SSE::Matchers::BaseMatcher
135
+
136
+ # @rbs actual: Object
137
+ # @rbs return: bool
138
+ def matches?: (Object actual) -> bool
139
+
140
+ # @rbs return: String
141
+ def failure_message: () -> String
142
+
143
+ # @rbs return: String
144
+ def failure_message_when_negated: () -> String
145
+
146
+ private
147
+
148
+ # @rbs obj: Object
149
+ # @rbs return: String
150
+ def description_for: (Object obj) -> String
151
+
152
+ # @rbs return: Array[Object]
153
+ def extract_actual: () -> Array[Object]
154
+
155
+ # @rbs return: String
156
+ def description: () -> String
157
+
158
+ # @rbs return: bool
159
+ def match_condition: () -> bool
160
+ end
161
+
162
+ class BeGracefullyClosed
163
+ @actual: Object
164
+
165
+ # Match if the response body ends with "\n\n" (SSE graceful close)
166
+ #
167
+ # @rbs actual: Object
168
+ # @rbs return: bool
169
+ def matches?: (Object actual) -> bool
170
+
171
+ # @rbs return: String
172
+ def failure_message: () -> String
173
+
174
+ # @rbs return: String
175
+ def failure_message_when_negated: () -> String
176
+
177
+ # @rbs return: String
178
+ def description: () -> String
179
+ end
180
+
181
+ class BeSuccessfullyOpened
182
+ @actual: Object
183
+
184
+ # Match if the header and status code indicate a successful SSE connection
185
+ #
186
+ # @rbs actual: Object
187
+ # @rbs return: bool
188
+ def matches?: (Object actual) -> bool
189
+
190
+ # @rbs return: String
191
+ def failure_message: () -> String
192
+
193
+ # @rbs return: String
194
+ def failure_message_when_negated: () -> String
195
+
196
+ # @rbs return: String
197
+ def description: () -> String
198
+ end
199
+
200
+ class ExactMatcher < BaseMatcher
201
+ # Match if extracted actual values exactly match expected values
202
+ #
203
+ # @rbs return: bool
204
+ def match_condition: () -> bool
205
+
206
+ # @rbs return: String
207
+ def description: () -> String
208
+ end
209
+
210
+ # Base matcher for contain exactly matching (order doesn't matter)
211
+ class ContainExactlyMatcher < BaseMatcher
212
+ # Match if extracted actual values match expected values in any order
213
+ #
214
+ # @rbs return: bool
215
+ def match_condition: () -> bool
216
+
217
+ # @rbs return: String
218
+ def description: () -> String
219
+ end
220
+
221
+ # Base matcher for inclusion matching (subset)
222
+ class IncludeMatcher < BaseMatcher
223
+ # Match if extracted actual values include all expected values
224
+ #
225
+ # @rbs return: bool
226
+ def match_condition: () -> bool
227
+
228
+ # @rbs return: String
229
+ def description: () -> String
230
+ end
231
+
232
+ # Matcher for be_events
233
+ class BeEvents < ExactMatcher
234
+ end
235
+
236
+ # Matcher for contain_exactly_events
237
+ class ContainExactlyEvents < ContainExactlyMatcher
238
+ end
239
+
240
+ # Matcher for have_events
241
+ class HaveEvents < IncludeMatcher
242
+ end
243
+
244
+ module TypeExtractor
245
+ private
246
+
247
+ # Extract event types from parsed events
248
+ #
249
+ # @rbs return: Array[String|nil]
250
+ def extract_actual: () -> Array[String | nil]
251
+ end
252
+
253
+ # Matcher for be_event_types
254
+ class BeEventTypes < ExactMatcher
255
+ include TypeExtractor
256
+
257
+ private
258
+
259
+ # @rbs return: String
260
+ def description: () -> String
261
+ end
262
+
263
+ # Matcher for contain_exactly_event_types
264
+ class ContainExactlyEventTypes < ContainExactlyMatcher
265
+ include TypeExtractor
266
+
267
+ private
268
+
269
+ # @rbs return: String
270
+ def description: () -> String
271
+ end
272
+
273
+ # Matcher for have_event_types
274
+ class HaveEventTypes < IncludeMatcher
275
+ include TypeExtractor
276
+
277
+ private
278
+
279
+ # @rbs return: String
280
+ def description: () -> String
281
+ end
282
+
283
+ module DataExtractor
284
+ private
285
+
286
+ # Extract event data from parsed events
287
+ # If :json option is enabled, attempt to parse the data as JSON
288
+ #
289
+ # @rbs return: Array[String|Hash[String, untyped]]
290
+ def extract_actual: () -> Array[String | Hash[String, untyped]]
291
+ end
292
+
293
+ # Matcher for be_event_data
294
+ class BeEventData < ExactMatcher
295
+ include DataExtractor
296
+
297
+ private
298
+
299
+ # @rbs return: String
300
+ def description: () -> String
301
+ end
302
+
303
+ # Matcher for contain_exactly_event_data
304
+ class ContainExactlyEventData < ContainExactlyMatcher
305
+ include DataExtractor
306
+
307
+ private
308
+
309
+ # @rbs return: String
310
+ def description: () -> String
311
+ end
312
+
313
+ # Matcher for have_event_data
314
+ class HaveEventData < IncludeMatcher
315
+ include DataExtractor
316
+
317
+ private
318
+
319
+ # @rbs return: String
320
+ def description: () -> String
321
+ end
322
+
323
+ module IdExtractor
324
+ private
325
+
326
+ # Extract event IDs from parsed events
327
+ #
328
+ # @rbs return: Array[String|nil]
329
+ def extract_actual: () -> Array[String | nil]
330
+ end
331
+
332
+ # Matcher for be_event_ids
333
+ class BeEventIds < ExactMatcher
334
+ include IdExtractor
335
+
336
+ private
337
+
338
+ # @rbs return: String
339
+ def description: () -> String
340
+ end
341
+
342
+ # Matcher for contain_exactly_event_ids
343
+ class ContainExactlyEventIds < ContainExactlyMatcher
344
+ include IdExtractor
345
+
346
+ private
347
+
348
+ # @rbs return: String
349
+ def description: () -> String
350
+ end
351
+
352
+ # Matcher for have_event_ids
353
+ class HaveEventIds < IncludeMatcher
354
+ include IdExtractor
355
+
356
+ private
357
+
358
+ # @rbs return: String
359
+ def description: () -> String
360
+ end
361
+
362
+ module RetryExtractor
363
+ private
364
+
365
+ # Extract reconnection times from parsed events
366
+ #
367
+ # @rbs return: Array[Integer|nil]
368
+ def extract_actual: () -> Array[Integer | nil]
369
+ end
370
+
371
+ # Matcher for be_reconnection_times
372
+ class BeReconnectionTimes < ExactMatcher
373
+ include RetryExtractor
374
+
375
+ private
376
+
377
+ # @rbs return: String
378
+ def description: () -> String
379
+ end
380
+
381
+ # Matcher for contain_exactly_reconnection_times
382
+ class ContainExactlyReconnectionTimes < ContainExactlyMatcher
383
+ include RetryExtractor
384
+
385
+ private
386
+
387
+ # @rbs return: String
388
+ def description: () -> String
389
+ end
390
+
391
+ # Matcher for have_reconnection_times
392
+ class HaveReconnectionTimes < IncludeMatcher
393
+ include RetryExtractor
394
+
395
+ private
396
+
397
+ # @rbs return: String
398
+ def description: () -> String
399
+ end
400
+ end
401
+ end
402
+ end
403
+
404
+ type ssePayload = { type: String?, data: String, id: String?, retry: Integer }
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-sse-matchers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - moznion
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: event_stream_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ description: A collection of RSpec matchers for testing Server-Sent Events (SSE) responses
28
+ email:
29
+ - moznion@mail.moznion.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rspec"
35
+ - ".standard.yml"
36
+ - CHANGELOG.md
37
+ - CODE_OF_CONDUCT.md
38
+ - LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - examples/sse_spec.rb
42
+ - lib/rspec/sse/matchers.rb
43
+ - lib/rspec/sse/matchers/version.rb
44
+ - renovate.json
45
+ - sig/generated/rspec/sse/matchers.rbs
46
+ - sig/generated/rspec/sse/matchers/version.rbs
47
+ homepage: https://github.com/moznion/rspec-sse-matchers
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ homepage_uri: https://github.com/moznion/rspec-sse-matchers
52
+ source_code_uri: https://github.com/moznion/rspec-sse-matchers
53
+ changelog_uri: https://github.com/moznion/rspec-sse-matchers/blob/main/CHANGELOG.md
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.0.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.5.16
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: RSpec matchers for Server-Sent Events (SSE)
73
+ test_files: []