2015-04-06 47 views
0

我很新的軌道,所以這對我來說有點神祕。Rails:黃瓜測試(與JS)失敗後,將資產添加到CSS

我已經將一些字體文件添加到app/assets/fonts,並使用asset-url助手將它們包含在SCSS文件中。但是我現在得到類似的錯誤:

No route matches assets/9df317a3-a79e-422e-b4e2-35ccd29cd5b7 (ActionController::RoutingError)

(注意失蹤的文件擴展名?)

在我黃瓜測試,但只@javascript標誌測試。我已經試過如下:

RAILS_ENV=test rake assets:precompile

,並在此線程的修復沒有工作:

Capybara tests with :js=>true... Routing Error: No route matches [GET] "/assets"

線程表明,有一個不正確的資產地方,但這種情況發生即使我從CSS中除去一個文件也是如此。加上應用程序報告沒有404s和字體在開發環境中工作。 這些是應用程序中唯一的資產!

我使用:

  • 軌道4
  • 黃瓜
  • 水豚
  • 鬼驅人(爲JS測試)

的CSS:

@font-face{ 
    font-family:"l baskerville w01_n4"; 
    src:asset-url("8dc59876-75a4-4e80-bd1a-735d5f043beb.eot?#iefix")format("eot") 
} 
etc... 

環境/ test.rb(該文件由fonts.com [因而可怕的文件名]提供):

Rails.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 

    # Do not eager load code on boot. This avoids loading your whole application 
    # just for the purpose of running a single test. If you are using a tool that 
    # preloads Rails for running tests, you may have to set it to true. 
    config.eager_load = false 

    # Configure static file server for tests with Cache-Control for performance. 
    config.serve_static_files = true 
    config.static_cache_control = 'public, max-age=3600' 

    # 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 

    # Randomize the order test cases are executed. 
    config.active_support.test_order = :random 

    # Print deprecation notices to the stderr. 
    config.active_support.deprecation = :stderr 

    # Raises error for missing translations 
    # config.action_view.raise_on_missing_translations = true 
end 

任何幫助,將不勝感激,我猜這是一個問題資產管道在測試和生產環境中。但我不知道從哪裏開始。

感謝,

LM

回答

0

原來答案是簡單的語法錯誤:

src: asset-url("8dc59876-75a4-4e80-bd1a-735d5f043beb.eot?#iefix")format("eot")

應該是:

src: font-url(url("8dc59876-75a4-4e80-bd1a-735d5f043beb.eot?#iefix")) format("eot")

希望THI對於像我這樣的其他新手來說很有用。