Skip to content
mengfung.com
writing

Getting SimpleCov-summary (0.0.5) to work with SimpleCov (0.16.1) and Rails 5.2

 ·  1 min read

If you run into issues with installing simplecov-summary using:

# Put this in for RSpec, Minitest will plug in automatically
RSpec.configure do |config|
config.after(:suite) do
if SimpleCov.running
silence_stream(STDOUT) do
SimpleCov::Formatter::HTMLFormatter.new.format(SimpleCov.result)
end
SimpleCov::Formatter::SummaryFormatter.new.format(SimpleCov.result)
end
end
end

Here’s how to fix it:

# Put this in for RSpec, Minitest will plug in automatically
RSpec.configure do |config|
config.after(:suite) do
SimpleCov.at_exit do
SimpleCov::Formatter::SummaryFormatter.new.format(SimpleCov.result)
SimpleCov::Formatter::HTMLFormatter.new.format(SimpleCov.result) 
end
end
end

Since Rails 5 removed silence_stream because it is not thread-safe. I found implementations of silence_stream but I got it to work by just removing it completely and I prefer to see these outputs at the end of my test run.