未在Rails测试环境中加载Javascript
在rails测试环境中,我无法在浏览器中加载Javascript。这对于通过水豚进行的黄瓜硒测试是有问题的。这是我的未在Rails测试环境中加载Javascript,javascript,ruby-on-rails,ruby-on-rails-3,selenium-webdriver,capybara,Javascript,Ruby On Rails,Ruby On Rails 3,Selenium Webdriver,Capybara,在rails测试环境中,我无法在浏览器中加载Javascript。这对于通过水豚进行的黄瓜硒测试是有问题的。这是我的test.rb(据我所知是默认值) 这将产生一个包含所有内容的concatative application.js。我已经尝试添加config.assets.debug=true,这样资产就不会被压缩,只是有时候才会加载javascript。如果我复制development.rb,它似乎可以工作,但这似乎并不理想 谢谢 结果是lessrails引导程序3.0.1gem版本由于相互依
test.rb
(据我所知是默认值)
这将产生一个包含所有内容的concatative application.js。我已经尝试添加config.assets.debug=true
,这样资产就不会被压缩,只是有时候才会加载javascript。如果我复制development.rb
,它似乎可以工作,但这似乎并不理想
谢谢 结果是
lessrails引导程序
3.0.1gem版本由于相互依赖性而以错误的顺序加载twitter/bootstrap。我们从未注意到这一点,因为Rails默认情况下不会在开发环境中压缩资产。所以这些特定的文件并没有被加载,但它们并没有像在测试中一样阻止我们加载所有的javascript
升级到
less rails bootstrap
3.0.3,或者在application.js中要求twitter/bootstrap的各个组件以正确的顺序运行,解决了这个问题。您是如何看到gem的加载顺序并实际调试这个问题的?现在经历一些类似的事情(一堆相互依赖的东西把事情搞砸了)对于了解您的最佳实践和调试是很有用的theses@Borat.sagdiyev我真的不记得了,对不起。我已经有几年没有在Rails工作了。
MyApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end