启用JavaScript的测试出错(Bootstrap 3,Rails 4,Travis CI) [英] Error with JavaScript enabled tests (Bootstrap 3, Rails 4, Travis CI)

查看:101
本文介绍了启用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 - 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中的相同错误与<$ c的404相同$ c> /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

这篇关于启用JavaScript的测试出错(Bootstrap 3,Rails 4,Travis CI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆