Class: RSpec::SSE::Matchers::BeSuccessfullyOpened
- Inherits:
-
Object
- Object
- RSpec::SSE::Matchers::BeSuccessfullyOpened
- Defined in:
- lib/rspec/sse/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#matches?(actual) ⇒ Boolean
Match if the header and status code indicate a successful SSE connection.
Instance Method Details
#description ⇒ Object
329 330 331 |
# File 'lib/rspec/sse/matchers.rb', line 329 def description "be successfully opened" end |
#failure_message ⇒ Object
319 320 321 |
# File 'lib/rspec/sse/matchers.rb', line 319 def "Expected response header of `content-type` is `text/event-stream`, `cache-control` contains `no-store` or `no-cache`, and status code is `2xx`" end |
#failure_message_when_negated ⇒ Object
324 325 326 |
# File 'lib/rspec/sse/matchers.rb', line 324 def "Expected response header of `content-type` is not `text/event-stream`, `cache-control` does not contain `no-store` or `no-cache`, and/or status code is not `2xx`" end |
#matches?(actual) ⇒ Boolean
Match if the header and status code indicate a successful SSE connection
311 312 313 314 315 316 |
# File 'lib/rspec/sse/matchers.rb', line 311 def matches?(actual) @actual = actual @actual.headers["content-type"] == "text/event-stream" \ && @actual.headers["cache-control"]&.match(/no-(?:store|cache)/) \ && @actual.status == 200 end |