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
@@ -1,9 +1,9 @@
|
|
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 AtExitTest < Minitest::Test
|
6
|
-
test
|
6
|
+
test "only registers once" do
|
7
7
|
Coverband::AtExit.instance_eval { @at_exit_registered = nil }
|
8
8
|
Coverband::AtExit.expects(:at_exit).yields.once.returns(true)
|
9
9
|
2.times { Coverband::AtExit.register }
|
@@ -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 CollectorsCoverageTest < Minitest::Test
|
6
6
|
attr_accessor :coverband
|
@@ -19,111 +19,97 @@ class CollectorsCoverageTest < Minitest::Test
|
|
19
19
|
@coverband = Coverband::Collectors::Coverage.instance.reset_instance
|
20
20
|
end
|
21
21
|
|
22
|
-
test
|
22
|
+
test "Dog class coverage" do
|
23
23
|
file = require_unique_file
|
24
24
|
coverband.report_coverage
|
25
25
|
coverage = Coverband.configuration.store.coverage
|
26
|
-
assert_equal(coverage[file][
|
26
|
+
assert_equal(coverage[file]["data"], [nil, nil, 1, 1, 0, nil, nil])
|
27
27
|
end
|
28
28
|
|
29
|
-
test
|
30
|
-
load File.expand_path(
|
29
|
+
test "Dog method and class coverage" do
|
30
|
+
load File.expand_path("../../dog.rb", File.dirname(__FILE__))
|
31
31
|
Dog.new.bark
|
32
32
|
coverband.report_coverage
|
33
33
|
coverage = Coverband.configuration.store.coverage
|
34
|
-
assert_equal(coverage[
|
34
|
+
assert_equal(coverage["./test/dog.rb"]["data"], [nil, nil, 1, 1, 1, nil, nil])
|
35
35
|
end
|
36
36
|
|
37
|
-
test
|
37
|
+
test "Dog eager load coverage" do
|
38
38
|
store = Coverband.configuration.store
|
39
39
|
assert_equal Coverband::RUNTIME_TYPE, store.type
|
40
|
-
file = coverband.eager_loading
|
40
|
+
file = coverband.eager_loading {
|
41
41
|
require_unique_file
|
42
|
-
|
42
|
+
}
|
43
43
|
coverage = Coverband.configuration.store.coverage[file]
|
44
|
-
assert_nil coverage,
|
44
|
+
assert_nil coverage, "No runtime coverage"
|
45
45
|
coverband.eager_loading!
|
46
46
|
coverage = Coverband.configuration.store.coverage[file]
|
47
|
-
refute_nil coverage,
|
48
|
-
assert_equal(coverage[
|
47
|
+
refute_nil coverage, "Eager load coverage is present"
|
48
|
+
assert_equal(coverage["data"], [nil, nil, 1, 1, 0, nil, nil])
|
49
49
|
end
|
50
50
|
|
51
|
-
test
|
51
|
+
test "gets coverage instance" do
|
52
52
|
assert_equal Coverband::Collectors::Coverage, coverband.class
|
53
53
|
end
|
54
54
|
|
55
|
-
test
|
56
|
-
assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get(
|
55
|
+
test "defaults to a redis store" do
|
56
|
+
assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get("@store").class
|
57
57
|
end
|
58
58
|
|
59
|
-
test
|
60
|
-
Coverband::Adapters::RedisStore.any_instance.stubs(:save_report).raises(
|
59
|
+
test "report_coverage raises errors in tests" do
|
60
|
+
Coverband::Adapters::RedisStore.any_instance.stubs(:save_report).raises("Oh no")
|
61
61
|
@coverband.reset_instance
|
62
62
|
assert_raises RuntimeError do
|
63
63
|
@coverband.report_coverage
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
test
|
67
|
+
test "report_coverage raises errors in tests with verbose enabled" do
|
68
68
|
Coverband.configuration.verbose = true
|
69
69
|
logger = mock
|
70
70
|
Coverband.configuration.logger = logger
|
71
71
|
@coverband.reset_instance
|
72
|
-
Coverband::Adapters::RedisStore.any_instance.stubs(:save_report).raises(
|
72
|
+
Coverband::Adapters::RedisStore.any_instance.stubs(:save_report).raises("Oh no")
|
73
73
|
logger.expects(:error).at_least(3)
|
74
74
|
error = assert_raises RuntimeError do
|
75
75
|
@coverband.report_coverage
|
76
76
|
end
|
77
|
-
assert_match
|
78
|
-
end
|
79
|
-
|
80
|
-
test 'default tmp ignores' do
|
81
|
-
heroku_build_file = '/tmp/build_81feca8c72366e4edf020dc6f1937485/config/initializers/assets.rb'
|
82
|
-
assert_equal false, @coverband.send(:track_file?, heroku_build_file)
|
83
|
-
end
|
84
|
-
|
85
|
-
# verifies a fix where we were storing, merging, and tracking ignored files
|
86
|
-
# then just filtering them out of the final report
|
87
|
-
test 'ignores uses regex same as reporter does' do
|
88
|
-
regex_file = Coverband.configuration.current_root + '/config/initializers/fake.rb'
|
89
|
-
assert_equal true, @coverband.send(:track_file?, regex_file)
|
90
|
-
@coverband.instance_variable_set(:@ignore_patterns, ['config/initializers/*'])
|
91
|
-
assert_equal false, @coverband.send(:track_file?, regex_file)
|
77
|
+
assert_match %r{Oh no}, error.message
|
92
78
|
end
|
93
79
|
|
94
|
-
test
|
95
|
-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(
|
80
|
+
test "one shot line coverage disabled for ruby >= 2.6" do
|
81
|
+
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
|
96
82
|
|
97
|
-
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with(
|
83
|
+
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with("2.6.0").returns(true)
|
98
84
|
::Coverage.expects(:running?).returns(false)
|
99
85
|
::Coverage.expects(:start).with(oneshot_lines: false)
|
100
86
|
Coverband::Collectors::Coverage.send(:new)
|
101
87
|
end
|
102
88
|
|
103
|
-
test
|
104
|
-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(
|
89
|
+
test "one shot line coverage enabled for ruby >= 2.6" do
|
90
|
+
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
|
105
91
|
|
106
92
|
Coverband.configuration.expects(:use_oneshot_lines_coverage).returns(true)
|
107
|
-
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with(
|
93
|
+
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with("2.6.0").returns(true)
|
108
94
|
::Coverage.expects(:running?).returns(false)
|
109
95
|
::Coverage.expects(:start).with(oneshot_lines: true)
|
110
96
|
Coverband::Collectors::Coverage.send(:new)
|
111
97
|
end
|
112
98
|
|
113
|
-
test
|
114
|
-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(
|
99
|
+
test "one shot line coverage for ruby >= 2.6 when already running" do
|
100
|
+
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
|
115
101
|
|
116
|
-
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with(
|
102
|
+
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with("2.6.0").returns(true)
|
117
103
|
::Coverage.expects(:running?).returns(true)
|
118
104
|
::Coverage.expects(:start).never
|
119
105
|
Coverband::Collectors::Coverage.send(:new)
|
120
106
|
end
|
121
107
|
|
122
|
-
test
|
123
|
-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(
|
108
|
+
test "no one shot line coverage for ruby < 2.6" do
|
109
|
+
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
|
124
110
|
|
125
|
-
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with(
|
126
|
-
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with(
|
111
|
+
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with("2.6.0").returns(false)
|
112
|
+
Coverband::Collectors::Coverage.expects(:ruby_version_greater_than_or_equal_to?).with("2.5.0").returns(true)
|
127
113
|
::Coverage.expects(:running?).returns(false)
|
128
114
|
::Coverage.expects(:start).with
|
129
115
|
Coverband::Collectors::Coverage.send(:new)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path(
|
4
|
-
require
|
3
|
+
require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
4
|
+
require "./lib/coverband/collectors/delta"
|
5
5
|
|
6
6
|
class CollectorsDeltaTest < Minitest::Test
|
7
7
|
class MockSystemCoverage < Struct.new(:results)
|
@@ -13,83 +13,111 @@ class CollectorsDeltaTest < Minitest::Test
|
|
13
13
|
|
14
14
|
def setup
|
15
15
|
Coverband::Collectors::Delta.reset
|
16
|
+
Coverband::Collectors::Delta.class_variable_set(:@@project_directory, "car.rb")
|
16
17
|
end
|
17
18
|
|
18
|
-
test
|
19
|
+
test "No previous results" do
|
19
20
|
current_coverage = {
|
20
|
-
|
21
|
+
"car.rb" => [0, 5, 1]
|
21
22
|
}
|
22
23
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
23
24
|
assert_equal(current_coverage, results)
|
24
25
|
end
|
25
26
|
|
26
|
-
test
|
27
|
+
test "Coverage has gone up" do
|
27
28
|
current_coverage = {
|
28
|
-
|
29
|
+
"car.rb" => [nil, 1, 5, 1]
|
29
30
|
}
|
30
31
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
31
32
|
assert_equal(current_coverage, results)
|
32
33
|
|
33
34
|
current_coverage = {
|
34
|
-
|
35
|
+
"car.rb" => [nil, 1, 7, 1]
|
35
36
|
}
|
36
37
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
37
|
-
assert_equal({
|
38
|
+
assert_equal({"car.rb" => [nil, 0, 2, 0]}, results)
|
38
39
|
end
|
39
40
|
|
40
|
-
test
|
41
|
+
test "New file added to coverage" do
|
41
42
|
current_coverage = {}
|
42
43
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
43
44
|
assert_equal(current_coverage, results)
|
44
45
|
|
45
46
|
current_coverage = {
|
46
|
-
|
47
|
+
"dealership.rb" => [nil, 1, 1, nil]
|
47
48
|
}
|
49
|
+
Coverband::Collectors::Delta.class_variable_set(:@@project_directory, "dealership.rb")
|
48
50
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
49
51
|
assert_equal(current_coverage, results)
|
50
52
|
end
|
51
53
|
|
52
|
-
test
|
54
|
+
test "default tmp ignores" do
|
55
|
+
heroku_build_file = "/tmp/build_81feca8c72366e4edf020dc6f1937485/config/initializers/assets.rb"
|
56
|
+
|
57
|
+
current_coverage = {
|
58
|
+
heroku_build_file => [0, 5, 1]
|
59
|
+
}
|
60
|
+
Coverband::Collectors::Delta.class_variable_set(:@@project_directory, heroku_build_file)
|
61
|
+
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
62
|
+
assert_equal({}, results)
|
63
|
+
end
|
64
|
+
|
65
|
+
# verifies a fix where we were storing, merging, and tracking ignored files
|
66
|
+
# then just filtering them out of the final report
|
67
|
+
test "ignores uses regex same as reporter does" do
|
68
|
+
regex_file = Coverband.configuration.current_root + "/config/initializers/fake.rb"
|
69
|
+
|
53
70
|
current_coverage = {
|
54
|
-
|
71
|
+
regex_file => [0, 5, 1]
|
72
|
+
}
|
73
|
+
|
74
|
+
Coverband::Collectors::Delta.class_variable_set(:@@project_directory, regex_file)
|
75
|
+
Coverband::Collectors::Delta.class_variable_set(:@@ignore_patterns, ["config/initializers/*"])
|
76
|
+
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
77
|
+
assert_equal({}, results)
|
78
|
+
end
|
79
|
+
|
80
|
+
test "Coverage has branching enabled and has gone up" do
|
81
|
+
current_coverage = {
|
82
|
+
"car.rb" => {lines: [nil, 1, 5, 1]}
|
55
83
|
}
|
56
84
|
::Coverage.expects(:peek_result).returns(current_coverage)
|
57
|
-
|
85
|
+
Coverband::Collectors::Delta.results
|
58
86
|
|
59
87
|
current_coverage = {
|
60
|
-
|
88
|
+
"car.rb" => {lines: [nil, 1, 7, 1]}
|
61
89
|
}
|
62
90
|
::Coverage.expects(:peek_result).returns(current_coverage)
|
63
91
|
results = Coverband::Collectors::Delta.results
|
64
|
-
assert_equal({
|
92
|
+
assert_equal({"car.rb" => [nil, 0, 2, 0]}, results)
|
65
93
|
end
|
66
94
|
|
67
95
|
if Coverband.configuration.one_shot_coverage_implemented_in_ruby_version?
|
68
|
-
test
|
96
|
+
test "oneshot coverage calls clear" do
|
69
97
|
Coverband.configuration.stubs(:use_oneshot_lines_coverage).returns(true)
|
70
98
|
current_coverage = {
|
71
|
-
|
99
|
+
"car.rb" => [1, 5]
|
72
100
|
}
|
73
101
|
|
74
102
|
::Coverage.expects(:result).with(clear: true, stop: false).returns(current_coverage)
|
75
|
-
|
103
|
+
Coverband::Collectors::Delta::RubyCoverage.results
|
76
104
|
end
|
77
105
|
|
78
|
-
test
|
106
|
+
test "one shot lines results" do
|
79
107
|
Coverband.configuration.stubs(:use_oneshot_lines_coverage).returns(true)
|
80
108
|
current_coverage = {}
|
81
109
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
82
110
|
assert_equal(current_coverage, results)
|
83
111
|
|
84
112
|
current_coverage = {
|
85
|
-
|
86
|
-
:
|
113
|
+
"dealership.rb" => {
|
114
|
+
oneshot_lines: [2, 3]
|
87
115
|
}
|
88
116
|
}
|
89
|
-
::Coverage.expects(:line_stub).with(
|
117
|
+
::Coverage.expects(:line_stub).with("dealership.rb").returns([nil, 0, 0, nil])
|
90
118
|
results = Coverband::Collectors::Delta.results(mock_coverage(current_coverage))
|
91
119
|
expected = {
|
92
|
-
|
120
|
+
"dealership.rb" => [nil, 1, 1, nil]
|
93
121
|
}
|
94
122
|
assert_equal(expected, results)
|
95
123
|
end
|
@@ -1,10 +1,10 @@
|
|
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 ReporterTest < Minitest::Test
|
6
6
|
def tracker_key
|
7
|
-
|
7
|
+
"render_tracker_2"
|
8
8
|
end
|
9
9
|
|
10
10
|
def setup
|
@@ -12,102 +12,102 @@ class ReporterTest < Minitest::Test
|
|
12
12
|
fake_store.raw_store.del(tracker_key)
|
13
13
|
end
|
14
14
|
|
15
|
-
test
|
15
|
+
test "init correctly" do
|
16
16
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
17
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: fake_store, roots:
|
18
|
-
assert_equal
|
17
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: fake_store, roots: "dir")
|
18
|
+
assert_equal "dir", tracker.roots.first
|
19
19
|
assert !tracker.store.nil?
|
20
20
|
assert_equal [], tracker.target
|
21
21
|
assert_equal [], tracker.logged_views
|
22
22
|
end
|
23
23
|
|
24
|
-
test
|
24
|
+
test "track partials" do
|
25
25
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
26
26
|
store = fake_store
|
27
27
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/file"
|
28
28
|
store.raw_store.expects(:hset).with(tracker_key, file_path, anything)
|
29
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
30
|
-
tracker.track_views(
|
29
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
30
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
31
31
|
tracker.report_views_tracked
|
32
32
|
assert_equal [file_path], tracker.logged_views
|
33
33
|
end
|
34
34
|
|
35
|
-
test
|
35
|
+
test "track partials that include the word vendor in the path" do
|
36
36
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
37
37
|
store = fake_store
|
38
38
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/vendor_relations/file"
|
39
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
40
|
-
tracker.track_views(
|
39
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
40
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
41
41
|
tracker.report_views_tracked
|
42
42
|
assert_equal [file_path], tracker.used_views.keys
|
43
43
|
end
|
44
44
|
|
45
|
-
test
|
45
|
+
test "ignore partials that include the folder vendor in the path" do
|
46
46
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
47
47
|
store = fake_store
|
48
48
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/vendor/file"
|
49
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
50
|
-
tracker.track_views(
|
49
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
50
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
51
51
|
tracker.report_views_tracked
|
52
|
-
assert_equal
|
52
|
+
assert_equal({}, tracker.used_views)
|
53
53
|
end
|
54
54
|
|
55
|
-
test
|
55
|
+
test "track layouts" do
|
56
56
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
57
57
|
store = fake_store
|
58
58
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/layout"
|
59
59
|
store.raw_store.expects(:hset).with(tracker_key, file_path, anything)
|
60
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
61
|
-
tracker.track_views(
|
60
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
61
|
+
tracker.track_views("name", "start", "finish", "id", layout: file_path)
|
62
62
|
tracker.report_views_tracked
|
63
63
|
assert_equal [file_path], tracker.logged_views
|
64
64
|
end
|
65
65
|
|
66
|
-
test
|
66
|
+
test "report used partials" do
|
67
67
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
68
68
|
store = fake_store
|
69
69
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/file"
|
70
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
71
|
-
tracker.track_views(
|
70
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
71
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
72
72
|
tracker.report_views_tracked
|
73
73
|
assert_equal [file_path], tracker.used_views.keys
|
74
74
|
end
|
75
75
|
|
76
|
-
test
|
76
|
+
test "report unused partials" do
|
77
77
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
78
78
|
store = fake_store
|
79
79
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/file"
|
80
|
-
target = [file_path,
|
81
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
82
|
-
tracker.track_views(
|
80
|
+
target = [file_path, "not_used"]
|
81
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir", target: target)
|
82
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
83
83
|
tracker.report_views_tracked
|
84
|
-
assert_equal [
|
84
|
+
assert_equal ["not_used"], tracker.unused_views
|
85
85
|
end
|
86
86
|
|
87
|
-
test
|
87
|
+
test "reset store" do
|
88
88
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
89
89
|
store = fake_store
|
90
90
|
store.raw_store.expects(:del).with(tracker_key)
|
91
|
-
store.raw_store.expects(:del).with(
|
92
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
93
|
-
tracker.track_views(
|
91
|
+
store.raw_store.expects(:del).with("render_tracker_time")
|
92
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
93
|
+
tracker.track_views("name", "start", "finish", "id", identifier: "file")
|
94
94
|
tracker.reset_recordings
|
95
95
|
end
|
96
96
|
|
97
|
-
test
|
97
|
+
test "clear_file" do
|
98
98
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
99
99
|
store = fake_store
|
100
100
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/file"
|
101
101
|
store.raw_store.expects(:hdel).with(tracker_key, file_path)
|
102
|
-
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots:
|
103
|
-
tracker.track_views(
|
104
|
-
tracker.clear_file!(
|
102
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
103
|
+
tracker.track_views("name", "start", "finish", "id", identifier: file_path)
|
104
|
+
tracker.clear_file!("file")
|
105
105
|
assert_equal [], tracker.logged_views
|
106
106
|
end
|
107
107
|
|
108
108
|
protected
|
109
109
|
|
110
110
|
def fake_store
|
111
|
-
@fake_store ||= Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace:
|
111
|
+
@fake_store ||= Coverband::Adapters::RedisStore.new(Coverband::Test.redis, redis_namespace: "coverband_test")
|
112
112
|
end
|
113
113
|
end
|