Sha256: b98b9be7154e44f39d31123ea8ea041bc7efc0a1c1b9a6ce4792f9e56c9cb811

Contents?: true

Size: 1.74 KB

Versions: 11

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require File.expand_path("../test_helper", File.dirname(__FILE__))
require "rack"

class FullStackSendDeferredEagerTest < Minitest::Test
  REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
  TEST_RACK_APP = "../fake_app/basic_rack.rb"

  def setup
    super
    Coverband::Collectors::Coverage.instance.reset_instance
    Coverband.configure do |config|
      config.background_reporting_enabled = false
      config.track_gems = true
      config.defer_eager_loading_data = true
      config.send_deferred_eager_loading_data = false
    end
    Coverband.start
    Coverband::Collectors::Coverage.instance.eager_loading!
    @rack_file = require_unique_file "fake_app/basic_rack.rb"
    Coverband.report_coverage
    Coverband::Collectors::Coverage.instance.runtime!
  end

  test "call app" do
    # eager loaded class coverage starts empty
    Coverband.eager_loading_coverage!
    expected = {}
    assert_equal expected, Coverband.configuration.store.coverage

    Coverband::Collectors::Coverage.instance.runtime!
    request = Rack::MockRequest.env_for("/anything.json")
    middleware = Coverband::BackgroundMiddleware.new(fake_app_with_lines)
    results = middleware.call(request)
    assert_equal "Hello Rack!", results.last
    Coverband.report_coverage
    expected = [nil, nil, 0, nil, 0, 0, 1, nil, nil]
    assert_equal expected, Coverband.configuration.store.coverage[@rack_file]["data"]

    # eager loaded class coverage is skipped at first normal coverage report
    Coverband.eager_loading_coverage!
    expected = {}
    assert_equal expected, Coverband.configuration.store.coverage
  end

  private

  def fake_app_with_lines
    @fake_app_with_lines ||= ::HelloWorld.new
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
coverband-6.1.4 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.1.3 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.1.2 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.1.2.rc.1 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.1.1 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.1.0 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.0.3.rc.4 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.0.3.rc.3 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.0.3.rc.2 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.0.3.rc.1 test/integration/full_stack_send_deferred_eager_test.rb
coverband-6.0.2 test/integration/full_stack_send_deferred_eager_test.rb