simplecov 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.rspec +3 -1
- data/.rubocop.yml +6 -5
- data/CHANGELOG.md +16 -2
- data/Gemfile +14 -14
- data/README.md +28 -12
- data/Rakefile +5 -8
- data/features/config_formatters.feature +1 -1
- data/features/config_tracked_files.feature +29 -0
- data/features/step_definitions/transformers.rb +1 -1
- data/features/support/env.rb +6 -3
- data/lib/simplecov.rb +19 -2
- data/lib/simplecov/configuration.rb +24 -4
- data/lib/simplecov/defaults.rb +28 -5
- data/lib/simplecov/file_list.rb +11 -0
- data/lib/simplecov/filter.rb +1 -1
- data/lib/simplecov/formatter/multi_formatter.rb +17 -13
- data/lib/simplecov/result.rb +1 -1
- data/lib/simplecov/source_file.rb +6 -3
- data/lib/simplecov/version.rb +1 -1
- data/spec/1_8_fallbacks_spec.rb +29 -0
- data/spec/command_guesser_spec.rb +46 -0
- data/spec/deleted_source_spec.rb +12 -0
- data/{test → spec}/faked_project/Gemfile +0 -0
- data/{test → spec}/faked_project/Rakefile +0 -0
- data/{test → spec}/faked_project/cucumber.yml +0 -0
- data/{test → spec}/faked_project/features/step_definitions/my_steps.rb +0 -0
- data/{test → spec}/faked_project/features/support/env.rb +0 -0
- data/{test → spec}/faked_project/features/test_stuff.feature +0 -0
- data/{test → spec}/faked_project/lib/faked_project.rb +1 -1
- data/{test → spec}/faked_project/lib/faked_project/framework_specific.rb +0 -0
- data/{test → spec}/faked_project/lib/faked_project/meta_magic.rb +0 -0
- data/{test → spec}/faked_project/lib/faked_project/some_class.rb +0 -0
- data/spec/faked_project/lib/faked_project/untested_class.rb +11 -0
- data/{test → spec}/faked_project/spec/faked_spec.rb +0 -0
- data/{test → spec}/faked_project/spec/forking_spec.rb +0 -0
- data/{test → spec}/faked_project/spec/meta_magic_spec.rb +0 -0
- data/{test → spec}/faked_project/spec/some_class_spec.rb +0 -0
- data/{test → spec}/faked_project/spec/spec_helper.rb +0 -0
- data/{test → spec}/faked_project/test/faked_test.rb +0 -0
- data/{test → spec}/faked_project/test/meta_magic_test.rb +0 -0
- data/{test → spec}/faked_project/test/some_class_test.rb +0 -0
- data/{test → spec}/faked_project/test/test_helper.rb +0 -0
- data/spec/file_list_spec.rb +48 -0
- data/spec/filters_spec.rb +96 -0
- data/{test → spec}/fixtures/app/controllers/sample_controller.rb +0 -0
- data/{test → spec}/fixtures/app/models/user.rb +0 -0
- data/{test → spec}/fixtures/deleted_source_sample.rb +0 -0
- data/{test → spec}/fixtures/frameworks/rspec_bad.rb +0 -0
- data/{test → spec}/fixtures/frameworks/rspec_good.rb +0 -0
- data/{test → spec}/fixtures/frameworks/testunit_bad.rb +0 -0
- data/{test → spec}/fixtures/frameworks/testunit_good.rb +0 -0
- data/{test → spec}/fixtures/iso-8859.rb +0 -0
- data/{test → spec}/fixtures/resultset1.rb +0 -0
- data/{test → spec}/fixtures/resultset2.rb +0 -0
- data/{test → spec}/fixtures/sample.rb +0 -0
- data/{test → spec}/fixtures/utf-8.rb +0 -0
- data/{test → spec}/helper.rb +3 -7
- data/spec/merge_helpers_spec.rb +108 -0
- data/spec/result_spec.rb +207 -0
- data/spec/return_codes_spec.rb +37 -0
- data/spec/source_file_line_spec.rb +153 -0
- data/spec/source_file_spec.rb +75 -0
- metadata +163 -149
- data/test/shoulda_macros.rb +0 -19
- data/test/test_1_8_fallbacks.rb +0 -31
- data/test/test_command_guesser.rb +0 -19
- data/test/test_deleted_source.rb +0 -14
- data/test/test_file_list.rb +0 -23
- data/test/test_filters.rb +0 -94
- data/test/test_merge_helpers.rb +0 -112
- data/test/test_result.rb +0 -175
- data/test/test_return_codes.rb +0 -41
- data/test/test_source_file.rb +0 -73
- data/test/test_source_file_line.rb +0 -106
@@ -0,0 +1,108 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe "merge helpers" do
|
4
|
+
describe "with two faked coverage resultsets" do
|
5
|
+
before do
|
6
|
+
SimpleCov.use_merging true
|
7
|
+
@resultset1 = {
|
8
|
+
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
9
|
+
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
10
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
11
|
+
source_fixture("resultset1.rb") => [1, 1, 1, 1],
|
12
|
+
}
|
13
|
+
|
14
|
+
@resultset2 = {
|
15
|
+
source_fixture("sample.rb") => [1, nil, 1, 1, nil, nil, 1, 1, nil, nil],
|
16
|
+
source_fixture("app/models/user.rb") => [nil, 1, 5, 1, nil, nil, 1, 0, nil, nil],
|
17
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
|
18
|
+
source_fixture("resultset2.rb") => [nil, 1, 1, nil],
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
context "a merge" do
|
23
|
+
subject do
|
24
|
+
@resultset1.merge_resultset(@resultset2)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has proper results for sample.rb" do
|
28
|
+
expect(subject[source_fixture("sample.rb")]).to eq([1, 1, 2, 2, nil, nil, 2, 2, nil, nil])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has proper results for user.rb" do
|
32
|
+
expect(subject[source_fixture("app/models/user.rb")]).to eq([nil, 2, 6, 2, nil, nil, 2, 0, nil, nil])
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has proper results for sample_controller.rb" do
|
36
|
+
expect(subject[source_fixture("app/controllers/sample_controller.rb")]).to eq([nil, 4, 2, 1, nil, nil, 2, 0, nil, nil])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "has proper results for resultset1.rb" do
|
40
|
+
expect(subject[source_fixture("resultset1.rb")]).to eq([1, 1, 1, 1])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has proper results for resultset2.rb" do
|
44
|
+
expect(subject[source_fixture("resultset2.rb")]).to eq([nil, 1, 1, nil])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# See Github issue #6
|
49
|
+
it "returns an empty hash when the resultset cache file is empty" do
|
50
|
+
File.open(SimpleCov::ResultMerger.resultset_path, "w+") { |f| f.puts "" }
|
51
|
+
expect(SimpleCov::ResultMerger.resultset).to be_empty
|
52
|
+
end
|
53
|
+
|
54
|
+
# See Github issue #6
|
55
|
+
it "returns an empty hash when the resultset cache file is not present" do
|
56
|
+
system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
57
|
+
expect(SimpleCov::ResultMerger.resultset).to be_empty
|
58
|
+
end
|
59
|
+
|
60
|
+
context "and results generated from those" do
|
61
|
+
before do
|
62
|
+
system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
63
|
+
@result1 = SimpleCov::Result.new(@resultset1)
|
64
|
+
@result1.command_name = "result1"
|
65
|
+
@result2 = SimpleCov::Result.new(@resultset2)
|
66
|
+
@result2.command_name = "result2"
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with stored results" do
|
70
|
+
before do
|
71
|
+
SimpleCov::ResultMerger.store_result(@result1)
|
72
|
+
SimpleCov::ResultMerger.store_result(@result2)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has stored data in resultset_path JSON file" do
|
76
|
+
expect(File.readlines(SimpleCov::ResultMerger.resultset_path).length).to be > 50
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns a hash containing keys ['result1' and 'result2'] for resultset" do
|
80
|
+
expect(SimpleCov::ResultMerger.resultset.keys.sort).to eq %w(result1 result2)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "returns proper values for merged_result" do
|
84
|
+
expect(SimpleCov::ResultMerger.merged_result.source_files.find { |s| s.filename =~ /user/ }.lines.map(&:coverage)).to eq([nil, 2, 6, 2, nil, nil, 2, 0, nil, nil])
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with second result way above the merge_timeout" do
|
88
|
+
before do
|
89
|
+
@result2.created_at = Time.now - 172_800 # two days ago
|
90
|
+
SimpleCov::ResultMerger.store_result(@result2)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "has only one result in SimpleCov::ResultMerger.results" do
|
94
|
+
expect(SimpleCov::ResultMerger.results.length).to eq(1)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "with merging disabled" do
|
99
|
+
before { SimpleCov.use_merging false }
|
100
|
+
|
101
|
+
it "returns nil for SimpleCov.result" do
|
102
|
+
expect(SimpleCov.result).to be_nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end if SimpleCov.usable?
|
data/spec/result_spec.rb
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe "result" do
|
4
|
+
context "with a (mocked) Coverage.result" do
|
5
|
+
before do
|
6
|
+
@prev_filters = SimpleCov.filters
|
7
|
+
SimpleCov.filters = []
|
8
|
+
@prev_groups = SimpleCov.groups
|
9
|
+
SimpleCov.groups = {}
|
10
|
+
@prev_formatter = SimpleCov.formatter
|
11
|
+
SimpleCov.formatter = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
SimpleCov.filters = @prev_filters
|
16
|
+
SimpleCov.groups = @prev_groups
|
17
|
+
SimpleCov.formatter = @prev_formatter
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:original_result) do
|
21
|
+
{
|
22
|
+
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
23
|
+
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
24
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
context "a simple cov result initialized from that" do
|
29
|
+
subject { SimpleCov::Result.new(original_result) }
|
30
|
+
|
31
|
+
it "has 3 filenames" do
|
32
|
+
expect(subject.filenames.count).to eq(3)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has 3 source files" do
|
36
|
+
expect(subject.source_files.count).to eq(3)
|
37
|
+
subject.source_files.each do |source_file|
|
38
|
+
expect(source_file).to be_a SimpleCov::SourceFile
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns an instance of SimpleCov::FileList for source_files and files" do
|
43
|
+
expect(subject.files).to be_a SimpleCov::FileList
|
44
|
+
expect(subject.source_files).to be_a SimpleCov::FileList
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has files equal to source_files" do
|
48
|
+
expect(subject.files).to eq(subject.source_files)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has accurate covered percent" do
|
52
|
+
# in our fixture, there are 13 covered line (result in 1) in all 15 relevant line (result in non-nil)
|
53
|
+
expect(subject.covered_percent).to eq(86.66666666666667)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "has accurate covered percentages" do
|
57
|
+
expect(subject.covered_percentages).to eq([80.0, 80.0, 100.0])
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has accurate least covered file" do
|
61
|
+
expect(subject.least_covered_file).to match(/sample_controller.rb/)
|
62
|
+
end
|
63
|
+
|
64
|
+
[:covered_percent, :covered_percentages, :least_covered_file, :covered_strength, :covered_lines, :missed_lines, :total_lines].each do |msg|
|
65
|
+
it "responds to #{msg}" do
|
66
|
+
expect(subject).to respond_to(msg)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "dumped with to_hash" do
|
71
|
+
it "is a hash" do
|
72
|
+
expect(subject.to_hash).to be_a Hash
|
73
|
+
end
|
74
|
+
|
75
|
+
context "loaded back with from_hash" do
|
76
|
+
let(:dumped_result) do
|
77
|
+
SimpleCov::Result.from_hash(subject.to_hash)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "has 3 source files" do
|
81
|
+
expect(dumped_result.source_files.count).to eq(subject.source_files.count)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "has the same covered_percent" do
|
85
|
+
expect(dumped_result.covered_percent).to eq(subject.covered_percent)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "has the same covered_percentages" do
|
89
|
+
expect(dumped_result.covered_percentages).to eq(subject.covered_percentages)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has the same timestamp" do
|
93
|
+
expect(dumped_result.created_at.to_i).to eq(subject.created_at.to_i)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "has the same command_name" do
|
97
|
+
expect(dumped_result.command_name).to eq(subject.command_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "has the same original_result" do
|
101
|
+
expect(dumped_result.original_result).to eq(subject.original_result)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context "with some filters set up" do
|
108
|
+
before do
|
109
|
+
SimpleCov.add_filter "sample.rb"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "has 2 files in a new simple cov result" do
|
113
|
+
expect(SimpleCov::Result.new(original_result).source_files.length).to eq(2)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "has 80 covered percent" do
|
117
|
+
expect(SimpleCov::Result.new(original_result).covered_percent).to eq(80)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "has [80.0, 80.0] covered percentages" do
|
121
|
+
expect(SimpleCov::Result.new(original_result).covered_percentages).to eq([80.0, 80.0])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "with groups set up for all files" do
|
126
|
+
before do
|
127
|
+
SimpleCov.add_group "Models", "app/models"
|
128
|
+
SimpleCov.add_group "Controllers", ["app/controllers"]
|
129
|
+
SimpleCov.add_group "Other" do |src_file|
|
130
|
+
File.basename(src_file.filename) == "sample.rb"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
subject do
|
135
|
+
SimpleCov::Result.new(original_result)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "has 3 groups" do
|
139
|
+
expect(subject.groups.length).to eq(3)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "has user.rb in 'Models' group" do
|
143
|
+
expect(File.basename(subject.groups["Models"].first.filename)).to eq("user.rb")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "has sample_controller.rb in 'Controllers' group" do
|
147
|
+
expect(File.basename(subject.groups["Controllers"].first.filename)).to eq("sample_controller.rb")
|
148
|
+
end
|
149
|
+
|
150
|
+
context "and simple formatter being used" do
|
151
|
+
before do
|
152
|
+
SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter
|
153
|
+
end
|
154
|
+
|
155
|
+
it "returns a formatted string with result.format!" do
|
156
|
+
expect(subject.format!).to be_a String
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context "and multi formatter being used" do
|
161
|
+
before do
|
162
|
+
SimpleCov.formatters = [
|
163
|
+
SimpleCov::Formatter::SimpleFormatter,
|
164
|
+
SimpleCov::Formatter::SimpleFormatter,
|
165
|
+
]
|
166
|
+
end
|
167
|
+
|
168
|
+
it "returns an array containing formatted string with result.format!" do
|
169
|
+
formatted = subject.format!
|
170
|
+
expect(formatted.count).to eq(2)
|
171
|
+
expect(formatted.first).to be_a String
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "with groups set up that do not match all files" do
|
177
|
+
before do
|
178
|
+
SimpleCov.configure do
|
179
|
+
add_group "Models", "app/models"
|
180
|
+
add_group "Controllers", "app/controllers"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
subject { SimpleCov::Result.new(original_result) }
|
185
|
+
|
186
|
+
it "has 3 groups" do
|
187
|
+
expect(subject.groups.length).to eq(3)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "has 1 item per group" do
|
191
|
+
subject.groups.each_value do |files|
|
192
|
+
expect(files.length).to eq(1)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'has sample.rb in "Ungrouped" group' do
|
197
|
+
expect(File.basename(subject.groups["Ungrouped"].first.filename)).to eq("sample.rb")
|
198
|
+
end
|
199
|
+
|
200
|
+
it "returns all groups as instances of SimpleCov::FileList" do
|
201
|
+
subject.groups.each_value do |files|
|
202
|
+
expect(files).to be_a SimpleCov::FileList
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end if SimpleCov.usable?
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
# Make sure that exit codes of tests are propagated properly
|
4
|
+
# See https://github.com/colszowka/simplecov/issues/5
|
5
|
+
describe "return codes" do
|
6
|
+
context "inside fixtures/frameworks" do
|
7
|
+
before do
|
8
|
+
@current_dir = Dir.getwd
|
9
|
+
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks"))
|
10
|
+
FileUtils.rm_rf("./coverage")
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
Dir.chdir(@current_dir)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has return code 0 when running testunit_good.rb" do
|
18
|
+
`ruby testunit_good.rb`
|
19
|
+
expect($?.exitstatus).to be_zero
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has return code 0 when running rspec_good.rb" do
|
23
|
+
`rspec rspec_good.rb`
|
24
|
+
expect($?.exitstatus).to be_zero
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has non-0 return code when running testunit_bad.rb" do
|
28
|
+
`ruby testunit_bad.rb`
|
29
|
+
expect($?.exitstatus).not_to be_zero
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has return code 1 when running rspec_bad.rb" do
|
33
|
+
`rspec rspec_bad.rb`
|
34
|
+
expect($?.exitstatus).not_to be_zero
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe SimpleCov::SourceFile::Line do
|
4
|
+
context "a source line" do
|
5
|
+
subject do
|
6
|
+
SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'returns "# the ruby source" as src' do
|
10
|
+
expect(subject.src).to eq("# the ruby source")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns the same for source as for src" do
|
14
|
+
expect(subject.src).to eq(subject.source)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "has line number 5" do
|
18
|
+
expect(subject.line_number).to eq(5)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has equal line_number, line and number" do
|
22
|
+
expect(subject.line).to eq(subject.line_number)
|
23
|
+
expect(subject.number).to eq(subject.line_number)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "flagged as skipped!" do
|
27
|
+
before do
|
28
|
+
subject.skipped!
|
29
|
+
end
|
30
|
+
it "is not covered" do
|
31
|
+
expect(subject).not_to be_covered
|
32
|
+
end
|
33
|
+
|
34
|
+
it "is skipped" do
|
35
|
+
expect(subject).to be_skipped
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is not missed" do
|
39
|
+
expect(subject).not_to be_missed
|
40
|
+
end
|
41
|
+
|
42
|
+
it "is not never" do
|
43
|
+
expect(subject).not_to be_never
|
44
|
+
end
|
45
|
+
|
46
|
+
it "status is skipped" do
|
47
|
+
expect(subject.status).to eq("skipped")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "A source line with coverage" do
|
53
|
+
subject do
|
54
|
+
SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "has coverage of 3" do
|
58
|
+
expect(subject.coverage).to eq(3)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is covered" do
|
62
|
+
expect(subject).to be_covered
|
63
|
+
end
|
64
|
+
|
65
|
+
it "is not skipped" do
|
66
|
+
expect(subject).not_to be_skipped
|
67
|
+
end
|
68
|
+
|
69
|
+
it "is not missed" do
|
70
|
+
expect(subject).not_to be_missed
|
71
|
+
end
|
72
|
+
|
73
|
+
it "is not never" do
|
74
|
+
expect(subject).not_to be_never
|
75
|
+
end
|
76
|
+
|
77
|
+
it "status is covered" do
|
78
|
+
expect(subject.status).to eq("covered")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "A source line without coverage" do
|
83
|
+
subject do
|
84
|
+
SimpleCov::SourceFile::Line.new("# the ruby source", 5, 0)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "has coverage of 0" do
|
88
|
+
expect(subject.coverage).to be_zero
|
89
|
+
end
|
90
|
+
|
91
|
+
it "is not covered" do
|
92
|
+
expect(subject).not_to be_covered
|
93
|
+
end
|
94
|
+
|
95
|
+
it "is not skipped" do
|
96
|
+
expect(subject).not_to be_skipped
|
97
|
+
end
|
98
|
+
|
99
|
+
it "is missed" do
|
100
|
+
expect(subject).to be_missed
|
101
|
+
end
|
102
|
+
|
103
|
+
it "is not never" do
|
104
|
+
expect(subject).not_to be_never
|
105
|
+
end
|
106
|
+
|
107
|
+
it "status is missed" do
|
108
|
+
expect(subject.status).to eq("missed")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "A source line with no code" do
|
113
|
+
subject do
|
114
|
+
SimpleCov::SourceFile::Line.new("# the ruby source", 5, nil)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "has nil coverage" do
|
118
|
+
expect(subject.coverage).to be_nil
|
119
|
+
end
|
120
|
+
|
121
|
+
it "is not covered" do
|
122
|
+
expect(subject).not_to be_covered
|
123
|
+
end
|
124
|
+
|
125
|
+
it "is not skipped" do
|
126
|
+
expect(subject).not_to be_skipped
|
127
|
+
end
|
128
|
+
|
129
|
+
it "is not missed" do
|
130
|
+
expect(subject).not_to be_missed
|
131
|
+
end
|
132
|
+
|
133
|
+
it "is never" do
|
134
|
+
expect(subject).to be_never
|
135
|
+
end
|
136
|
+
|
137
|
+
it "status is never" do
|
138
|
+
expect(subject.status).to eq("never")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
it "raises ArgumentError when initialized with invalid src" do
|
143
|
+
expect { SimpleCov::SourceFile::Line.new(:symbol, 5, 3) }.to raise_error(ArgumentError)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "raises ArgumentError when initialized with invalid line_number" do
|
147
|
+
expect { SimpleCov::SourceFile::Line.new("some source", "five", 3) }.to raise_error(ArgumentError)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "raises ArgumentError when initialized with invalid coverage" do
|
151
|
+
expect { SimpleCov::SourceFile::Line.new("some source", 5, "three") }.to raise_error(ArgumentError)
|
152
|
+
end
|
153
|
+
end if SimpleCov.usable?
|