coverband 4.2.6 → 5.0.0.rc.5
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 +24 -77
- data/Rakefile +17 -17
- data/changes.md +30 -28
- data/config.ru +1 -1
- data/coverband.gemspec +31 -34
- data/lib/alternative_coverband_patch.rb +5 -0
- 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 +150 -113
- data/lib/coverband/integrations/background.rb +6 -6
- data/lib/coverband/integrations/rack_server_check.rb +3 -3
- data/lib/coverband/integrations/resque.rb +13 -1
- 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 +61 -48
- 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 +29 -34
- 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,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
|
@@ -1,34 +1,34 @@
|
|
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
|
7
7
|
# initial version of test pulled into Coverband from Simplecov 12/17/2018
|
8
8
|
####
|
9
9
|
describe Coverband::Utils::LinesClassifier do
|
10
|
-
describe
|
10
|
+
describe "#classify" do
|
11
11
|
def subject
|
12
12
|
Coverband::Utils::LinesClassifier.new
|
13
13
|
end
|
14
14
|
|
15
|
-
describe
|
16
|
-
it
|
15
|
+
describe "relevant lines" do
|
16
|
+
it "determines code as relevant" do
|
17
17
|
classified_lines = subject.classify [
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
"module Foo",
|
19
|
+
" class Baz",
|
20
|
+
" def Bar",
|
21
21
|
" puts 'hi'",
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
" end",
|
23
|
+
" end",
|
24
|
+
"end"
|
25
25
|
]
|
26
26
|
|
27
27
|
assert_equal 7, classified_lines.length
|
28
28
|
assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::RELEVANT })
|
29
29
|
end
|
30
30
|
|
31
|
-
it
|
31
|
+
it "determines invalid UTF-8 byte sequences as relevant" do
|
32
32
|
classified_lines = subject.classify [
|
33
33
|
"bytes = \"\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\""
|
34
34
|
]
|
@@ -38,11 +38,11 @@ describe Coverband::Utils::LinesClassifier do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
it
|
41
|
+
describe "not-relevant lines" do
|
42
|
+
it "determines whitespace is not-relevant" do
|
43
43
|
classified_lines = subject.classify [
|
44
|
-
|
45
|
-
|
44
|
+
"",
|
45
|
+
" ",
|
46
46
|
"\t\t"
|
47
47
|
]
|
48
48
|
|
@@ -50,11 +50,11 @@ describe Coverband::Utils::LinesClassifier do
|
|
50
50
|
assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::NOT_RELEVANT })
|
51
51
|
end
|
52
52
|
|
53
|
-
describe
|
54
|
-
it
|
53
|
+
describe "comments" do
|
54
|
+
it "determines comments are not-relevant" do
|
55
55
|
classified_lines = subject.classify [
|
56
|
-
|
57
|
-
|
56
|
+
"#Comment",
|
57
|
+
" # Leading space comment",
|
58
58
|
"\t# Leading tab comment"
|
59
59
|
]
|
60
60
|
|
@@ -72,27 +72,27 @@ describe Coverband::Utils::LinesClassifier do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
75
|
+
describe ":nocov: blocks" do
|
76
|
+
it "determines :nocov: blocks are not-relevant" do
|
77
77
|
classified_lines = subject.classify [
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
"# :nocov:",
|
79
|
+
"def hi",
|
80
|
+
"end",
|
81
|
+
"# :nocov:"
|
82
82
|
]
|
83
83
|
|
84
84
|
assert_equal 4, classified_lines.length
|
85
85
|
assert(classified_lines.all? { |line| line == Coverband::Utils::LinesClassifier::NOT_RELEVANT })
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "determines all lines after a non-closing :nocov: as not-relevant" do
|
89
89
|
classified_lines = subject.classify [
|
90
|
-
|
90
|
+
"# :nocov:",
|
91
91
|
"puts 'Not relevant'",
|
92
|
-
|
92
|
+
"# :nocov:",
|
93
93
|
"puts 'Relevant again'",
|
94
94
|
"puts 'Still relevant'",
|
95
|
-
|
95
|
+
"# :nocov:",
|
96
96
|
"puts 'Not relevant till the end'",
|
97
97
|
"puts 'Ditto'"
|
98
98
|
]
|
@@ -1,38 +1,38 @@
|
|
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 RelativeFileConverterTest < ::Minitest::Test
|
8
8
|
def test_convert
|
9
|
-
converter = RelativeFileConverter.new([
|
10
|
-
assert_equal(
|
9
|
+
converter = RelativeFileConverter.new(["/bar/tmp/"])
|
10
|
+
assert_equal("./gracie.rb", converter.convert("/bar/tmp/gracie.rb"))
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_convert_without_leading_forward_slash
|
14
|
-
converter = RelativeFileConverter.new([
|
15
|
-
assert_equal(
|
14
|
+
converter = RelativeFileConverter.new(["/foo/bar"])
|
15
|
+
assert_equal("./file.rb", converter.convert("/foo/bar/file.rb"))
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_multiple_roots
|
19
|
-
converter = RelativeFileConverter.new([
|
20
|
-
assert_equal(
|
19
|
+
converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
|
20
|
+
assert_equal("./josie.rb", converter.convert("/foo/bar/josie.rb"))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_no_match
|
24
|
-
converter = RelativeFileConverter.new([
|
25
|
-
assert_equal(
|
24
|
+
converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
|
25
|
+
assert_equal("/foo/josie.rb", converter.convert("/foo/josie.rb"))
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_middle_path_match
|
29
|
-
converter = RelativeFileConverter.new([
|
30
|
-
assert_equal(
|
29
|
+
converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
|
30
|
+
assert_equal("/tmp/foo/bar/josie.rb", converter.convert("/tmp/foo/bar/josie.rb"))
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_already_relative_file
|
34
|
-
converter = RelativeFileConverter.new([
|
35
|
-
assert_equal(
|
34
|
+
converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
|
35
|
+
assert_equal("./foo/bar/josie.rb", converter.convert("./foo/bar/josie.rb"))
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,59 +1,59 @@
|
|
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
|
7
7
|
# initial version of test pulled into Coverband from Simplecov 12/19/2018
|
8
8
|
####
|
9
|
-
describe
|
10
|
-
describe
|
9
|
+
describe "result" do
|
10
|
+
describe "with a (mocked) Coverage.result" do
|
11
11
|
let(:original_result) do
|
12
12
|
{
|
13
|
-
source_fixture(
|
14
|
-
source_fixture(
|
15
|
-
source_fixture(
|
13
|
+
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
14
|
+
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
15
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe "a simple cov result initialized from that" do
|
20
20
|
subject { Coverband::Utils::Result.new(original_result) }
|
21
21
|
|
22
|
-
it
|
22
|
+
it "has 3 filenames" do
|
23
23
|
assert_equal 3, subject.filenames.count
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it "has 3 source files" do
|
27
27
|
assert_equal 3, subject.source_files.count
|
28
28
|
subject.source_files.each do |source_file|
|
29
29
|
assert source_file.is_a?(Coverband::Utils::SourceFile)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it "returns an instance of Coverband::Utils::FileList for source_files and files" do
|
34
34
|
assert subject.files.is_a?(Coverband::Utils::FileList)
|
35
35
|
assert subject.source_files.is_a?(Coverband::Utils::FileList)
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it "has files equal to source_files" do
|
39
39
|
assert_equal subject.source_files, subject.files
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it "has accurate covered percent" do
|
43
43
|
# in our fixture, there are 13 covered line (result in 1) in all 15 relevant line (result in non-nil)
|
44
44
|
assert_equal 86.66666666666667, subject.covered_percent
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
47
|
+
it "has accurate covered percentages" do
|
48
48
|
assert_equal [80.0, 80.0, 100.0], subject.covered_percentages
|
49
49
|
end
|
50
50
|
|
51
51
|
%i[covered_percent
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
covered_percentages
|
53
|
+
covered_strength
|
54
|
+
covered_lines
|
55
|
+
missed_lines
|
56
|
+
total_lines].each do |msg|
|
57
57
|
it "responds to #{msg}" do
|
58
58
|
assert(subject.respond_to?(msg))
|
59
59
|
end
|
@@ -1,52 +1,52 @@
|
|
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
|
-
describe
|
6
|
-
describe
|
7
|
-
let(:source_file) { Coverband::Utils::SourceFile.new(source_fixture(
|
5
|
+
describe "results" do
|
6
|
+
describe "with a (mocked) Coverage.result" do
|
7
|
+
let(:source_file) { Coverband::Utils::SourceFile.new(source_fixture("app/models/user.rb"), run_lines) }
|
8
8
|
let(:eager_lines) { [nil, 1, 1, 0, nil, nil, 1, 0, nil, nil] }
|
9
|
-
let(:run_lines) { [nil, nil, nil, 1, nil, nil, nil,nil, nil, nil] }
|
9
|
+
let(:run_lines) { [nil, nil, nil, 1, nil, nil, nil, nil, nil, nil] }
|
10
10
|
let(:original_result) do
|
11
11
|
orig = {
|
12
|
-
Coverband::MERGED_TYPE => {source_fixture(
|
12
|
+
Coverband::MERGED_TYPE => {source_fixture("app/models/user.rb") => eager_lines}
|
13
13
|
}
|
14
|
-
orig
|
15
|
-
orig
|
14
|
+
orig[Coverband::EAGER_TYPE] = {source_fixture("app/models/user.rb") => eager_lines} if eager_lines
|
15
|
+
orig[Coverband::RUNTIME_TYPE] = {source_fixture("app/models/user.rb") => run_lines} if run_lines
|
16
16
|
orig
|
17
17
|
end
|
18
18
|
subject { Coverband::Utils::Results.new(original_result) }
|
19
19
|
|
20
|
-
describe
|
21
|
-
it
|
20
|
+
describe "runtime relevant lines is supported" do
|
21
|
+
it "has correct runtime relevant coverage" do
|
22
22
|
assert_equal 50.0, subject.runtime_relevant_coverage(source_file)
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "has correct runtime relevant lines" do
|
26
26
|
assert_equal 2, subject.runtime_relavent_lines(source_file)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
30
|
+
describe "runtime relevant lines when no runtime coverage exists" do
|
31
31
|
let(:run_lines) { nil }
|
32
32
|
|
33
|
-
it
|
33
|
+
it "has correct runtime relevant lines" do
|
34
34
|
assert_equal 0.0, subject.runtime_relevant_coverage(source_file)
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it "has correct runtime relevant lines" do
|
38
38
|
assert_equal 2, subject.runtime_relavent_lines(source_file)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
42
|
+
describe "runtime relevant lines when no eager coverage exists" do
|
43
43
|
let(:eager_lines) { nil }
|
44
44
|
|
45
|
-
it
|
45
|
+
it "has correct runtime relevant lines" do
|
46
46
|
assert_equal 100.0, subject.runtime_relevant_coverage(source_file)
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
49
|
+
it "has correct runtime relevant lines" do
|
50
50
|
assert_equal 1, subject.runtime_relavent_lines(source_file)
|
51
51
|
end
|
52
52
|
end
|
@@ -1,165 +1,165 @@
|
|
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
|
7
7
|
# initial version of test pulled into Coverband from Simplecov 12/19/2018
|
8
8
|
####
|
9
9
|
describe Coverband::Utils::SourceFile::Line do
|
10
|
-
describe
|
10
|
+
describe "a source line" do
|
11
11
|
subject do
|
12
|
-
Coverband::Utils::SourceFile::Line.new(
|
12
|
+
Coverband::Utils::SourceFile::Line.new("# the ruby source", 5, 3)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'returns "# the ruby source" as src' do
|
16
|
-
assert_equal
|
16
|
+
assert_equal "# the ruby source", subject.src
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it "returns the same for source as for src" do
|
20
20
|
assert_equal subject.src, subject.source
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it "has line number 5" do
|
24
24
|
assert_equal 5, subject.line_number
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it "has equal line_number, line and number" do
|
28
28
|
assert_equal subject.line, subject.line_number
|
29
29
|
assert_equal subject.number, subject.line_number
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
32
|
+
describe "flagged as skipped!" do
|
33
33
|
before do
|
34
34
|
subject.skipped!
|
35
35
|
end
|
36
|
-
it
|
36
|
+
it "is not covered" do
|
37
37
|
refute subject.covered?
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it "is skipped" do
|
41
41
|
assert subject.skipped?
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "is not missed" do
|
45
45
|
refute subject.missed?
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it "is not never" do
|
49
49
|
refute subject.never?
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
assert_equal
|
52
|
+
it "status is skipped" do
|
53
|
+
assert_equal "skipped", subject.status
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe
|
58
|
+
describe "A source line with coverage" do
|
59
59
|
subject do
|
60
|
-
Coverband::Utils::SourceFile::Line.new(
|
60
|
+
Coverband::Utils::SourceFile::Line.new("# the ruby source", 5, 3)
|
61
61
|
end
|
62
62
|
|
63
|
-
it
|
63
|
+
it "has coverage of 3" do
|
64
64
|
assert_equal 3, subject.coverage
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it "is covered" do
|
68
68
|
assert subject.covered?
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
71
|
+
it "is not skipped" do
|
72
72
|
refute subject.skipped?
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
75
|
+
it "is not missed" do
|
76
76
|
refute subject.missed?
|
77
77
|
end
|
78
78
|
|
79
|
-
it
|
79
|
+
it "is not never" do
|
80
80
|
refute subject.never?
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
84
|
-
assert_equal
|
83
|
+
it "status is covered" do
|
84
|
+
assert_equal "covered", subject.status
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
88
|
+
describe "A source line without coverage" do
|
89
89
|
subject do
|
90
|
-
Coverband::Utils::SourceFile::Line.new(
|
90
|
+
Coverband::Utils::SourceFile::Line.new("# the ruby source", 5, 0)
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
93
|
+
it "has coverage of 0" do
|
94
94
|
assert_equal 0, subject.coverage
|
95
95
|
end
|
96
96
|
|
97
|
-
it
|
97
|
+
it "is not covered" do
|
98
98
|
refute subject.covered?
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
101
|
+
it "is not skipped" do
|
102
102
|
refute subject.skipped?
|
103
103
|
end
|
104
104
|
|
105
|
-
it
|
105
|
+
it "is missed" do
|
106
106
|
assert subject.missed?
|
107
107
|
end
|
108
108
|
|
109
|
-
it
|
109
|
+
it "is not never" do
|
110
110
|
refute subject.never?
|
111
111
|
end
|
112
112
|
|
113
|
-
it
|
114
|
-
assert_equal
|
113
|
+
it "status is missed" do
|
114
|
+
assert_equal "missed", subject.status
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
describe
|
118
|
+
describe "A source line with no code" do
|
119
119
|
subject do
|
120
|
-
Coverband::Utils::SourceFile::Line.new(
|
120
|
+
Coverband::Utils::SourceFile::Line.new("# the ruby source", 5, nil)
|
121
121
|
end
|
122
122
|
|
123
|
-
it
|
123
|
+
it "has nil coverage" do
|
124
124
|
assert_nil subject.coverage
|
125
125
|
end
|
126
126
|
|
127
|
-
it
|
127
|
+
it "is not covered" do
|
128
128
|
refute subject.covered?
|
129
129
|
end
|
130
130
|
|
131
|
-
it
|
131
|
+
it "is not skipped" do
|
132
132
|
refute subject.skipped?
|
133
133
|
end
|
134
134
|
|
135
|
-
it
|
135
|
+
it "is not missed" do
|
136
136
|
refute subject.missed?
|
137
137
|
end
|
138
138
|
|
139
|
-
it
|
139
|
+
it "is never" do
|
140
140
|
assert subject.never?
|
141
141
|
end
|
142
142
|
|
143
|
-
it
|
144
|
-
assert_equal
|
143
|
+
it "status is never" do
|
144
|
+
assert_equal "never", subject.status
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
it
|
148
|
+
it "raises ArgumentError when initialized with invalid src" do
|
149
149
|
assert_raises ArgumentError do
|
150
150
|
Coverband::Utils::SourceFile::Line.new(:symbol, 5, 3)
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
154
|
+
it "raises ArgumentError when initialized with invalid line_number" do
|
155
155
|
assert_raises ArgumentError do
|
156
|
-
Coverband::Utils::SourceFile::Line.new(
|
156
|
+
Coverband::Utils::SourceFile::Line.new("some source", "five", 3)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
|
-
it
|
160
|
+
it "raises ArgumentError when initialized with invalid coverage" do
|
161
161
|
assert_raises ArgumentError do
|
162
|
-
Coverband::Utils::SourceFile::Line.new(
|
162
|
+
Coverband::Utils::SourceFile::Line.new("some source", 5, "three")
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|