Error with proven JavaScript tests (Bootstrap 3, Rails 4, Travis CI)

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

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

Full trace here

In development and production environments, successful requirements go to /assets/bootstrap/glyphicons-halflings-regular.woff . There is a difference in the part of /fonts/ - /assets and svg - woff . All errors generated in tests with JavaScript support (Poltergeist / PhantomJS driver). Conventional Capybara tests are all green. Chrome devtools says the request for the font file is generated by jquery.js, not the page file or css.

+5
source share
2 answers

This is due to the bootstrap-sass . I am using version 3.3.4.1 with Rails 4.2.

My presentation problem was very similar, but a little different: the same error in CI from 404 for /fonts/bootstrap/glyphicons-halflings-regular.woff , and the other way in dev, /fonts/glyphicons...

The solution that worked for me was to add the following line before enabling the JS bootstrap with SASS:

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

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

+1
source

If you have a similar setup for us, you installed Bootstrap manually on Rails and had to do some manual CSS style overrides to point the Glyphicon fonts in the right way. (/ assets / botostrap ... instead of / fonts / bootstrap ...). However, the original styles are still present in bootstrap.css, and although they are overridden, it seems that PhantomJS is still detecting and using these originals.

In our case, we had to look for all links to half glyphics-halflings in bootstrap.css and change the path to the correct one. After that, routing errors disappear.

Good luck

0
source

All Articles