SimpleCov showing 0% coverage in RubyMine but works fine elsewhere

434 Views Asked by At

I have a suspicion that this is a local system configuration issue, but I don't know exactly what I'm doing wrong. In my spec_helper.rb file, I have the following lines at the very beginning:

require 'simplecov'
SimpleCov.start 'rails'

I can run the following locally on the command line (which is exactly what RubyMine is running):

/home/scottj/.rvm/rubies/ruby-2.6.1/bin/ruby -x /home/scottj/Source/foamfactory/api/bin/bundle exec /home/scottj/.rvm/rubies/ruby-2.6.1/bin/ruby -r /home/scottj/.local/share/JetBrains/Toolbox/apps/RubyMine/ch-0/221.5787.34/plugins/ruby/rb/simplecov_starter.rb /home/scottj/Source/foamfactory/api/bin/rails spec

And it will generate a report in coverage/index.html that appears to be correct. However, when I run api: spec with coverage in RubyMine, all of my files in the app/ directory show up as "0% coverage". I suspect this has something to do with a simplecov_json_formatter that appears to be installed within my system gems folder, but I'm not sure.

Can anyone help with configuration so I can get back to a stable state where I can see code coverage in RubyMine?

1

There are 1 best solutions below

0
jwir3 On

I was sort of able to fix this by comparing with one of my other projects that had code coverage working successfully. What I did was remove the "spec: API" configuration that was a rake task configuration, add a new run/debug configuration of "RSpec" type and called it "Run All Specs", with the spec folder as the input folder.

Now, running with code coverage works as expected. It would be really interesting to understand why, though.