-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cable_ready.integration_test_request_encoding
initializer
#300
base: main
Are you sure you want to change the base?
Conversation
* This has been adapted from https://github.com/hotwired/turbo-rails/blob/9b17a3be3705786d72c3ae77fde5a9b3006555d7/lib/turbo/engine.rb#L119 * In order to streamline development, Rails integration tests should be able to support `as: :cable_ready` to test Cable Ready responses * This is done by setting up a new request encoding that ActionDispatch's integration tests can use. In this case, the encoder is barebones and is largely focused on streamlining how the request `Accept` headers are setup
✅ Deploy Preview for cableready ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
# Support `as: :cable_ready`. Public `register_encoder` API is a little too strict. | ||
class ActionDispatch::RequestEncoder | ||
class CableReadyStreamEncoder < IdentityEncoder | ||
header = [ Mime[:cable_ready], Mime[:html] ].join(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tcannonfodder, thanks for this pull request. Should this be :json
instead of :html
, since the MIME-Type is text/vnd.cable-ready.json
:
header = [ Mime[:cable_ready], Mime[:html] ].join(",") | |
header = [ Mime[:cable_ready], Mime[:json ].join(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcoroth yeah, that sounds right to me. There's a syntax error in your suggestion though, so it's this:
header = [ Mime[:cable_ready], Mime[:html] ].join(",") | |
header = [ Mime[:cable_ready], Mime[:json] ].join(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are totally @kaspth! Thanks!
Type of PR
Enhancement
Description
as: :cable_ready
to test Cable Ready responsesAccept
headers are setupWhy should this be added
This makes it easier for folks to write tests for their CableReady actions, making the gem fit into the larger ecosystem
Checklist