Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails:Cumber测试(使用JS)在向CSS添加资产后失败_Ruby On Rails_Cucumber_Capybara_Asset Pipeline_Poltergeist - Fatal编程技术网

Ruby on rails Rails:Cumber测试(使用JS)在向CSS添加资产后失败

Ruby on rails Rails:Cumber测试(使用JS)在向CSS添加资产后失败,ruby-on-rails,cucumber,capybara,asset-pipeline,poltergeist,Ruby On Rails,Cucumber,Capybara,Asset Pipeline,Poltergeist,我是rails的新手,所以这对我来说有点神秘 我已经将一些字体文件添加到app/assets/font中,并使用asseturlhelper将它们包含在一个SCSS文件中。但是,我现在得到的错误类似于: 没有路由匹配资产/9df317a3-a79e-422e-b4e2-35ccd29cd5b7(操作控制器::路由错误) (注意缺少的文件扩展名?) 在我的Cucumber测试中,但仅在带有@javascript标志的测试中。我尝试了以下方法: RAILS\u ENV=测试rake资产:预编译 此

我是rails的新手,所以这对我来说有点神秘

我已经将一些字体文件添加到
app/assets/font
中,并使用
asseturl
helper将它们包含在一个SCSS文件中。但是,我现在得到的错误类似于:

没有路由匹配资产/9df317a3-a79e-422e-b4e2-35ccd29cd5b7(操作控制器::路由错误)

(注意缺少的文件扩展名?)

在我的Cucumber测试中,但仅在带有
@javascript
标志的测试中。我尝试了以下方法:

RAILS\u ENV=测试rake资产:预编译

此线程中的修复程序不起作用:

该线程表明某个地方有一个不正确的资产,但即使我从CSS中删除除一个文件以外的所有文件,也会发生这种情况。另外,应用程序报告没有404,字体在dev env中工作这些是应用程序中唯一的资产

我正在使用:

  • 轨道4
  • 黄瓜
  • 水豚
  • 恶鬼(用于JS测试)
Css:

(这些文件是由fonts.com提供的[因此产生了可怕的文件名])

环境/test.rb:

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

发现答案是一个简单的语法错误:

src:asset url(“8dc59876-75a4-4e80-bd1a-735d5f043beb.eot?#iefix”)格式(“eot”)

应该是:

src:font-url(url(“8dc59876-75a4-4e80-bd1a-735d5f043beb.eot?#iefix”))格式(“eot”)

希望这对像我这样的新手有用

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