user2320239
user2320239

Reputation: 1038

SimpleCov not showing rails files

I'm trying to use simplecov to monitor my test coverage however after having to roll back some changes to my project and reinstall simplecov it seems to have broken.

It no longer tracks the models and controller ect, but instead covers the spec files, as can be seen here:

enter image description here

How can I get it back to how it should be where it's tracking the actual rails files in separate tabs?

Any help would be great!

Upvotes: 2

Views: 1684

Answers (2)

Son Tr.
Son Tr.

Reputation: 846

Add these lines at the very top of your spec_helper.rb

require "simplecov"
SimpleCov.start "rails"

# Previous content of test helper now starts here

Upvotes: 4

Ginty
Ginty

Reputation: 3501

I guess you have an initializer or something where you are configuring SimpleCov, you need to define the groups there like this:

SimpleCov.start do
  add_group "Models", "app/models"
  add_group "Controllers", "app/controllers"
  add_group "Long files" do |src_file|
    src_file.lines.count > 100
  end
  add_group "Multiple Files", ["app/models", "app/controllers"] # You can also pass in an array
  add_group "Short files", LineFilter.new(5) # Using the LineFilter class defined in Filters section above
end

Upvotes: 0

Related Questions