Skip to content

Commit 25a92fd

Browse files
committed
Fix coverage support check for older Rubies
1 parent bd2df93 commit 25a92fd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/json/test_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
22

33
require 'coverage'
4+
5+
branches_supported = Coverage.respond_to?(:supported?) && Coverage.supported?(:branches)
6+
47
# Coverage module must be started before SimpleCov to work around the cyclic require order.
58
# Track both branches and lines, or else SimpleCov misleadingly reports 0/0 = 100% for non-branching files.
69
Coverage.start(lines: true,
7-
branches: Coverage.supported?(:branches))
10+
branches: branches_supported)
811

912
begin
1013
require 'simplecov'
@@ -14,7 +17,7 @@
1417
SimpleCov.start do
1518
# Enabling both coverage types to let SimpleCov know to output them together in reports
1619
enable_coverage :line
17-
enable_coverage :branch if Coverage.supported?(:branches)
20+
enable_coverage :branch if branches_supported
1821

1922
# Can't always trust SimpleCov to find files implicitly
2023
track_files 'lib/**/*.rb'

0 commit comments

Comments
 (0)