-
Notifications
You must be signed in to change notification settings - Fork 755
React Rails Testing #353
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
Comments
sounds like I broke something, hmm |
Ah, is this only in test. I think my implementation depends on Rack middleware doing its thing, let me find a fix for this ... |
could you share the test that's breaking? The tests in this repo pass but I guess there's another kind of test that I missed! |
The most basic test that is failing is:
|
what kind of test is that? what test framework? is it inside a class which extends a base test class? is it part of a |
(seems like this middleware is not applied in the test context: https://github.com/reactjs/react-rails/blob/master/lib/react/rails/render_middleware.rb) |
We use:
|
@rmosolgo I can confirm this as well when upgrading to react-rails 1.3.0, this is using minitest 5.1 using a controller test extending from ActionController::TestCase |
Ahh awesome, thanks for that info, i can try to reproduce tomorrow! |
YES, that's super helpful, thank you!! |
@stevestmartin could you point your gemfile at this branch and give it a try? #356 for example, gem 'react-rails', github: 'rmosolgo/react-rails', branch: 'refactor-helper-lifecycle' |
@rmosolgo works great, thanks. also using middleware was only temporarily a bad choice. Rails 5 controller tests will work the same as integration tests executing the middleware. |
Thanks for reporting & testing, please try Good to know about middleware in the future, but I figure we'll be supporting Rails 4 for a few years still 😬 |
1.3.2 still broken for rspec |
I can confirm this is still failing on 1.3.2. I have a cache warming rake task that renders a view page which uses react_component in there. On version 1.2.0 it wasn't an issue but after upgrading I receive the same error: |
Sorry, I'm on the road this week so I haven't had a chance to properly address this issue. There's a PR to fix Rspec here: #367 Perhaps something there will be useful in the meantime! |
FWIW this also also breaks using react_component within the cells gem (in development) the 3.0 branch not current 4.0 branch. Perhaps this may help create a fix in isolation. It's not broken in 1.2.0. Still broken in 1.3.2 Also as a side note, perhaps its just me but if it were my gem and I knew it was broken (even if for a smaller subset) and is present in rubygems, I would advise yanking those versions. |
@nacengineer Thanks for the heads up about the "cells" gem, I'll have to take a look at that! I hear your point about putting imperfect code on Rubygems. But I don't want the perfect to be the enemy of the good! The broken use case here is to use a Rails view helper without a Rails controller. I think I can fix that case, but I'm just without a home base at the moment (moving from CA to VA 😬)! |
@rmosolgo congrats on getting back east of the Mississippi, live is better on this side. FWIW all I have to do to trigger it is render a cell and use the the react_component helper in its view. Nothing special. |
I've suggested a fix here: #375 This way, the view helper will work even if you're not in the context of a controller action. Could you give it a try and let me know if that works for you? Sorry I overlooked this when adding that feature!! |
@rmosolgo I just chimed in to mention it was still failing but when I described how I was using it I realized I could workaround it. But also probably not at all how you intended someone to use the helper so I didn't expect a fix for an odd case. Just wanted to say thanks so much for taking the time! Really appreciate it. |
Shipped in 1.3.3, please let me know if you find a case where it's still broken! |
@rmosolgo just gave it a try, its working for my use case. Thanks!! 👍🏻🎉 |
@rmosolgo Can confirm it fixes the issue in cells gem. Thanks! I'm always impressed with the responsiveness of react-rails gem's devs. Thanks I would still put a small plug in to yank previous 1.3.x gem as they're technically broken. Just from a technical support POV I don't think you want to rely on people coming across this thread if they run into the issue. IMO its not a better v. good issue. Its broken v. working. But its of course your call. Best of luck in VA! Thanks for the timely response. |
I just updated to 1.3.0, ran
rake test
and got this error message:ActionView::Template::Error: undefined method 'react_component' for nil:NilClass app/views/layouts/application.html.erb:30:in '_app_views_layouts_application_html_erb___3811361224884677630_70195218569900'
This only happens when I run my tests and doesn't happen when I run the code in the browser. When I stepped back to 1.2.0 it fixed the issue.
I'm calling
react_component
in my application.html.erb file.The text was updated successfully, but these errors were encountered: