How to get coverage for views in Rails

Context

As said earlier in 2012, see the links below, I like to know if my Rails views are covered in my / cucs specs. I know that in 2012 the answer was that there was no solution. I was wondering if there is a solution in 2014? I searched the Internet and did not find much, so I am afraid that the answer will be the same.

Motivation

I want to know if my cucumber functions cover all parts of the API (in this case, the graphical interface). When I add GUI functionality (new view, button, etc.), but for some reason I forget to add corn to it, I want to be notified. So it’s not so much that I want to cover everything in my views, but I want me to unwittingly forget to add a cell for new custom functions. Consequently, the likelihood that the code does not work in production is reduced.

Study

I found the following links mentioned above:

  • How to check code coverage for ERB Rails templates?
  • How to get coverage for view specifications using rspec, rails and simplecov?

A potentially interesting approach I want to explore:

+7
ruby ruby-on-rails ruby-on-rails-3 rspec
source share
1 answer

I want me to accidentally forget to add cashews for new custom functions.

The pedantic answer is that you could definitely write these tests before adding functions (or at least complete them at the same time). But this is too dogmatic and not always realistic.

SimpleCov or another testing tool can help you indirectly track this, even if it cannot directly measure coverage in views (because they are not written in Ruby.)

If you cover every controller action, model and kind of helper method, then you are probably in good shape. (This works best if you avoid putting logic in views where possible.)

+2
source share

All Articles