启用JavaScript的测试出错(Bootstrap 3,Rails 4,Travis CI)

启用JavaScript的测试出错(Bootstrap 3,Rails 4,Travis CI)

问题描述:

我有奇怪的错误,只出现在CI环境中。此错误不会出现在开发,生产甚至本地测试环境中。

I have strange error that appears only in CI environment. This error does not appear in develpment, production or even local test environments.

ActionController::RoutingError: No route matches [GET] "/fonts/bootstrap/glyphicons-halflings-regular.svg"

可以找到完整的跟踪这里

在开发和生产环境成功需要转到 /assets/bootstrap/glyphicons-halflings-regular.woff / fonts / - / assets svg $ c $有区别c> - woff 部分。启用JavaScript的所有错误都启用了测试(Poltergeist / PhantomJS驱动程序)。定期的Capybara测试都是绿色的。 Chrome devtools表示,字体文件的请求是由jquery.js生成的,而不是页面或css文件。

In development and production enviroments successfull reqest goes to /assets/bootstrap/glyphicons-halflings-regular.woff. There is a difference in /fonts/ - /assets and svg - woff part. All errors generated by JavaScript enabled tests (Poltergeist / PhantomJS driver). Regular Capybara tests are all green. Chrome devtools says that request for font file is generated by jquery.js, not the page or css file.

这是相关的到 bootstrap-sass gem。我正在使用它的版本3.3.4.1和Rails 4.2。

This is related to the bootstrap-sass gem. I'm using version 3.3.4.1 of it with Rails 4.2.

我提出的问题非常相似但略有不同:CI中的相同错误与 /fonts/bootstrap/glyphicons-halflings-regular.woff 但是dev中的路径不同, / fonts / glyphicons ...

My presenting issue was very similar but slightly different: the same error in CI with 404 for /fonts/bootstrap/glyphicons-halflings-regular.woff but a different path in dev, /fonts/glyphicons....

对我有用的解决方案是在包含带SASS的bootstrap JS之前添加以下行:

The solution that worked for me was adding the following line before including the bootstrap JS with SASS:

$icon-font-path: "bootstrap/";
@import 'bootstrap';

我最好的线索来自于gem的追踪者对此问题的评论:
https://github.com/twbs/bootstrap-sass/issues/480#issuecomment -49237119

My best clue came from the comments on this issue in the gem's tracker: https://github.com/twbs/bootstrap-sass/issues/480#issuecomment-49237119