Sprocket directives not compiling under Capybara

Hi all,

I’m trying to run some end-to-end tests for my middleman app using Capybara and Poltergeist. I have the following lines in my spec_helper to spin up the app:

Capybara.javascript_driver = :poltergeist
Capybara.app = Middleman::Application.server.inst do
  set :root, File.expand_path(File.join(File.dirname(__FILE__), '..'))
  set :environment, :test
  set :show_exceptions, false
end

The app starts up, but my sprocket directives in the JS are not being compiled, e.g.:

//= require_tree .

Here’s my config.rb:

# Setup directory structure
set :css_dir, 'stylesheets'

set :js_dir, 'javascripts'

set :images_dir, 'images'

after_configuration do
  # Import Bower assests
  sprockets.append_path File.join "#{root}", 'bower_components'
  sprockets.import_asset 'angular-route/angular-route.js'
end

activate :blog do |blog|
  blog.layout = :article_layout
  blog.sources = "{year}-{month}-{day}-{title}.html"
  blog.prefix = "blog"
  blog.paginate = true
  summary_length = -1
end

activate :directory_indexes

configure :development do
  activate :livereload
  set :debug_assets, true
end

configure :build do

  activate :minify_html

  activate :minify_css

  activate :minify_javascript

  activate :gzip

  activate :asset_hash

  activate :relative_assets
end

Thanks for any ideas about how to get the directives to compile!

Setting debug_assets to true seems to fix this issue:

Capybara.javascript_driver = :poltergeist
Capybara.app = Middleman::Application.server.inst do
  set :debug_assets, true
  set :root, File.expand_path(File.join(File.dirname(__FILE__), '..'))
  set :environment, :test
  set :show_exceptions, false
end