Search code examples
ruby-on-railsrspecphantomjscapybaragoogle-font-api

Rails feature specs: external Google font API is called, but I don't know where


When I run my Rails feature specs without internet connection, tests fail with the following reason:

  3) Creating user textarea fullscreen feature of "about" textarea shows the fullscreen toggler on hover
     Failure/Error: visit new_user_path

     Capybara::Poltergeist::StatusFailError:
       Request to 'http://127.0.0.1:65001/en/users/new' failed to reach server, check DNS and/or server status - Timed out with the following resources still waiting http://fonts.googleapis.com/css?family=Fredericka+the+Great
     # /Users/josh/.rvm/gems/ruby-2.2.6@a4aa2/gems/poltergeist-1.13.0/lib/capybara/poltergeist/browser.rb:376:in `command'
     # /Users/josh/.rvm/gems/ruby-2.2.6@a4aa2/gems/poltergeist-1.13.0/lib/capybara/poltergeist/browser.rb:35:in `visit'
     # /Users/josh/.rvm/gems/ruby-2.2.6@a4aa2/gems/poltergeist-1.13.0/lib/capybara/poltergeist/driver.rb:97:in `visit'
     # /Users/josh/.rvm/gems/ruby-2.2.6@a4aa2/gems/capybara-2.12.0/lib/capybara/session.rb:252:in `visit'
     # /Users/josh/.rvm/gems/ruby-2.2.6@a4aa2/gems/capybara-2.12.0/lib/capybara/dsl.rb:52:in `block (2 levels) in <module:DSL>'
     # ./spec/features/users/new_spec.rb:137:in `block (3 levels) in <top (required)>'

I suspect this being caused by a google font that I reference, but I have downloaded the font locally and load it like this in my SASS:

@font-face
  font-family: 'Fredericka the Great'
  font-style: normal
  font-weight: 400
  src: local('Fredericka the Great'), local('FrederickatheGreat'), asset-url('assets/fredericka_the_great.woff2') format('woff2')
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215

So I don't see any reference to http://fonts.googleapis.com in my code. Searching for this exact string over the whole project doesn't give any results, either.

How can I prevent this problem? I don't want PhantomJS to contact to any non-local resource anyways, as it slows down tests.


Solution

  • I found the problem: my application.css wasn't correctly recompiled when testing, so it required an old version.

    After doing a manual $ rake assets:precompile the google font api source wasn't called anymore.