Sha256: 8d2c26d9f9dea720ee7efb8bfa2b2a108ae74d9d3d15979418520025d5126aac

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require File.expand_path('../../test_helper', File.dirname(__FILE__))

class HTMLFormatterTest < Minitest::Test
  def setup
    super
    @redis = Redis.new
    @store = Coverband::Adapters::RedisStore.new(@redis, redis_namespace: 'coverband_test')
    @store.clear!
  end

  test 'generate dynamic content hosted html report' do
    Coverband.configure do |config|
      config.store             = @store
      config.ignore            = ['notsomething.rb']
    end
    mock_file_hash
    @store.send(:save_report, basic_coverage_full_path)

    notice = nil
    base_path = '/coverage'
    filtered_report_files = Coverband::Reporters::Base.report(@store, {})
    html = Coverband::Utils::HTMLFormatter.new(filtered_report_files,
                                               base_path: base_path,
                                               notice: notice).format_dynamic_html!
    assert_match 'loading source data', html
  end

  test 'generate static HTML report file' do
    Coverband.configure do |config|
      config.store             = @store
      config.ignore            = ['notsomething.rb']
    end
    mock_file_hash
    @store.send(:save_report, basic_coverage_full_path)

    filtered_report_files = Coverband::Reporters::Base.report(@store, {})
    Coverband::Utils::HTMLFormatter.new(filtered_report_files).format_static_html!
    html = File.read("#{Coverband.configuration.root}/coverage/index.html")
    assert_match 'Coverage first seen', html
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coverband-4.2.3 test/coverband/utils/html_formatter_test.rb
coverband-4.2.3.rc.2 test/coverband/utils/html_formatter_test.rb
coverband-4.2.3.rc.1 test/coverband/utils/html_formatter_test.rb
coverband-4.2.2 test/coverband/utils/html_formatter_test.rb
coverband-4.2.2.rc.1 test/coverband/utils/html_formatter_test.rb
coverband-4.2.1 test/coverband/utils/html_formatter_test.rb
coverband-4.2.1.rc4 test/coverband/utils/html_formatter_test.rb