simplecov

SimpleCov calculate 0% coverage for user model

拥有回忆 提交于 2019-12-22 02:04:09
问题 I decided to try using simplecov gem. And I think it's cool tool, but I have one problem: I have model User and I have user_spec.rb which contains test cases, but simplecov shows 0% coverage of this model. And It shows 100% coverage for other models, and It's true. I don't understand what's trouble with User model. class User < ActiveRecord::Base extend Enumerize # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database

rails 4 simpecov missing files

徘徊边缘 提交于 2019-12-10 10:51:28
问题 I am a huge fan of testing and when I run my current coverage reports I noticed that my lib sub folders with .rb files are not being picked up by simplecov. Here is my setup in my spec_helper.rb file: if ENV['COVERAGE'] require 'simplecov' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter ] SimpleCov.minimum_coverage 90 SimpleCov.start do coverage_dir 'tmp/coverage' add_filter '/.bundle/' add_filter '/spec/' add_filter '/config/' add_group 'Models

rspec test a private method within a private method that needs to be stubbed

為{幸葍}努か 提交于 2019-12-08 03:12:29
问题 Simplecov detected that I was missing some tests on my lib/api_verson.rb class: class ApiVersion def initialize(version) @version = version end def matches?(request) versioned_accept_header?(request) || version_one?(request) end private def versioned_accept_header?(request) accept = request.headers['Accept'] accept && accept[/application\/vnd\.#{Rails.application.secrets.my_app_accept_header}-v#{@version}\+json/] end def unversioned_accept_header?(request) accept = request.headers['Accept']

Simplecov report ignores folders in /app directory

拟墨画扇 提交于 2019-12-07 14:47:43
问题 I use simplecov to measure coverage for my Rails 4.0.11 app. I use Ruby 2.0.0. I noticed that some subfolders of /app are ignored by simplecov and I can't figure out why. test_helper.rb: require 'simplecov' SimpleCov.start 'rails' ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) I have tried upgrading to Ruby 2.1 after reading some posts that that might help, but still some subfolders are being ignored. I also tried to move the SimpleCov.start into a

Simplecov report ignores folders in /app directory

左心房为你撑大大i 提交于 2019-12-05 20:15:38
I use simplecov to measure coverage for my Rails 4.0.11 app. I use Ruby 2.0.0. I noticed that some subfolders of /app are ignored by simplecov and I can't figure out why. test_helper.rb: require 'simplecov' SimpleCov.start 'rails' ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) I have tried upgrading to Ruby 2.1 after reading some posts that that might help, but still some subfolders are being ignored. I also tried to move the SimpleCov.start into a .simplecov file at the root of my project, but the problem persists. I also tried to remove the rails

SimpleCov calculate 0% coverage for user model

偶尔善良 提交于 2019-12-04 23:56:35
I decided to try using simplecov gem. And I think it's cool tool, but I have one problem: I have model User and I have user_spec.rb which contains test cases, but simplecov shows 0% coverage of this model. And It shows 100% coverage for other models, and It's true. I don't understand what's trouble with User model. class User < ActiveRecord::Base extend Enumerize # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable STATUS_ACTIVE =

Simple cov gem missing untested files in Rails

一个人想着一个人 提交于 2019-11-27 13:07:29
Using simple_cov gem in a Rails app, can we have the files that we are not testing included in the report? If yes, how? If no, that files should count to the coverage percentage, right ? Try to edit your config/environments/test.rb and set this line: config.eager_load = false to true in this way the whole app is loaded and simplecov reads it. Eager load the whole Rails app when running tests suite with code coverage. Add Rails.application.eager_load! to spec_helper.rb . Simplecov slows down tests that's why I use shell environment variable to turn it on. Usually my spec_helper.rb / rails

Simple cov gem missing untested files in Rails

回眸只為那壹抹淺笑 提交于 2019-11-26 16:13:36
问题 Using simple_cov gem in a Rails app, can we have the files that we are not testing included in the report? If yes, how? If no, that files should count to the coverage percentage, right ? 回答1: Try to edit your config/environments/test.rb and set this line: config.eager_load = false to true in this way the whole app is loaded and simplecov reads it. 回答2: Eager load the whole Rails app when running tests suite with code coverage. Add Rails.application.eager_load! to spec_helper.rb . Simplecov