I have a project in which I'm using rails 3.2.3, rspec 2.9.0, and simplecov 0.6.1, all seem to be the latest gems.
I'm getting code coverage results for my controllers and models, but not my views. I've tried adding the group in my simplecov setup:
SimpleCov.start 'rails' do
add_group 'Views', 'app/views'
end
And even explicitly saying I want .erb files included:
SimpleCov.start 'rails' do
add_group 'Views', 'app/views/*/*.erb'
end
...but no dice. The "Views" group is there in my coverage results, but no files are listed there.
Has anyone gotten this working?
To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.
Test coverage using SimpleCov SimpleCov is a code coverage analysis tool for Ruby. It uses Ruby's built-in Coverage library to gather code coverage data. Add simplecov to your Gemfile and run bundle install: 1gem 'simplecov', require: false, group: :test.
Apparently, the answer to this is "you can't", due to a limitation in the standard ruby coverage library:
https://github.com/colszowka/simplecov/issues/38
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With