Sha256: 092489d85953281827cac835ad21be50e073499cf74f4b83be15b9483a0d555f

Contents?: true

Size: 1.7 KB

Versions: 49

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

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

class FullStackTest < 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
    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
    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"]

    # additional calls increase count by 1
    middleware.call(request)
    Coverband.report_coverage
    expected = [nil, nil, 0, nil, 0, 0, 2, nil, nil]
    assert_equal expected, Coverband.configuration.store.coverage[@rack_file]["data"]

    # class coverage
    Coverband.eager_loading_coverage!
    Coverband.configuration.store.coverage[@rack_file]["data"]
    expected = [nil, nil, 1, nil, 1, 1, 0, nil, nil]
    assert_equal expected, Coverband.configuration.store.coverage[@rack_file]["data"]
  end

  private

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

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
coverband-6.1.4 test/integration/full_stack_test.rb
coverband-6.1.3 test/integration/full_stack_test.rb
coverband-6.1.2 test/integration/full_stack_test.rb
coverband-6.1.2.rc.1 test/integration/full_stack_test.rb
coverband-6.1.1 test/integration/full_stack_test.rb
coverband-6.1.0 test/integration/full_stack_test.rb
coverband-6.0.3.rc.4 test/integration/full_stack_test.rb
coverband-6.0.3.rc.3 test/integration/full_stack_test.rb
coverband-6.0.3.rc.2 test/integration/full_stack_test.rb
coverband-6.0.3.rc.1 test/integration/full_stack_test.rb
coverband-6.0.2 test/integration/full_stack_test.rb
coverband-6.0.1 test/integration/full_stack_test.rb
coverband-6.0.1.rc.1 test/integration/full_stack_test.rb
coverband-6.0.0 test/integration/full_stack_test.rb
coverband-5.2.6.rc.6 test/integration/full_stack_test.rb
coverband-5.2.3.2 test/integration/full_stack_test.rb
coverband-5.2.6.rc.5 test/integration/full_stack_test.rb
coverband-5.2.3.1 test/integration/full_stack_test.rb
coverband-5.2.6.rc.4 test/integration/full_stack_test.rb
coverband-5.2.6.rc.3 test/integration/full_stack_test.rb