title: How to test code coverage for Rails ERB templates?
body: <p>I'm just building a test suite for a legacy Rails app. The <code>simplecov</code> gem has been great for finding dark corners of the app which need test coverage (or which may be completely unused and OK to remove). I'm invoking <code>simplecov</code> simply by including the following at the top of <code>test/test_helper.rb</code>:</p>
  
  <pre><code>require 'simplecov'
  SimpleCov.start('rails')
  </code></pre>
  
  <p>The problem is that this doesn't check all the code which is embedded in the templates. There is all kinds of junk in there, and I'm sure a lot of it could just be removed, but it would be really nice if a code-coverage tool could point me to the unused bits.</p>
  
  <p>Some experimentation with Ruby 1.9's <code>Coverage</code> library leads me to believe that it could only do the job if the templates were somehow pre-compiled to Ruby code, saved in Ruby source files, and then <code>load</code>ed or <code>require</code>d, rather than loading the compiled templates directly with <code>eval</code>. OR, it might be possible to hack ERB to add logging statements to each line of each template during the compilation process.</p>
  
  <p>Does anyone have any other ideas how to measure code coverage of ERB templates? Do you know of an already-made tool which can do this? (Or will I have to be the one to build and release it?)</p>