Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index.html file showing full test coverage of spec files, missing some model files #349

Closed
zackshapiro opened this issue Nov 11, 2014 · 7 comments

Comments

@zackshapiro
Copy link

Top of spec_helper.rb:

require 'simplecov'
SimpleCov.start
require 'simplecov-json'
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter

---

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
# require 'requests/fakeweb_helper'

Dir[Rails.root.join("spec/support/**/*.rb")].sort.each {|f| require f}
...

This is strange... In the screenshot above which is a sample of coverage/index.html, it's showing me 100% test coverage on my spec files yet it's missing a number of models.

It shows I have 100% coverage on order_spec.rb yet no mention of order.rb in there. I'm not testing my test files, that wouldn't make much sense, so I'm very confused about this output and why it's happening.

It shows certain models but not others and has 100% test coverage on all of my _spec.rb files

Any suggestions on how to remedy?

@zackshapiro zackshapiro changed the title index.html file showing full test coverage of spec files, missing model files index.html file showing full test coverage of spec files, missing some model files Nov 11, 2014
@bf4
Copy link
Collaborator

bf4 commented Nov 14, 2014

I imagine you closed this because you looked at the various profiles you can use? Did you see #340 ?

@zackshapiro
Copy link
Author

It was related to the simplecov-json gem. I took it out which fixed the issue

@bf4
Copy link
Collaborator

bf4 commented Nov 14, 2014

Did you create an issue there? Link?

@zackshapiro
Copy link
Author

I didn't. I don't have time at the moment to figure out what was wrong a do a proper report.

@bf4
Copy link
Collaborator

bf4 commented Nov 14, 2014

Something about what you saw, what you tried, and what worked is a
good enough to stub an issue imho

@SergiiVdovareize
Copy link

SergiiVdovareize commented May 2, 2018

Got this issue. I don't use the simplecov-json gem.
This is all I have in spec/rails_helper.rb regarding simplecov:

# coverage
require 'simplecov'
SimpleCov.start

I run only model tests like this: rspec spec/models

image

@SergiiVdovareize
Copy link

SergiiVdovareize commented May 2, 2018

Found the issue in my case.

  1. pay special attention to this:

Note: If SimpleCov starts after your application code is already loaded (via require), it won't be able to track your files and their coverage! The SimpleCov.start must be issued before any of your application code is required!

  1. I use it in a rails app so I needed this line:
    SimpleCov.start 'rails'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants