I’ve been wondering recently “If I cache a file in public/ how do my integration tests access the file?”
By default, Rails’ integration stack only calls into the routes/controllers. So the following fails, ironically with a 404 error:
$ script/console >> app.get '404.html' => 404
It should return
200. If I cache a file into public/ I want to be able to pull it back out during the normal course of integration testing.
In integration testing, this problem manifested when I clicked a link to a cached asset, or an action redirected to a cached asset.
What worked for me was to put the following at the bottom of my config/environments/cucumber.rb file (or your …/test.rb file if you do integration testing in that environment):
Now, I can successfully load assets via the
get helper, or indirectly via webrat clicking links, etc:
$ script/console cucumber >> app.get '404.html' => 200
- Using CoffeeScript in Rails and even on Heroku I’m pretty excited about CoffeeScript as a clean-syntax replacement for...