Skip to content

Commit 3c2c808

Browse files
committed
Better Rubymine compatibility for .simplecov
Rubymine's code coverage tools separate collection from reporting so that multiple runs can have their data merged. To separate, collecting from reporting, SimpleCov.start is only run when not using Rubymine (as indicated by a lack of the RM_INFO environment variable). This way, `rake spec` will collect coverage info and generate the report as before, but Rubymine will only collect coverage when using 'Run ... with coverage enabled' button and will only generate a report when using 'Generate Coverage Report' as is the intended behavior in Rubymine.
1 parent e2ed4f2 commit 3c2c808

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.simplecov

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# RM_INFO is set when using Rubymine. In Rubymine, starting SimpleCov is
2+
# controlled by running with coverage, so don't explicitly start coverage (and
3+
# therefore generate a report) when in Rubymine. This _will_ generate a report
4+
# whenever `rake spec` is run.
5+
unless ENV['RM_INFO']
6+
SimpleCov.start
7+
end
8+
19
SimpleCov.configure do
210
# ignore this file
311
add_filter '.simplecov'

spec/spec_helper.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
# must be first require and started before any other requires so that it can measure coverage of all following required
1212
# code. It is after the rubygems and bundler only because Bundler.setup supplies the LOAD_PATH to simplecov.
1313
require 'simplecov'
14-
# Ensure the coverage directory is always the same no matter where the individual spec is in the hierarchy when using
15-
# Rubymine to run one spec.
16-
#
17-
# @see https://github.com/colszowka/simplecov/issues/95
18-
SimpleCov.root(root_pathname)
19-
SimpleCov.start
2014

2115
require 'rspec/core'
2216

0 commit comments

Comments
 (0)