coverband 4.2.5.rc.2 → 5.0.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +25 -0
- data/.travis.yml +2 -1
- data/Gemfile +5 -7
- data/Gemfile.rails4 +0 -3
- data/Gemfile.rails6 +0 -3
- data/README.md +24 -77
- data/Rakefile +17 -17
- data/changes.md +26 -30
- data/config.ru +1 -1
- data/coverband.gemspec +29 -34
- data/lib/alternative_coverband_patch.rb +5 -0
- data/lib/coverband.rb +55 -43
- data/lib/coverband/adapters/base.rb +17 -17
- data/lib/coverband/adapters/file_store.rb +2 -2
- data/lib/coverband/adapters/hash_redis_store.rb +24 -21
- data/lib/coverband/adapters/redis_store.rb +12 -12
- data/lib/coverband/at_exit.rb +1 -1
- data/lib/coverband/collectors/coverage.rb +15 -27
- data/lib/coverband/collectors/delta.rb +19 -9
- data/lib/coverband/collectors/view_tracker.rb +19 -11
- data/lib/coverband/configuration.rb +48 -84
- data/lib/coverband/integrations/background.rb +3 -3
- data/lib/coverband/integrations/rack_server_check.rb +3 -3
- data/lib/coverband/integrations/resque.rb +13 -1
- data/lib/coverband/reporters/base.rb +10 -10
- data/lib/coverband/reporters/console_report.rb +1 -1
- data/lib/coverband/reporters/html_report.rb +10 -30
- data/lib/coverband/reporters/web.rb +56 -49
- data/lib/coverband/utils/absolute_file_converter.rb +6 -6
- data/lib/coverband/utils/html_formatter.rb +32 -61
- data/lib/coverband/utils/railtie.rb +16 -4
- data/lib/coverband/utils/relative_file_converter.rb +2 -2
- data/lib/coverband/utils/result.rb +6 -11
- data/lib/coverband/utils/results.rb +0 -10
- data/lib/coverband/utils/source_file.rb +21 -30
- data/lib/coverband/utils/tasks.rb +7 -11
- data/lib/coverband/version.rb +1 -1
- data/public/application.js +0 -30
- data/test/benchmarks/benchmark.rake +97 -92
- data/test/benchmarks/dog.rb +1 -1
- data/test/benchmarks/init_rails.rake +4 -4
- data/test/coverband/adapters/base_test.rb +29 -30
- data/test/coverband/adapters/file_store_test.rb +15 -16
- data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
- data/test/coverband/adapters/redis_store_test.rb +26 -26
- data/test/coverband/at_exit_test.rb +2 -2
- data/test/coverband/collectors/coverage_test.rb +33 -47
- data/test/coverband/collectors/delta_test.rb +51 -23
- data/test/coverband/collectors/view_tracker_test.rb +35 -35
- data/test/coverband/configuration_test.rb +27 -53
- data/test/coverband/coverband_test.rb +11 -11
- data/test/coverband/integrations/background_middleware_test.rb +10 -10
- data/test/coverband/integrations/background_test.rb +3 -2
- data/test/coverband/integrations/rack_server_check_test.rb +7 -7
- data/test/coverband/integrations/report_middleware_test.rb +9 -9
- data/test/coverband/integrations/resque_worker_test.rb +9 -9
- data/test/coverband/integrations/test_resque_job.rb +1 -1
- data/test/coverband/reporters/base_test.rb +9 -9
- data/test/coverband/reporters/console_test.rb +6 -6
- data/test/coverband/reporters/html_test.rb +36 -48
- data/test/coverband/reporters/web_test.rb +16 -18
- data/test/coverband/utils/absolute_file_converter_test.rb +22 -22
- data/test/coverband/utils/file_hasher_test.rb +6 -12
- data/test/coverband/utils/file_list_test.rb +13 -13
- data/test/coverband/utils/html_formatter_test.rb +9 -23
- data/test/coverband/utils/lines_classifier_test.rb +29 -29
- data/test/coverband/utils/relative_file_converter_test.rb +13 -13
- data/test/coverband/utils/result_test.rb +18 -18
- data/test/coverband/utils/results_test.rb +17 -17
- data/test/coverband/utils/source_file_line_test.rb +46 -46
- data/test/coverband/utils/source_file_test.rb +38 -88
- data/test/dog.rb +1 -1
- data/test/fake_app/basic_rack.rb +2 -2
- data/test/fixtures/app/controllers/sample_controller.rb +1 -1
- data/test/fixtures/app/models/user.rb +1 -1
- data/test/fixtures/sample.rb +1 -1
- data/test/fixtures/utf-8.rb +0 -2
- data/test/forked/rails_full_stack_test.rb +24 -27
- data/test/forked/rails_rake_full_stack_test.rb +7 -26
- data/test/integration/full_stack_test.rb +11 -22
- data/test/jruby_check.rb +2 -3
- data/test/rails4_dummy/Rakefile +1 -1
- data/test/rails4_dummy/config.ru +1 -1
- data/test/rails4_dummy/config/application.rb +4 -4
- data/test/rails4_dummy/config/boot.rb +2 -2
- data/test/rails4_dummy/config/coverband.rb +1 -1
- data/test/rails4_dummy/config/coverband_missing_redis.rb +1 -1
- data/test/rails4_dummy/config/environment.rb +1 -1
- data/test/rails4_dummy/config/routes.rb +2 -2
- data/test/rails5_dummy/Rakefile +1 -1
- data/test/rails5_dummy/config.ru +1 -1
- data/test/rails5_dummy/config/application.rb +3 -3
- data/test/rails5_dummy/config/coverband.rb +8 -8
- data/test/rails5_dummy/config/coverband_missing_redis.rb +8 -8
- data/test/rails5_dummy/config/environment.rb +1 -1
- data/test/rails5_dummy/config/routes.rb +2 -2
- data/test/rails6_dummy/Rakefile +1 -1
- data/test/rails6_dummy/config.ru +1 -1
- data/test/rails6_dummy/config/application.rb +4 -4
- data/test/rails6_dummy/config/boot.rb +2 -2
- data/test/rails6_dummy/config/coverband.rb +1 -1
- data/test/rails6_dummy/config/coverband_missing_redis.rb +1 -1
- data/test/rails6_dummy/config/environment.rb +1 -1
- data/test/rails6_dummy/config/routes.rb +2 -2
- data/test/rails_test_helper.rb +11 -11
- data/test/test_helper.rb +41 -34
- data/test/unique_files.rb +10 -10
- data/views/layout.erb +2 -12
- metadata +5 -43
- data/.rubocop.yml +0 -84
- data/lib/coverband/integrations/bundler.rb +0 -8
- data/lib/coverband/utils/file_groups.rb +0 -53
- data/lib/coverband/utils/gem_list.rb +0 -31
- data/lib/coverband/utils/s3_report.rb +0 -105
- data/test/coverband/utils/file_groups_test.rb +0 -61
- data/test/coverband/utils/gem_list_test.rb +0 -48
- data/test/coverband/utils/s3_report_test.rb +0 -44
- data/views/gem_list.erb +0 -63
data/.rubocop.yml
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.4
|
3
|
-
Exclude:
|
4
|
-
- vendor/bundle/**/*
|
5
|
-
- docs/**/*
|
6
|
-
- test/rails6_dummy/**/*
|
7
|
-
- test/rails5_dummy/**/*
|
8
|
-
- test/fixtures/**/*
|
9
|
-
# Get the code passing first then we will enable for tests
|
10
|
-
- test/**/*
|
11
|
-
Documentation:
|
12
|
-
Enabled: false
|
13
|
-
Metrics/MethodLength:
|
14
|
-
Enabled: false
|
15
|
-
Layout/LineLength:
|
16
|
-
Max: 160
|
17
|
-
Metrics/BlockNesting:
|
18
|
-
Max: 5
|
19
|
-
Metrics/BlockLength:
|
20
|
-
Max: 30
|
21
|
-
Metrics/CyclomaticComplexity:
|
22
|
-
Enabled: false
|
23
|
-
Metrics/PerceivedComplexity:
|
24
|
-
Enabled: false
|
25
|
-
Metrics/AbcSize:
|
26
|
-
Enabled: false
|
27
|
-
Metrics/ClassLength:
|
28
|
-
Enabled: false
|
29
|
-
Metrics/ModuleLength:
|
30
|
-
Enabled: false
|
31
|
-
Metrics/ParameterLists:
|
32
|
-
Max: 10
|
33
|
-
Naming/AccessorMethodName:
|
34
|
-
Enabled: false
|
35
|
-
Naming/RescuedExceptionsVariableName:
|
36
|
-
Enabled: false
|
37
|
-
Naming/PredicateName:
|
38
|
-
Enabled: true
|
39
|
-
Style/TernaryParentheses:
|
40
|
-
Enabled: false
|
41
|
-
Style/MutableConstant:
|
42
|
-
Enabled: false
|
43
|
-
Style/IdenticalConditionalBranches:
|
44
|
-
Enabled: false
|
45
|
-
Style/ClassVars:
|
46
|
-
Enabled: false
|
47
|
-
Style/MultilineBlockChain:
|
48
|
-
Enabled: false
|
49
|
-
Style/StringLiterals:
|
50
|
-
Enabled: false
|
51
|
-
Style/IfInsideElse:
|
52
|
-
Enabled: false
|
53
|
-
Style/FrozenStringLiteralComment:
|
54
|
-
Enabled: true
|
55
|
-
Style/GuardClause:
|
56
|
-
Enabled: true
|
57
|
-
Style/NumericPredicate:
|
58
|
-
Enabled: true
|
59
|
-
Style/NumericLiterals:
|
60
|
-
Enabled: false
|
61
|
-
Style/NumericLiteralPrefix:
|
62
|
-
Enabled: false
|
63
|
-
Style/ClassAndModuleChildren:
|
64
|
-
Enabled: false
|
65
|
-
Style/SymbolArray:
|
66
|
-
Enabled: false
|
67
|
-
Style/SymbolProc:
|
68
|
-
Enabled: false
|
69
|
-
Style/RegexpLiteral:
|
70
|
-
Enabled: false
|
71
|
-
Layout/MultilineMethodCallIndentation:
|
72
|
-
Enabled: true
|
73
|
-
Layout/MultilineOperationIndentation:
|
74
|
-
Enabled: true
|
75
|
-
Lint/RescueException:
|
76
|
-
Enabled: true
|
77
|
-
Lint/UselessAccessModifier:
|
78
|
-
Enabled: true
|
79
|
-
Lint/ShadowingOuterLocalVariable:
|
80
|
-
Enabled: true
|
81
|
-
Style/FormatString:
|
82
|
-
Enabled: true
|
83
|
-
Security/Eval:
|
84
|
-
Enabled: true
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Applies the configured groups to the given array of Coverband::SourceFile items
|
5
|
-
#
|
6
|
-
module Coverband
|
7
|
-
module Utils
|
8
|
-
class FileGroups
|
9
|
-
def initialize(files)
|
10
|
-
@grouped = {}
|
11
|
-
@files = files
|
12
|
-
filter_to_groups
|
13
|
-
end
|
14
|
-
|
15
|
-
def grouped_results
|
16
|
-
@grouped
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def filter_to_groups
|
22
|
-
grouped_files = []
|
23
|
-
Coverband.configuration.groups.each do |name, filter|
|
24
|
-
if name == 'Gems'
|
25
|
-
gem_lists = gem_files(name, filter)
|
26
|
-
grouped_files.concat(gem_lists.flatten) if gem_lists.flatten.any?
|
27
|
-
else
|
28
|
-
app_files(name, filter)
|
29
|
-
grouped_files += @grouped[name]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
if !Coverband.configuration.groups.empty? && !(other_files = @files.reject do |source_file|
|
33
|
-
grouped_files.include?(source_file)
|
34
|
-
end).empty?
|
35
|
-
@grouped['Ungrouped'] = Coverband::Utils::FileList.new(other_files)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def gem_files(name, filter)
|
40
|
-
grouped_gems = @files.select { |source_file| source_file.filename =~ /#{filter}/ }.group_by(&:gem_name)
|
41
|
-
gem_lists = grouped_gems.values.map { |gem_files| Coverband::Utils::FileList.new(gem_files) }
|
42
|
-
@grouped[name] = Coverband::Utils::GemList.new(gem_lists) if gem_lists.flatten.any?
|
43
|
-
gem_lists
|
44
|
-
end
|
45
|
-
|
46
|
-
def app_files(name, filter)
|
47
|
-
@grouped[name] = Coverband::Utils::FileList.new(@files.select do |source_file|
|
48
|
-
source_file.filename =~ /#{filter}/ && source_file.filename !~ /#{Coverband.configuration.gem_paths.first}/
|
49
|
-
end)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
####
|
4
|
-
# An array of FileLists instances with helpers to roll up the stats
|
5
|
-
# methods for calculating coverage across them etc.
|
6
|
-
####
|
7
|
-
module Coverband
|
8
|
-
module Utils
|
9
|
-
class GemList < FileList
|
10
|
-
# Returns the count of lines that have coverage
|
11
|
-
def covered_lines
|
12
|
-
to_a.map(&:covered_lines).inject(:+)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns the count of lines that have been missed
|
16
|
-
def missed_lines
|
17
|
-
to_a.map(&:missed_lines).inject(:+)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns the count of lines that are not relevant for coverage
|
21
|
-
def never_lines
|
22
|
-
to_a.map(&:never_lines).inject(:+)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns the count of skipped lines
|
26
|
-
def skipped_lines
|
27
|
-
to_a.map(&:skipped_lines).inject(:+)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Coverband
|
4
|
-
module Utils
|
5
|
-
###
|
6
|
-
# TODO: this is currently a html report writer
|
7
|
-
# this should support writing coverage the current method should be fine
|
8
|
-
# to write every report to S3 and sum them later or use the 2 pass
|
9
|
-
# method we do for redis if in a background thread
|
10
|
-
###
|
11
|
-
class S3Report
|
12
|
-
def self.instance
|
13
|
-
s3_options = {
|
14
|
-
region: Coverband.configuration.s3_region,
|
15
|
-
access_key_id: Coverband.configuration.s3_access_key_id,
|
16
|
-
secret_access_key: Coverband.configuration.s3_secret_access_key
|
17
|
-
}
|
18
|
-
new(Coverband.configuration.s3_bucket, s3_options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(bucket_name, options = {})
|
22
|
-
@bucket_name = bucket_name
|
23
|
-
@region = options[:region]
|
24
|
-
@access_key_id = options[:access_key_id]
|
25
|
-
@secret_access_key = options[:secret_access_key]
|
26
|
-
begin
|
27
|
-
require 'aws-sdk-s3'
|
28
|
-
rescue StandardError
|
29
|
-
err_msg = 'Coverband requires aws-sdk in order use S3Report.'
|
30
|
-
Coverband.configuration.logger&.error err_msg
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def persist!
|
35
|
-
if defined?(Aws)
|
36
|
-
object.put(body: coverage_content)
|
37
|
-
else
|
38
|
-
object.write(coverage_content)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def retrieve
|
43
|
-
if defined?(Aws)
|
44
|
-
s3_client.get_object(bucket: Coverband.configuration.s3_bucket,
|
45
|
-
key: 'coverband/index.html').body.read
|
46
|
-
else
|
47
|
-
object.read
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def coverage_content
|
54
|
-
version = Coverband::VERSION
|
55
|
-
File.read("#{Coverband.configuration.root}/coverage/index.html").gsub("./assets/#{version}/", '')
|
56
|
-
end
|
57
|
-
|
58
|
-
def object
|
59
|
-
if defined?(Aws)
|
60
|
-
bucket.object('coverband/index.html')
|
61
|
-
else
|
62
|
-
bucket.objects['coverband/index.html']
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def client_options
|
67
|
-
{
|
68
|
-
region: @region,
|
69
|
-
access_key_id: @access_key_id,
|
70
|
-
secret_access_key: @secret_access_key
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
def s3_client
|
75
|
-
if defined?(Aws)
|
76
|
-
# AWS SDK v2
|
77
|
-
Aws::S3::Client.new(client_options)
|
78
|
-
else
|
79
|
-
# AWS SDK v1
|
80
|
-
AWS::S3::Client.new(client_options)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def s3
|
85
|
-
resource_options = { client: s3_client }
|
86
|
-
resource_options = {} if client_options.values.any?(&:nil?)
|
87
|
-
if defined?(Aws)
|
88
|
-
# AWS SDK v2
|
89
|
-
Aws::S3::Resource.new(resource_options)
|
90
|
-
else
|
91
|
-
# AWS SDK v1
|
92
|
-
AWS::S3.new(resource_options)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def bucket
|
97
|
-
if defined?(Aws)
|
98
|
-
s3.bucket(@bucket_name)
|
99
|
-
else
|
100
|
-
s3.buckets[@bucket_name]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
|
-
|
5
|
-
describe Coverband::Utils::FileGroups do
|
6
|
-
FAKE_GEM_PATH = '/Users/danmayer/.rvm/gems/ruby-2.6.2/gems'
|
7
|
-
SECONDAY_GEM_PATH = '/Users/danmayer/.rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems'
|
8
|
-
subject do
|
9
|
-
controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
|
10
|
-
files = [
|
11
|
-
Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
|
12
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
|
13
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
|
14
|
-
Coverband::Utils::SourceFile.new("#{FAKE_GEM_PATH}/gem_name-1.0.0/gem_name.rb", controller_lines),
|
15
|
-
Coverband::Utils::SourceFile.new("#{SECONDAY_GEM_PATH}/gem_two_name-1.1.1/gem_two.rb", controller_lines)
|
16
|
-
]
|
17
|
-
Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_GEM_PATH, SECONDAY_GEM_PATH])
|
18
|
-
Coverband.configuration.track_gems = true
|
19
|
-
Coverband::Utils::FileGroups.new(files)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'has app files' do
|
23
|
-
assert_equal 'test/fixtures/sample.rb', subject.grouped_results['App'].first.short_name
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'has gem files' do
|
27
|
-
assert_equal "gem_name-1.0.0", subject.grouped_results['Gems'].first.first.gem_name
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'has gem files from secondary gem paths' do
|
31
|
-
assert_equal "gem_two_name-1.1.1", subject.grouped_results['Gems'][1].first.gem_name
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe Coverband::Utils::FileGroups, :vendored_gems do
|
36
|
-
FAKE_VENDOR_GEM_PATH = "#{test_root}/app/vendor/bundle/ruby/2.5.0/gems"
|
37
|
-
subject do
|
38
|
-
controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
|
39
|
-
files = [
|
40
|
-
Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
|
41
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
|
42
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
|
43
|
-
Coverband::Utils::SourceFile.new("#{FAKE_VENDOR_GEM_PATH}/gem_name.rb", controller_lines)
|
44
|
-
]
|
45
|
-
Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_VENDOR_GEM_PATH])
|
46
|
-
Coverband.configuration.track_gems = true
|
47
|
-
Coverband::Utils::FileGroups.new(files)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'has app files' do
|
51
|
-
assert_equal 'test/fixtures/sample.rb', subject.grouped_results['App'].first.short_name
|
52
|
-
end
|
53
|
-
|
54
|
-
it "doesn't include vendor gems in app files app files" do
|
55
|
-
assert_nil subject.grouped_results['App'].select { |files| files.short_name.match(/gem_name/) }.first
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'does has gem files' do
|
59
|
-
assert_equal '.gem_name.rb', subject.grouped_results['Gems'].first.first.short_name
|
60
|
-
end
|
61
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
|
-
|
5
|
-
####
|
6
|
-
# Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
|
7
|
-
# initial version of test pulled into Coverband from Simplecov 12/19/2018
|
8
|
-
####
|
9
|
-
describe Coverband::Utils::GemList do
|
10
|
-
subject do
|
11
|
-
controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
|
12
|
-
gem_files = [
|
13
|
-
Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
|
14
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
|
15
|
-
Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines)
|
16
|
-
]
|
17
|
-
gem_lists = [Coverband::Utils::FileList.new(gem_files), Coverband::Utils::FileList.new(gem_files)]
|
18
|
-
Coverband::Utils::GemList.new(gem_lists)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'has 22 covered lines' do
|
22
|
-
assert_equal 22, subject.covered_lines
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'has 6 missed lines' do
|
26
|
-
assert_equal 6, subject.missed_lines
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'has 34 never lines' do
|
30
|
-
assert_equal 34, subject.never_lines
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'has 28 lines of code' do
|
34
|
-
assert_equal 28, subject.lines_of_code
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'has 10 skipped lines' do
|
38
|
-
assert_equal 10, subject.skipped_lines
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'has the correct covered percent' do
|
42
|
-
assert_equal 78.57142857142857, subject.covered_percent
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'has the correct covered strength' do
|
46
|
-
assert_equal 0.9285714285714286, subject.covered_strength
|
47
|
-
end
|
48
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
4
|
-
|
5
|
-
module Coverband
|
6
|
-
class S3ReportTest < Minitest::Test
|
7
|
-
def html_version
|
8
|
-
Coverband::VERSION
|
9
|
-
end
|
10
|
-
|
11
|
-
test 'it writes the coverage report to s3' do
|
12
|
-
if defined?(Aws::S3::Resource)
|
13
|
-
# AWS v2
|
14
|
-
s3 = mock('s3_resource')
|
15
|
-
bucket = mock('bucket')
|
16
|
-
object = mock('object')
|
17
|
-
s3.expects(:bucket).with('coverage-bucket').returns(bucket)
|
18
|
-
bucket.expects(:object).with('coverband/index.html').returns(object)
|
19
|
-
File.expects(:read).with("#{Coverband.configuration.root}/coverage/index.html").returns("content ./assets/#{html_version}/")
|
20
|
-
object.expects(:put).with(body: 'content ')
|
21
|
-
Aws::S3::Client.expects(:new).returns(nil)
|
22
|
-
Aws::S3::Resource.expects(:new).returns(s3)
|
23
|
-
else
|
24
|
-
# AWS v1
|
25
|
-
object = mock('object')
|
26
|
-
object.expects(:write).with('content ')
|
27
|
-
bucket = mock('bucket')
|
28
|
-
bucket.expects(:objects).returns('coverband/index.html' => object)
|
29
|
-
local_s3 = mock('s3_resource')
|
30
|
-
local_s3.expects(:buckets).returns('coverage-bucket' => bucket)
|
31
|
-
File.expects(:read).at_least(0).returns("content ./assets/#{html_version}/")
|
32
|
-
AWS::S3::Client.expects(:new).returns(nil)
|
33
|
-
AWS::S3.expects(:new).returns(local_s3)
|
34
|
-
end
|
35
|
-
|
36
|
-
s3_options = {
|
37
|
-
region: 'us-west-1',
|
38
|
-
access_key_id: '',
|
39
|
-
secret_access_key: ''
|
40
|
-
}
|
41
|
-
Coverband::Utils::S3Report.new('coverage-bucket', s3_options).persist!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/views/gem_list.erb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
<div class="file_list_container" id="<%= title_id %>">
|
2
|
-
<h2>
|
3
|
-
<span class="group_name"><%= title %></span>
|
4
|
-
(<span class="covered_percent"><span class="<%= coverage_css_class(source_files.covered_percent) %>"><%= source_files.covered_percent.round(2) %>%</span></span>
|
5
|
-
covered at
|
6
|
-
<span class="covered_strength">
|
7
|
-
<span class="<%= strength_css_class(source_files.covered_strength) %>">
|
8
|
-
<%= source_files.covered_strength.round(2) %>
|
9
|
-
</span>
|
10
|
-
</span> hits/line)
|
11
|
-
</h2>
|
12
|
-
<div>
|
13
|
-
<b><%= source_files.length %></b> files in total.
|
14
|
-
<b><%= source_files.lines_of_code %></b> relevant lines.
|
15
|
-
<span class="green"><b><%= source_files.covered_lines %></b> lines covered</span> and
|
16
|
-
<span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
|
17
|
-
</div>
|
18
|
-
<table class="gem_list">
|
19
|
-
<thead>
|
20
|
-
<tr>
|
21
|
-
<th>Gem</th>
|
22
|
-
<th>% covered</th>
|
23
|
-
<th>% runtime</th>
|
24
|
-
<th>Relevant Lines</th>
|
25
|
-
<th>Lines covered</th>
|
26
|
-
<th>Lines runtime</th>
|
27
|
-
<th>Lines missed</th>
|
28
|
-
<th>Avg. Hits / Line</th>
|
29
|
-
</tr>
|
30
|
-
</thead>
|
31
|
-
<tbody>
|
32
|
-
<% source_files.each do |source_file| %>
|
33
|
-
<tr>
|
34
|
-
<td class="strong">
|
35
|
-
<% if gem_details? %>
|
36
|
-
<%= link_to_gem_list(source_file.first.gem_name) %>
|
37
|
-
<% else %>
|
38
|
-
<%= source_file.first.gem_name %>
|
39
|
-
<% end %>
|
40
|
-
</td>
|
41
|
-
<td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
|
42
|
-
<% runtime_percentage = result.group_file_list_with_type(title, source_file, Coverband::RUNTIME_TYPE)&.formatted_covered_percent %>
|
43
|
-
<td class="<%= "#{coverage_css_class(runtime_percentage)}" %> strong">
|
44
|
-
<%= "#{runtime_percentage || '0'} %" %>
|
45
|
-
</td>
|
46
|
-
<td><%= source_file.covered_lines + source_file.missed_lines %></td>
|
47
|
-
<td><%= source_file.covered_lines %></td>
|
48
|
-
<td>
|
49
|
-
<%= result.group_file_list_with_type(title, source_file, Coverband::RUNTIME_TYPE)&.covered_lines || 0 %>
|
50
|
-
</td>
|
51
|
-
<td><%= source_file.missed_lines %></td>
|
52
|
-
<td><%= source_file.covered_strength.round(1) %></td>
|
53
|
-
</tr>
|
54
|
-
<% end %>
|
55
|
-
</tbody>
|
56
|
-
</table>
|
57
|
-
</div>
|
58
|
-
|
59
|
-
<% if gem_details? %>
|
60
|
-
<% source_files.each do |gem_files| %>
|
61
|
-
<%= formatted_file_list(gem_files.first.gem_name, result, gem_files, skip_nav: true) %>
|
62
|
-
<% end %>
|
63
|
-
<% end %>
|