# frozen_string_literal: true

Coverband.eager_loading_coverage!
module Coverband
  class Railtie < Rails::Railtie
    initializer 'coverband.configure' do |app|
      app.middleware.use Coverband::Middleware
    end

    config.after_initialize do
      Coverband.report_coverage(true)
      Coverband.runtime_coverage!
    end

    rake_tasks do
      load 'coverband/utils/tasks.rb'
    end
  end
end

# frozen_string_literal: true

Coverband.eager_loading_coverage!
module Coverband
  class Railtie < Rails::Railtie
    initializer 'coverband.configure' do |app|
      app.middleware.use Coverband::Middleware
    end

    config.after_initialize do
      Coverband.report_coverage(true)
      Coverband.runtime_coverage!
    end

    config.before_initialize do
      Coverband.eager_loading_coverage!
    end

    rake_tasks do
      load 'coverband/utils/tasks.rb'
    end
  end
end

Call eager_loading in rails before_initialize
Call eager_loading in rails before_initialize

Since configure resets, we need to call configure afterward again in
before_initialize. I believe this problem would only occur within tests
when calling configure multiple times.
