Webfont path, rspec, capybara and poltergeist
Asked Answered
S

1

6

I'm in the process of converting my Capybara test suite from capybara-webkit to poltergeist.

-require 'capybara/webkit'
+require 'capybara/poltergeist'

-Capybara.javascript_driver = :webkit
+Capybara.javascript_driver = :poltergeist

While running my test, the first test failed with this message...

Failure/Error: Unable to find matching line from backtrace
 ActionController::RoutingError:
   No route matches [GET] "/assets/fonts/glyphicons-halflings-regular.ttf"

After some investigation, I found similar issues here.

However, I have a manual installation of bootstrap.css. I made adjustments to the path as suggested in the second answer and I received the same message with the updated path.

After some time and frustration, I realized that it is only the first test in my suite that fails, the rest pass. So naturally, I deleted the first test. Now the "new" first test fails and the rest pass. So I deleted them all. Now, none of them fail! Testing is easy! The end.

What is making my first test fail? Why are the rest passing?

More info on request.

Scurvy answered 26/10, 2015 at 21:36 Comment(1)
Please post the spec that is failing.Malva
R
0

There are two possible solutions to this

A. You are loading images and you might not want to do that (speeds up tests etc.)

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app,
    :timeout => 60,
    :phantomjs_logger => File.open(File::NULL), # silence JavaScript console.log
    :phantomjs_options => %w(--load-images=false --ignore-ssl-errors=true),
  )
end

B. The spec is failing because you are getting a 404 not found for that asset

# Gemfile
gem 'bootstrap-sass'

Then include it in JavaScript land

# assets/javascripts/application.js
//= require bootstrap-sprockets

Then include it in CSS land

# assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
Roselba answered 17/7, 2016 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.