-
-
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
✅ Deploy Preview for cableready ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@marcoroth heyo, anything I can do to help on this? |
Hey @kaspth thanks for checking in! I couldn't apply the fix myself, but if @tcannonfodder could update the suggestion that would be great! Then I'm more than happy to merge this! Thanks! 🙌🏼 |
Will do this weekend! Sorry, things have been a mess here |
Thanks @tcannonfodder, looks like standard is failing on your changes, if you could run the fix command and push up the changes that would be super appreciated! 🙌🏼 |
* 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
e6c11f3
to
9a5ba14
Compare
I think I've got standardrb appeased (I am having issues with |
Nice! |
I just looked at the latest RequestEncoder setup in Rails and I wonder if we should do something more akin to https://github.com/rails/rails/blob/20f5828cacf164f0f53d669b37ba1e4b0f0f8907/actionpack/lib/action_dispatch/testing/request_encoder.rb#L58 here. Ref: rails/rails@0f4ab82 That way users can match on the operations JSON: patch account_url(@account), params: { name: "Yo" }, as: :cable_ready
assert_pattern { response.parsed_body => {name:} } # Not quite sure what the test would look like, I'm not the most experienced with CableReady. We could also do a custom response parser object, that would load the JSON, construct into objects that respond to We could start with: @encoders[:cable_ready] = CableReadyStreamEncoder.new \
response_parser: ->(body) { JSON.parse(body, object_class: ActiveSupport::HashWithIndifferentAccess) Also because of the way the request encoders are setup, ^ would only be called when the response acutally was a |
cc @seanpdoyle in case you have thoughts on extending the request encoder. |
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