Skip to content

Commit

Permalink
ensure coverage is loaded before extending
Browse files Browse the repository at this point in the history
  • Loading branch information
danmayer committed Jun 24, 2020
1 parent 53e2abd commit 42f6beb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 0 additions & 5 deletions lib/coverband.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ def self.runtime_coverage!
end
unless ENV["COVERBAND_DISABLE_AUTO_START"]
begin
if RUBY_PLATFORM == "java"
unless Coverage.respond_to?(:line_stub)
require "coverband/utils/jruby_ext"
end
end
# Coverband should be setup as early as possible
# to capture usage of things loaded by initializers or other Rails engines
configure
Expand Down
5 changes: 5 additions & 0 deletions lib/coverband/collectors/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def initialize
raise NotImplementedError, "Coverage needs Ruby > 2.3.0" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.3.0")

require "coverage"
if RUBY_PLATFORM == "java"
unless ::Coverage.respond_to?(:line_stub)
require "coverband/utils/jruby_ext"
end
end
if defined?(SimpleCov) && defined?(Rails) && defined?(Rails.env) && Rails.env.test?
puts "Coverband: detected SimpleCov in test Env, allowing it to start Coverage"
puts "Coverband: to ensure no error logs or missing Coverage call `SimpleCov.start` prior to requiring Coverband"
Expand Down

0 comments on commit 42f6beb

Please sign in to comment.