Skip to content
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

Parameters not coerced when visiting a Lookbook preview in a Rails system test #640

Open
camertron opened this issue Sep 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@camertron
Copy link
Contributor

Describe the bug

Hey there 👋 It's me again! Just popping in to describe some unexpected behavior around param coercion. My pair and I noticed today that visiting a Lookbook preview in a system test does not result in properly coerced parameters. We're visiting like this:

visit "/page?my_param=foo"

In the preview code, the #preview_name method has an @param annotation for the my_param parameter that indicates it should be coerced to a symbol. Unfortunately, the coercion does not occur:

# @param [Symbol] select [foo, bar]
def preview_name(my_param: :foo)
  # my_param is a string here
  ...
end

To Reproduce

Steps to reproduce the behavior:

  1. Create a preview as described above.
  2. Render that preview in a Rails system test.
  3. Observe that parameters are not coerced.

Expected behavior

I expect the my_param parameter to be of type Symbol instead of String.

Version numbers

Please complete the following information:

  • Lookbook: 2.3.2
  • ViewComponent: 3.13.0
  • Rails: 7.1.3
  • Ruby: 3.3.3
@camertron camertron added the bug Something isn't working label Sep 12, 2024
@allmarkedup
Copy link
Collaborator

Hey @camertron 👋

Thanks for reporting this. To be honest I would have expected that this should 'just work' but I must admit I don't know a whole lot about how Rails system tests work under the hood...

I haven't had a lot of time to spend on Lookbook recently but as soon as I get a chance I'll dig into this, would be interesting to figure out what is going on here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants