-
Notifications
You must be signed in to change notification settings - Fork 247
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
raise_runtime_errors is not working with recent sprockets #299
Comments
Yes, we are aware of it. It was one of the main changes in sprockets-rails 3.
No. That option was made optional before because we introduced in a minor version. Now that we released a major version I don't see any reason to disable that check that was made to avoid surprising errors.
If you are talking about teaspoon they have how to handle that without you needing to disable that check. Just to be clear I use this same approach in Shopify test suite without to having to disable this check. If you are not using teaspoon, you can also handle that without needing to disable the check. If you know the files that need to be included you can also use this information to tell the checker to not raise the error for those files. |
From @rosenfeld on December 28, 2015 23:46 I'm using my own framework and runner. How can I allow it to include the debug dependencies without getting into this error? |
I had not check that yet but you can use |
Hi @rafaelfranca, I'm not sure teaspoon is using your suggestion as I can't find any references to
This should resolve the issue with all those test runners integrated with the Rails Assets Pipeline. After all, I want to take advantage of the feature that will raise everytime we forget to add an asset to the precompiled list for the application and only skip it for my tests. I often run my JS tests from the development environment, so I'd prefer to avoid setting a different checker based on the environment. Would you consider a solution which provided some special option to stylesheet_link_tag and javascript_include_tag? |
Also, how do I know when the |
I could get it to initialize like this: Rails.application.config.after_initialize do
ActiveSupport.on_load(:action_view) do
default_checker = ActionView::Base.precompiled_asset_checker
ActionView::Base.precompiled_asset_checker = -> logical_path do
default_checker[logical_path] || @tests
end
end
end But @tests is always nil even when it is defined in the controller and I couldn't find any way to get the request context. Any ideas, @rafaelfranca? |
The only solution I could come up with is by using Thread.current[:skip_precompiled_check] in an |
This is how I fixed rails-sandbox-assets for the time being: |
@rosenfeld please check out how this issue has been resolved in konacha: alexkravets/konacha@f049dcf |
Thanks, @alexkravets. I'm in the process of moving our resources build system from sprockets to webpack due to several reasons, like support for source-maps, ES6 (Babel), code splitting, ability to join some CSS rules inside a JS chunk to reduce the amount of lazy requests, ability to easily use and manage npm and bower packages and other reasons. So, it's likely I'll end up moving oojspec to some npm package and integrate it to karma and webpack for running my tests... But thanks anyway for sharing your solution! |
Is jfirebaugh/konacha#216 related to this issue? That issue just got closed recently. |
NoMethodError - undefined method `first' for #Sprockets::Asset:0x0000000c0cbd70: |
From @rosenfeld on December 28, 2015 18:39
From the official guides:
http://guides.rubyonrails.org/asset_pipeline.html
"3.1 Runtime Error Checking
By default the asset pipeline will check for potential errors in development mode during runtime. To disable this behavior you can set:
config.assets.raise_runtime_errors = false
When this option is true, the asset pipeline will check if all the assets loaded in your application are included in the config.assets.precompile list."
This indeed used to work with previous versions of sprockets but when I tried to upgrade it stopped working. You can easily reproduce it by running "rails new demo" using latest Rails (4.2.5). sprockets 3.5.2 is installed currently and sprockets-rails 3.0.0 will always generate an "Asset was not declared to be precompiled in production" error.
It assumes it's always an error to not add the asset to precompile but for my use case I need a way to circumvent this error. I use an approach to test my client-side code that will require only the dependencies for a given test, so that I can be sure all dependencies are fully specified for my JS modules. The testing framework will then include individual assets that shouldn't be precompiled because those individual compiled files won't be sent to production and are only using in the test and development environments.
Could you please get raise_runtime_errors back to work with recent versions of sprocket/sprocket-rails?
Copied from original issue: rails/rails#22813
The text was updated successfully, but these errors were encountered: