Integration test failure after rake assets:precompile

Prior to pushing my app up to Heroku, I compiled the assets locally with:

RAILS_ENV=production bundle exec rake assets:precompile

After running rake I noticed that one of my Rspec integration tests (Capybara with :js => true) which had passed formerly was now failing. After discarding the contents of public/assets, the test passed again.

The failure had to do with the webdriver clicking a button on the page before an element fully loads. The page itself works with precompiled assets when the same steps are duplicated by hand.

Is there a way to force Rspec to load the uncompiled assets when tests run? Or should I be concerned that a test is failing with the precompiled assets, and take steps to resolve it?

If anyone else runs into the issue, I was able to prevent tests from using precompiled assets by setting serve_static_assets = false

config.serve_static_assets = false

in config/enviornments/test.rb

The caveat here, is that this won’t allow anything to be served from /public, which is a problem if you’re storing Paperclip uploads there, etc. There are a few workarounds in this SO thread:

Ideally your tests would pass even with pre-compiled assets. Be sure you are using asset-pipeline aware helpers everywhere you are including images, script, and stylesheets.