I want to make sure all external resources called for by my views (like
images) actually exist. How do I write an rspec that will fail when an
image included on the page isn’t present?
For example, let’s say in application.html.erb, I include , but that file doesn’t exist (say it’s
When this is run on the server, the image won’t appear, and the server
log will show an error like this:
ActionController::RoutingError (No route matches
However, views tests like response.should have_tag(img[src=/mylogo.png/)
won’t catch it, because the tag will be there. controllers tests
(with integrate_views on) for response.should be_success,
render_template won’t catch it because the page itself was a success and
rendered the template.
But an error was thrown during a second connection to the server,
because the image file didn’t exist … there must be a way for any such