Simple Coverage Route not showing up
ruby-on-rails
Solution
If you're using SimpleCov or some similar gem to generate test results, those are static HTML files that are meant to be viewed locally on your machine. I.E. just browse to /Users/nicholasshook/Sites/<>/coverage/index.html and open that file in your browser.
Rails won't create routes to /coverage/index.html for security and manageability reasons. You can create a route to static html pages, but they must be in the /public directory. If you need your coverage results to be accessible in your app, you have a few options:
- Move your coverage file to the /public directory, and use a gem like High_Voltage https://github.com/thoughtbot/high_voltage to creat a route there
- You'll need to either reconfigure your coverage tool to put files in the /public directory, or manually copy them over
Problem
I have a rails app that when I run my tests I am creating new files in my /cov folder ``` Finished in 20.6 seconds 19 examples, 0 failures Coverage report generated for RSpec to /Users/nicholasshook/Sites/<<my project>>/coverage. 264 / 446 LOC (59.19%) covered. ``` Done. However, when I try going to localhost/coverage/index.html I get this error ``` No route matches [GET] "/coverage/index.html" ``` Thanks