coverband 4.2.7 → 5.0.0.rc.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +26 -0
- data/.travis.yml +2 -1
- data/Gemfile +5 -7
- data/Gemfile.rails4 +0 -3
- data/Gemfile.rails6 +0 -3
- data/README.md +8 -77
- data/Rakefile +17 -17
- data/changes.md +30 -28
- data/config.ru +1 -1
- data/coverband.gemspec +31 -34
- data/lib/coverband.rb +68 -44
- data/lib/coverband/adapters/base.rb +17 -18
- data/lib/coverband/adapters/file_store.rb +38 -6
- data/lib/coverband/adapters/hash_redis_store.rb +24 -21
- data/lib/coverband/adapters/redis_store.rb +12 -12
- data/lib/coverband/adapters/stdout_store.rb +41 -0
- data/lib/coverband/adapters/web_service_store.rb +155 -0
- data/lib/coverband/at_exit.rb +1 -1
- data/lib/coverband/collectors/coverage.rb +15 -27
- data/lib/coverband/collectors/delta.rb +29 -9
- data/lib/coverband/collectors/view_tracker.rb +10 -10
- data/lib/coverband/collectors/view_tracker_service.rb +59 -0
- data/lib/coverband/configuration.rb +149 -112
- data/lib/coverband/integrations/background.rb +6 -6
- data/lib/coverband/integrations/rack_server_check.rb +3 -3
- data/lib/coverband/reporters/base.rb +11 -12
- data/lib/coverband/reporters/console_report.rb +1 -1
- data/lib/coverband/reporters/html_report.rb +10 -30
- data/lib/coverband/reporters/web.rb +55 -50
- 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 +23 -6
- 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 +8 -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 +19 -20
- data/test/coverband/adapters/hash_redis_store_test.rb +57 -57
- data/test/coverband/adapters/redis_store_test.rb +26 -26
- data/test/coverband/adapters/web_service_store_test.rb +56 -0
- 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 +52 -23
- data/test/coverband/collectors/view_tracker_test.rb +35 -35
- data/test/coverband/configuration_test.rb +49 -36
- 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 +17 -5
- 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 +44 -34
- data/test/unique_files.rb +10 -10
- data/views/layout.erb +2 -12
- metadata +28 -34
- data/.rubocop.yml +0 -86
- 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
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class HTMLReportTest < Minitest::Test
|
6
6
|
REDIS_STORAGE_FORMAT_VERSION = Coverband::Adapters::RedisStore::REDIS_STORAGE_FORMAT_VERSION
|
@@ -10,17 +10,17 @@ class HTMLReportTest < Minitest::Test
|
|
10
10
|
@store = Coverband.configuration.store
|
11
11
|
end
|
12
12
|
|
13
|
-
test
|
13
|
+
test "report data" do
|
14
14
|
Coverband.configure do |config|
|
15
|
-
config.reporter =
|
15
|
+
config.reporter = "std_out"
|
16
16
|
end
|
17
|
-
Coverband.configuration.logger.stubs(
|
17
|
+
Coverband.configuration.logger.stubs("info")
|
18
18
|
mock_file_hash
|
19
|
-
Coverband::Utils::RelativeFileConverter.expects(:convert).with(
|
19
|
+
Coverband::Utils::RelativeFileConverter.expects(:convert).with("app_path/dog.rb").returns("./dog.rb")
|
20
20
|
@store.send(:save_report, basic_coverage)
|
21
21
|
|
22
22
|
report = Coverband::Reporters::ConsoleReport.report(@store)[:merged]
|
23
|
-
expected = {
|
23
|
+
expected = {"./dog.rb" => [0, 1, 2]}
|
24
24
|
assert_equal(expected.keys, report.keys)
|
25
25
|
end
|
26
26
|
end
|
@@ -1,95 +1,83 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class ReportHTMLTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
super
|
8
8
|
@store = Coverband.configuration.store
|
9
9
|
Coverband.configure do |config|
|
10
|
-
config.store
|
11
|
-
config.root
|
12
|
-
config.ignore
|
10
|
+
config.store = @store
|
11
|
+
config.root = fixtures_root
|
12
|
+
config.ignore = ["notsomething.rb", "lib/*"]
|
13
13
|
end
|
14
14
|
mock_file_hash
|
15
15
|
end
|
16
16
|
|
17
|
-
test
|
17
|
+
test "generate dynamic content hosted html report" do
|
18
18
|
@store.send(:save_report, basic_coverage)
|
19
19
|
|
20
20
|
html = Coverband::Reporters::HTMLReport.new(@store,
|
21
|
-
|
22
|
-
|
23
|
-
assert_match 'Generated by', html
|
21
|
+
open_report: false).report
|
22
|
+
assert_match "Generated by", html
|
24
23
|
end
|
25
24
|
|
26
|
-
test
|
25
|
+
test "files with no Coverage but in project are shown in reports" do
|
27
26
|
@store.send(:save_report, basic_source_fixture_coverage)
|
28
27
|
|
29
28
|
html = Coverband::Reporters::HTMLReport.new(@store,
|
30
|
-
|
31
|
-
|
32
|
-
assert_match 'sample.rb', html
|
29
|
+
open_report: false).report
|
30
|
+
assert_match "sample.rb", html
|
33
31
|
# in project, but not in coverage data
|
34
|
-
assert_match
|
32
|
+
assert_match "app/models/user.rb", html
|
35
33
|
end
|
36
34
|
|
37
|
-
test
|
35
|
+
test "files with no Coverage but in project details page list warning" do
|
38
36
|
@store.send(:save_report, basic_coverage_full_path)
|
39
37
|
|
40
|
-
|
38
|
+
basic_coverage_file_full_path
|
41
39
|
base_path = Dir.pwd
|
42
40
|
# in project, but not in coverage data
|
43
41
|
html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
assert_match
|
48
|
-
end
|
49
|
-
|
50
|
-
test 'generate static HTML report file' do
|
51
|
-
@store.send(:save_report, basic_coverage)
|
52
|
-
|
53
|
-
reporter = Coverband::Reporters::HTMLReport.new(@store,
|
54
|
-
static: true,
|
55
|
-
open_report: false)
|
56
|
-
Coverband::Utils::HTMLFormatter.any_instance.expects(:format_static_html!).once
|
57
|
-
reporter.report
|
42
|
+
filename: "#{Dir.pwd}/test/fixtures/app/models/user.rb",
|
43
|
+
base_path: base_path,
|
44
|
+
open_report: false).file_details
|
45
|
+
assert_match "This file was never loaded", html
|
58
46
|
end
|
59
47
|
|
60
|
-
test
|
48
|
+
test "generate dynamic content detailed file report" do
|
61
49
|
@store.send(:save_report, basic_coverage_full_path)
|
62
50
|
|
63
51
|
filename = basic_coverage_file_full_path
|
64
|
-
base_path =
|
52
|
+
base_path = "/coverage"
|
65
53
|
html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
assert_match
|
54
|
+
filename: filename,
|
55
|
+
base_path: base_path,
|
56
|
+
open_report: false).file_details
|
57
|
+
assert_match "Coverage first seen", html
|
70
58
|
end
|
71
59
|
|
72
|
-
test
|
60
|
+
test "generate dynamic content detailed file report handles missing file" do
|
73
61
|
@store.send(:save_report, basic_coverage_full_path)
|
74
62
|
|
75
|
-
filename =
|
76
|
-
base_path =
|
63
|
+
filename = "missing_path"
|
64
|
+
base_path = "/coverage"
|
77
65
|
html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
assert_match
|
66
|
+
filename: filename,
|
67
|
+
base_path: base_path,
|
68
|
+
open_report: false).file_details
|
69
|
+
assert_match "File No Longer Available", html
|
82
70
|
end
|
83
71
|
|
84
|
-
test
|
72
|
+
test "generate dynamic content detailed file report does not allow loading real non project files" do
|
85
73
|
@store.send(:save_report, basic_coverage_full_path)
|
86
74
|
|
87
75
|
filename = "#{test_root}/test_helper.rb"
|
88
|
-
base_path =
|
76
|
+
base_path = "/coverage"
|
89
77
|
html = Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
assert_match
|
78
|
+
filename: filename,
|
79
|
+
base_path: base_path,
|
80
|
+
open_report: false).file_details
|
81
|
+
assert_match "File No Longer Available", html
|
94
82
|
end
|
95
83
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'rack/test'
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
|
+
require File.expand_path("../../../lib/coverband/reporters/web", File.dirname(__FILE__))
|
5
|
+
require "rack/test"
|
7
6
|
|
8
|
-
ENV[
|
7
|
+
ENV["RACK_ENV"] = "test"
|
9
8
|
|
10
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(
|
9
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
|
11
10
|
module Coverband
|
12
11
|
class WebTest < Minitest::Test
|
13
12
|
include Rack::Test::Methods
|
@@ -18,29 +17,28 @@ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
|
|
18
17
|
|
19
18
|
def teardown
|
20
19
|
super
|
21
|
-
Coverband.configuration.s3_bucket = nil
|
22
20
|
end
|
23
21
|
|
24
|
-
test
|
25
|
-
get
|
22
|
+
test "renders index content" do
|
23
|
+
get "/"
|
26
24
|
assert last_response.ok?
|
27
|
-
assert_match
|
25
|
+
assert_match "Coverband Admin", last_response.body
|
28
26
|
end
|
29
27
|
|
30
|
-
test
|
31
|
-
get
|
28
|
+
test "renders index content for empty path" do
|
29
|
+
get ""
|
32
30
|
assert last_response.ok?
|
33
|
-
assert_match
|
31
|
+
assert_match "Coverband Admin", last_response.body
|
34
32
|
end
|
35
33
|
|
36
|
-
test
|
37
|
-
get
|
34
|
+
test "renders 404" do
|
35
|
+
get "/show"
|
38
36
|
assert last_response.not_found?
|
39
|
-
assert_equal
|
37
|
+
assert_equal "404 error!", last_response.body
|
40
38
|
end
|
41
39
|
|
42
|
-
test
|
43
|
-
post
|
40
|
+
test "clears coverband" do
|
41
|
+
post "/clear"
|
44
42
|
assert_equal 301, last_response.status
|
45
43
|
end
|
46
44
|
end
|
@@ -1,53 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
module Coverband
|
6
6
|
module Utils
|
7
7
|
class AbsoluteFileConverterTest < ::Minitest::Test
|
8
8
|
def test_convert
|
9
9
|
converter = AbsoluteFileConverter.new([FileUtils.pwd])
|
10
|
-
assert_equal("#{FileUtils.pwd}/lib/coverband.rb", converter.convert(
|
10
|
+
assert_equal("#{FileUtils.pwd}/lib/coverband.rb", converter.convert("./lib/coverband.rb"))
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_convert_multiple_roots
|
14
|
-
converter = AbsoluteFileConverter.new([
|
15
|
-
assert_equal("#{FileUtils.pwd}/Rakefile", converter.convert(
|
14
|
+
converter = AbsoluteFileConverter.new(["/foo/bar", FileUtils.pwd])
|
15
|
+
assert_equal("#{FileUtils.pwd}/Rakefile", converter.convert("./Rakefile"))
|
16
16
|
end
|
17
17
|
|
18
|
-
test
|
19
|
-
converter = AbsoluteFileConverter.new([
|
20
|
-
assert_equal
|
18
|
+
test "relative_path_to_full leave filename from a key with a local path" do
|
19
|
+
converter = AbsoluteFileConverter.new(["/app/", "/full/remote_app/path/"])
|
20
|
+
assert_equal "/full/remote_app/path/is/a/path.rb", converter.convert("/full/remote_app/path/is/a/path.rb")
|
21
21
|
end
|
22
22
|
|
23
|
-
test
|
24
|
-
key =
|
25
|
-
converter = AbsoluteFileConverter.new([
|
26
|
-
expected_path =
|
23
|
+
test "relative_path_to_full fix filename from a key with a swappable path" do
|
24
|
+
key = "/app/is/a/path.rb"
|
25
|
+
converter = AbsoluteFileConverter.new(["/app/", "/full/remote_app/path/"])
|
26
|
+
expected_path = "/full/remote_app/path/is/a/path.rb"
|
27
27
|
File.expects(:exist?).with(key).returns(false)
|
28
28
|
File.expects(:exist?).with(expected_path).returns(true)
|
29
29
|
assert_equal expected_path, converter.convert(key)
|
30
30
|
end
|
31
31
|
|
32
|
-
test
|
33
|
-
converter = AbsoluteFileConverter.new(['/box/apps/app_name/releases/\\d+/',
|
34
|
-
expected_path =
|
35
|
-
key =
|
32
|
+
test "relative_path_to_full fix filename a changing deploy path with quotes" do
|
33
|
+
converter = AbsoluteFileConverter.new(['/box/apps/app_name/releases/\\d+/', "/full/remote_app/path/"])
|
34
|
+
expected_path = "/full/remote_app/path/app/models/user.rb"
|
35
|
+
key = "/box/apps/app_name/releases/20140725203539/app/models/user.rb"
|
36
36
|
File.expects(:exist?).with('/box/apps/app_name/releases/\\d+/app/models/user.rb').returns(false)
|
37
37
|
File.expects(:exist?).with(expected_path).returns(true)
|
38
38
|
assert_equal expected_path, converter.convert(key)
|
39
39
|
assert_equal expected_path, converter.convert(key)
|
40
40
|
end
|
41
41
|
|
42
|
-
test
|
43
|
-
current_app_root =
|
44
|
-
converter = AbsoluteFileConverter.new([
|
42
|
+
test "relative_path_to_full fix filename a changing deploy path real world examples" do
|
43
|
+
current_app_root = "/var/local/company/company.d/79"
|
44
|
+
converter = AbsoluteFileConverter.new(["/var/local/company/company.d/[0-9]*/", "#{current_app_root}/"])
|
45
45
|
|
46
|
-
expected_path =
|
47
|
-
key =
|
48
|
-
File.expects(:exist?).with(
|
46
|
+
expected_path = "/var/local/company/company.d/79/app/controllers/dashboard_controller.rb"
|
47
|
+
key = "/var/local/company/company.d/78/app/controllers/dashboard_controller.rb"
|
48
|
+
File.expects(:exist?).with("/var/local/company/company.d/[0-9]*/app/controllers/dashboard_controller.rb").returns(false)
|
49
49
|
File.expects(:exist?).with(expected_path).returns(true)
|
50
|
-
roots = [
|
50
|
+
# roots = ["/var/local/company/company.d/[0-9]*/", "#{current_app_root}/"]
|
51
51
|
assert_equal expected_path, converter.convert(key)
|
52
52
|
assert_equal expected_path, converter.convert(key)
|
53
53
|
end
|
@@ -1,28 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
module Coverband
|
6
6
|
module Utils
|
7
7
|
class FileHasherTest < Minitest::Test
|
8
8
|
def test_hash_same_file
|
9
|
-
refute_nil FileHasher.hash(
|
10
|
-
assert_equal(FileHasher.hash(
|
11
|
-
assert_equal(FileHasher.hash(File.expand_path(
|
9
|
+
refute_nil FileHasher.hash("./test/dog.rb")
|
10
|
+
assert_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./test/dog.rb"))
|
11
|
+
assert_equal(FileHasher.hash(File.expand_path("./test/dog.rb")), FileHasher.hash("./test/dog.rb"))
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_hash_different_files
|
15
|
-
refute_equal(FileHasher.hash(
|
15
|
+
refute_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./lib/coverband.rb"))
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_hash_file_not_exists
|
19
|
-
assert_nil(FileHasher.hash(
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_hash_gem_file
|
23
|
-
spec = Gem::Specification.find_by_name('rainbow')
|
24
|
-
assert FileHasher.hash("./gems/rainbow-#{spec.version}/lib/rainbow.rb",
|
25
|
-
path_converter: AbsoluteFileConverter.new(Coverband.configuration.gem_paths))
|
19
|
+
assert_nil(FileHasher.hash("./made_up_file.py"))
|
26
20
|
end
|
27
21
|
end
|
28
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
####
|
6
6
|
# Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
|
@@ -9,46 +9,46 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
|
9
9
|
describe Coverband::Utils::FileList do
|
10
10
|
subject do
|
11
11
|
original_result = {
|
12
|
-
source_fixture(
|
13
|
-
source_fixture(
|
14
|
-
source_fixture(
|
12
|
+
source_fixture("sample.rb") => {"first_updated_at" => Time.at(0), "data" => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]},
|
13
|
+
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
14
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
|
15
15
|
}
|
16
16
|
Coverband::Utils::Result.new(original_result).files
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it "has 11 covered lines" do
|
20
20
|
assert_equal 11, subject.covered_lines
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it "has 3 missed lines" do
|
24
24
|
assert_equal 3, subject.missed_lines
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it "has 17 never lines" do
|
28
28
|
assert_equal 17, subject.never_lines
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "has 14 lines of code" do
|
32
32
|
assert_equal 14, subject.lines_of_code
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
35
|
+
it "has 5 skipped lines" do
|
36
36
|
assert_equal 5, subject.skipped_lines
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it "has the correct covered percent" do
|
40
40
|
assert_equal 78.57142857142857, subject.covered_percent
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
43
|
+
it "has the correct covered percentages" do
|
44
44
|
assert_equal [50.0, 80.0, 100.0], subject.covered_percentages
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "has the correct covered strength" do
|
48
48
|
assert_equal 0.9285714285714286, subject.covered_strength
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it "has correct first_seen_at" do
|
52
52
|
assert_equal Time.at(0), subject.first_seen_at
|
53
53
|
end
|
54
54
|
end
|
@@ -1,41 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class HTMLFormatterTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
super
|
8
|
-
@store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace:
|
8
|
+
@store = Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
|
9
9
|
end
|
10
10
|
|
11
|
-
test
|
11
|
+
test "generate dynamic content hosted html report" do
|
12
12
|
Coverband.configure do |config|
|
13
|
-
config.store
|
14
|
-
config.ignore
|
13
|
+
config.store = @store
|
14
|
+
config.ignore = ["notsomething.rb"]
|
15
15
|
end
|
16
16
|
mock_file_hash
|
17
17
|
@store.send(:save_report, basic_coverage_full_path)
|
18
18
|
|
19
19
|
notice = nil
|
20
|
-
base_path =
|
20
|
+
base_path = "/coverage"
|
21
21
|
filtered_report_files = Coverband::Reporters::Base.report(@store, {})
|
22
22
|
html = Coverband::Utils::HTMLFormatter.new(filtered_report_files,
|
23
|
-
|
24
|
-
|
25
|
-
assert_match
|
26
|
-
end
|
27
|
-
|
28
|
-
test 'generate static HTML report file' do
|
29
|
-
Coverband.configure do |config|
|
30
|
-
config.store = @store
|
31
|
-
config.ignore = ['notsomething.rb']
|
32
|
-
end
|
33
|
-
mock_file_hash
|
34
|
-
@store.send(:save_report, basic_coverage_full_path)
|
35
|
-
|
36
|
-
filtered_report_files = Coverband::Reporters::Base.report(@store, {})
|
37
|
-
Coverband::Utils::HTMLFormatter.new(filtered_report_files).format_static_html!
|
38
|
-
html = File.read("#{Coverband.configuration.root}/coverage/index.html")
|
39
|
-
assert_match 'Coverage first seen', html
|
23
|
+
base_path: base_path,
|
24
|
+
notice: notice).format_dynamic_html!
|
25
|
+
assert_match "loading source data", html
|
40
26
|
end
|
41
27
|
end
|