4

How can I add folder and subfolders of my libs to simplecov generate the coverage?

My SimpleCov Config

  SimpleCov.start do
    add_group 'Bot', 'app/bots'
    add_group 'Bot', 'lib/bot'
    add_group 'Controllers', 'app/controllers'
    add_group 'Models', 'app/models'
    add_group 'Helpers', 'app/helpers'
    add_group 'Libraries', 'lib'
  end

This is my lib tree

├── assets
├── bot
│   ├── base_bot_logic.rb
│   ├── bot_logic.rb
│   ├── core
│   │   ├── blacklist.rb
│   │   ├── bot_core.rb
│   │   ├── broadcast.rb
│   │   ├── emoji.rb
│   │   ├── profile.rb
│   │   ├── reply.rb
│   │   ├── setup.rb
│   │   ├── state_machine.rb
│   │   └── webview.rb
│   └── geoutils
│       └── geoutils.rb
├── estrutura.txt
├── solar
│   ├── api.rb
│   ├── assistido.rb
│   ├── atendimento.rb
│   └── validation
│       └── cpf.rb
├── solar.rb
└── tasks

7 directories, 18 files

But only two files are recognized by SimpleCov.

simplevoc lib coverage

How I can add missing folders?

EDIT:

I add track_files '{app,lib}/**/*.rb' in my SimpleCov.start and it recognize mys files, but don't calculate the coverage rate.

enter image description here

Luiz Carvalho
  • 1,549
  • 1
  • 23
  • 46

1 Answers1

1

Although I missed the party, I will answer

Getting started contains answer on your question:

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!

In this way, its correctly:

require 'simplecov'

require 'yourapp'

its NOT correctly:

require 'yourapp'

require 'simplecov'

track_files just includes files matched by this glob, whether or not they were explicitly required.

Community
  • 1
  • 1
Eugene Yak
  • 334
  • 4
  • 11