simplecov 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -7
- data/Gemfile.lock +7 -10
- data/LICENSE +1 -1
- data/README.rdoc +59 -7
- data/Rakefile +15 -27
- data/lib/simplecov.rb +16 -7
- data/lib/simplecov/configuration.rb +1 -0
- data/lib/simplecov/result.rb +1 -1
- data/lib/simplecov/version.rb +3 -0
- data/simplecov.gemspec +20 -101
- data/test/helper.rb +10 -5
- data/test/shoulda_macros.rb +11 -0
- data/test/test_1_8_fallbacks.rb +33 -0
- data/test/test_command_guesser.rb +13 -11
- data/test/test_filters.rb +53 -51
- data/test/test_merge_helpers.rb +76 -74
- data/test/test_result.rb +95 -93
- data/test/test_return_codes.rb +26 -24
- data/test/test_source_file.rb +45 -43
- data/test/test_source_file_line.rb +78 -76
- metadata +15 -26
- data/VERSION +0 -1
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
# Tests that verify that on 1.8 versions of ruby, simplecov simply
|
4
|
+
# does not launch and does not cause errors on the way
|
5
|
+
#
|
6
|
+
# TODO: This should be expanded upon all methods that could potentially
|
7
|
+
# be called in a test/spec-helper simplecov config block
|
8
|
+
#
|
9
|
+
class Test18FallBacks < Test::Unit::TestCase
|
10
|
+
on_ruby '1.8' do
|
11
|
+
should "return false when calling SimpleCov.start" do
|
12
|
+
assert_equal false, SimpleCov.start
|
13
|
+
end
|
14
|
+
|
15
|
+
should "return false when calling SimpleCov.start with a block" do
|
16
|
+
assert_equal false, SimpleCov.start { raise "Shouldn't reach this!?" }
|
17
|
+
end
|
18
|
+
|
19
|
+
should "return false when calling SimpleCov.configure with a block" do
|
20
|
+
assert_equal false, SimpleCov.configure { raise "Shouldn't reach this!?" }
|
21
|
+
end
|
22
|
+
|
23
|
+
should "allow to define an adapter" do
|
24
|
+
begin
|
25
|
+
SimpleCov.adapters.define 'testadapter' do
|
26
|
+
add_filter '/config/'
|
27
|
+
end
|
28
|
+
rescue => err
|
29
|
+
assert false, "Adapter definition should have been fine, but raised #{err}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestCommandGuesser < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
on_ruby '1.9' do
|
5
|
+
def self.should_guess_command_name(expectation, *argv)
|
6
|
+
argv.each do |args|
|
7
|
+
should "return '#{expectation}' for '#{args}'" do
|
8
|
+
assert_equal expectation, SimpleCov::CommandGuesser.guess(args)
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb'
|
14
|
+
should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb'
|
15
|
+
should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb'
|
16
|
+
should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
|
17
|
+
should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
|
18
|
+
should_guess_command_name "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments'
|
19
|
+
end
|
18
20
|
end
|
data/test/test_filters.rb
CHANGED
@@ -1,73 +1,75 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestFilters < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
on_ruby '1.9' do
|
5
|
+
context "A source file initialized with some coverage data" do
|
6
|
+
setup do
|
7
|
+
@source_file = SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
should "pass a new SimpleCov::StringFilter 'foobar'" do
|
11
|
+
assert SimpleCov::StringFilter.new('foobar').passes?(@source_file)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
should "pass a new SimpleCov::StringFilter 'some/path'" do
|
15
|
+
assert SimpleCov::StringFilter.new('some/path').passes?(@source_file)
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
should "not pass a new SimpleCov::StringFilter 'test/fixtures'" do
|
19
|
+
assert !SimpleCov::StringFilter.new('test/fixtures').passes?(@source_file)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
should "not pass a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do
|
23
|
+
assert !SimpleCov::StringFilter.new('test/fixtures/sample.rb').passes?(@source_file)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
should "not pass a new SimpleCov::StringFilter 'sample.rb'" do
|
27
|
+
assert !SimpleCov::StringFilter.new('sample.rb').passes?(@source_file)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
should "pass a new SimpleCov::BlockFilter that is not applicable" do
|
31
|
+
assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).passes?(@source_file)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
should "not pass a new SimpleCov::BlockFilter that is applicable" do
|
35
|
+
assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).passes?(@source_file)
|
36
|
+
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
context "with no filters set up and a basic source file in an array" do
|
40
|
+
setup do
|
41
|
+
SimpleCov.filters = []
|
42
|
+
@files = [SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])]
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
should "return 0 items after executing SimpleCov.filtered on files when using a 'sample' string filter" do
|
46
|
+
SimpleCov.add_filter "sample"
|
47
|
+
assert_equal 0, SimpleCov.filtered(@files).count
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
should "return 0 items after executing SimpleCov.filtered on files when using a 'test/fixtures/' string filter" do
|
51
|
+
SimpleCov.add_filter "test/fixtures"
|
52
|
+
assert_equal 0, SimpleCov.filtered(@files).count
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
should "return 1 item after executing SimpleCov.filtered on files when using a 'fooo' string filter" do
|
56
|
+
SimpleCov.add_filter "fooo"
|
57
|
+
assert_equal 1, SimpleCov.filtered(@files).count
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
should "return 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do
|
61
|
+
SimpleCov.add_filter do |src_file|
|
62
|
+
true
|
63
|
+
end
|
64
|
+
assert_equal 0, SimpleCov.filtered(@files).count
|
62
65
|
end
|
63
|
-
assert_equal 0, SimpleCov.filtered(@files).count
|
64
|
-
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
should "return 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do
|
68
|
+
SimpleCov.add_filter do |src_file|
|
69
|
+
false
|
70
|
+
end
|
71
|
+
assert_equal 1, SimpleCov.filtered(@files).count
|
69
72
|
end
|
70
|
-
assert_equal 1, SimpleCov.filtered(@files).count
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
data/test/test_merge_helpers.rb
CHANGED
@@ -1,105 +1,107 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestMergeHelpers < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
SimpleCov.use_merging true
|
7
|
-
@resultset1 = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
8
|
-
source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
9
|
-
source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
10
|
-
source_fixture('resultset1.rb') => [1, 1, 1, 1]}
|
11
|
-
|
12
|
-
@resultset2 = {source_fixture('sample.rb') => [1, nil, 1, 1, nil, nil, 1, 1, nil, nil],
|
13
|
-
source_fixture('app/models/user.rb') => [nil, 1, 5, 1, nil, nil, 1, 0, nil, nil],
|
14
|
-
source_fixture('app/controllers/sample_controller.rb') => [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
|
15
|
-
source_fixture('resultset2.rb') => [nil, 1, 1, nil]}
|
16
|
-
end
|
17
|
-
|
18
|
-
context "a merge" do
|
4
|
+
on_ruby '1.9' do
|
5
|
+
context "With two faked coverage resultsets" do
|
19
6
|
setup do
|
20
|
-
|
7
|
+
SimpleCov.use_merging true
|
8
|
+
@resultset1 = {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
|
+
@resultset2 = {source_fixture('sample.rb') => [1, nil, 1, 1, nil, nil, 1, 1, nil, nil],
|
14
|
+
source_fixture('app/models/user.rb') => [nil, 1, 5, 1, nil, nil, 1, 0, nil, nil],
|
15
|
+
source_fixture('app/controllers/sample_controller.rb') => [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
|
16
|
+
source_fixture('resultset2.rb') => [nil, 1, 1, nil]}
|
21
17
|
end
|
18
|
+
|
19
|
+
context "a merge" do
|
20
|
+
setup do
|
21
|
+
assert @merged = @resultset1.merge_resultset(@resultset2)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
should "have proper results for sample.rb" do
|
25
|
+
assert_equal [1, 1, 2, 2, nil, nil, 2, 2, nil, nil], @merged[source_fixture('sample.rb')]
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
should "have proper results for user.rb" do
|
29
|
+
assert_equal [nil, 2, 6, 2, nil, nil, 2, 0, nil, nil], @merged[source_fixture('app/models/user.rb')]
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
should "have proper results for sample_controller.rb" do
|
33
|
+
assert_equal [nil, 4, 2, 1, nil, nil, 2, 0, nil, nil], @merged[source_fixture('app/controllers/sample_controller.rb')]
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
should "have proper results for resultset1.rb" do
|
37
|
+
assert_equal [1, 1, 1, 1], @merged[source_fixture('resultset1.rb')]
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
should "have proper results for resultset2.rb" do
|
41
|
+
assert_equal [nil, 1, 1, nil], @merged[source_fixture('resultset2.rb')]
|
42
|
+
end
|
41
43
|
end
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# See Github issue #6
|
46
|
+
should "return an empty hash when the resultset cache file is empty" do
|
47
|
+
File.open(SimpleCov::ResultMerger.resultset_path, "w+") {|f| f.puts ""}
|
48
|
+
assert_equal Hash.new, SimpleCov::ResultMerger.resultset
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
53
|
-
assert_equal Hash.new, SimpleCov::ResultMerger.resultset
|
54
|
-
end
|
55
|
-
|
56
|
-
context "and results generated from those" do
|
57
|
-
setup do
|
51
|
+
# See Github issue #6
|
52
|
+
should "return an empty hash when the resultset cache file is not present" do
|
58
53
|
system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
59
|
-
|
60
|
-
@result1.command_name = "result1"
|
61
|
-
@result2 = SimpleCov::Result.new(@resultset2)
|
62
|
-
@result2.command_name = "result2"
|
54
|
+
assert_equal Hash.new, SimpleCov::ResultMerger.resultset
|
63
55
|
end
|
64
|
-
|
65
|
-
context "
|
56
|
+
|
57
|
+
context "and results generated from those" do
|
66
58
|
setup do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
assert File.readlines(SimpleCov::ResultMerger.resultset_path).length > 50
|
59
|
+
system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
|
60
|
+
@result1 = SimpleCov::Result.new(@resultset1)
|
61
|
+
@result1.command_name = "result1"
|
62
|
+
@result2 = SimpleCov::Result.new(@resultset2)
|
63
|
+
@result2.command_name = "result2"
|
73
64
|
end
|
65
|
+
|
66
|
+
context "with stored results" do
|
67
|
+
setup do
|
68
|
+
assert SimpleCov::ResultMerger.store_result(@result1)
|
69
|
+
assert SimpleCov::ResultMerger.store_result(@result2)
|
70
|
+
end
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
should "have stored data in resultset_path yaml file" do
|
73
|
+
assert File.readlines(SimpleCov::ResultMerger.resultset_path).length > 50
|
74
|
+
end
|
78
75
|
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
should "return a hash containing keys ['result1' and 'result2'] for resultset" do
|
77
|
+
assert_equal ['result1', 'result2'], SimpleCov::ResultMerger.resultset.keys.sort
|
78
|
+
end
|
82
79
|
|
83
|
-
|
84
|
-
|
85
|
-
@result2.created_at = Time.mktime(Time.now.year, Time.now.month, Time.now.day-2)
|
86
|
-
assert SimpleCov::ResultMerger.store_result(@result2)
|
80
|
+
should "return proper values for merged_result" do
|
81
|
+
assert_equal [nil, 2, 6, 2, nil, nil, 2, 0, nil, nil], SimpleCov::ResultMerger.merged_result.source_files.find {|s| s.filename =~ /user/}.lines.map(&:coverage)
|
87
82
|
end
|
83
|
+
|
84
|
+
context "with second result way above the merge_timeout" do
|
85
|
+
setup do
|
86
|
+
@result2.created_at = Time.mktime(Time.now.year, Time.now.month, Time.now.day-2)
|
87
|
+
assert SimpleCov::ResultMerger.store_result(@result2)
|
88
|
+
end
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
should "have only one result in SimpleCov::ResultMerger.results" do
|
91
|
+
assert_equal 1, SimpleCov::ResultMerger.results.length
|
92
|
+
end
|
91
93
|
end
|
92
|
-
end
|
93
94
|
|
94
|
-
|
95
|
-
|
95
|
+
context "with merging disabled" do
|
96
|
+
setup { SimpleCov.use_merging false }
|
96
97
|
|
97
|
-
|
98
|
-
|
98
|
+
should "return nil for SimpleCov.result" do
|
99
|
+
assert_nil SimpleCov.result
|
100
|
+
end
|
99
101
|
end
|
100
102
|
end
|
101
|
-
end
|
102
103
|
|
104
|
+
end
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
data/test/test_result.rb
CHANGED
@@ -1,133 +1,135 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestResult < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
on_ruby "1.9" do
|
5
|
+
context "With a (mocked) Coverage.result" do
|
6
|
+
setup do
|
7
|
+
SimpleCov.filters = []
|
8
|
+
SimpleCov.groups = {}
|
9
|
+
SimpleCov.formatter = nil
|
10
|
+
@original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
11
|
+
source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
12
|
+
source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]}
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
context "a simple cov result initialized from that" do
|
16
|
+
setup { @result = SimpleCov::Result.new(@original_result) }
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
should "have 3 filenames" do
|
19
|
+
assert_equal 3, @result.filenames.count
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
should "have 3 source files" do
|
23
|
+
assert_equal 3, @result.source_files.count
|
24
|
+
assert @result.source_files.all? {|s| s.instance_of?(SimpleCov::SourceFile)}, "Not alL instances are of SimpleCov::SourceFile type"
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
should "have files equal to source_files" do
|
28
|
+
assert_equal @result.files, @result.source_files
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
should "have accurate covered percent" do
|
32
|
+
# in our fixture, there are 13 covered line (result in 1) in all 15 relevant line (result in non-nil)
|
33
|
+
assert_equal 100.0*13/15, @result.covered_percent
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
context "dumped with to_yaml" do
|
37
|
+
setup { @yaml = @result.to_yaml }
|
38
|
+
should("be a string") { assert_equal String, @yaml.class }
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
context "loaded back with from_yaml" do
|
41
|
+
setup { @dumped_result = SimpleCov::Result.from_yaml(@yaml) }
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
should "have 3 source files" do
|
44
|
+
assert_equal @result.source_files.count, @dumped_result.source_files.count
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
should "have the same covered_percent" do
|
48
|
+
assert_equal @result.covered_percent, @dumped_result.covered_percent
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
should "have the same created_at" do
|
52
|
+
assert_equal @result.created_at, @dumped_result.created_at
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
should "have the same command_name" do
|
56
|
+
assert_equal @result.command_name, @dumped_result.command_name
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
should "have the same original_result" do
|
60
|
+
assert_equal @result.original_result, @dumped_result.original_result
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
context "with some filters set up" do
|
67
|
+
setup do
|
68
|
+
SimpleCov.add_filter 'sample.rb'
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
should "have 2 files in a new simple cov result" do
|
72
|
+
assert_equal 2, SimpleCov::Result.new(@original_result).source_files.length
|
73
|
+
end
|
73
74
|
|
74
|
-
|
75
|
-
|
75
|
+
should "have 80 covered percent" do
|
76
|
+
assert_equal 80, SimpleCov::Result.new(@original_result).covered_percent
|
77
|
+
end
|
76
78
|
end
|
77
|
-
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
context "with groups set up for all files" do
|
81
|
+
setup do
|
82
|
+
SimpleCov.add_group 'Models', 'app/models'
|
83
|
+
SimpleCov.add_group 'Controllers', 'app/controllers'
|
84
|
+
SimpleCov.add_group 'Other' do |src_file|
|
85
|
+
File.basename(src_file.filename) == 'sample.rb'
|
86
|
+
end
|
87
|
+
@result = SimpleCov::Result.new(@original_result)
|
85
88
|
end
|
86
|
-
@result = SimpleCov::Result.new(@original_result)
|
87
|
-
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
should "have 3 groups" do
|
91
|
+
assert_equal 3, @result.groups.length
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
should "have user.rb in 'Models' group" do
|
95
|
+
assert_equal 'user.rb', File.basename(@result.groups['Models'].first.filename)
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
should "have sample_controller.rb in 'Controllers' group" do
|
99
|
+
assert_equal 'sample_controller.rb', File.basename(@result.groups['Controllers'].first.filename)
|
100
|
+
end
|
100
101
|
|
101
|
-
|
102
|
-
|
102
|
+
context "and simple formatter being used" do
|
103
|
+
setup {SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter}
|
103
104
|
|
104
|
-
|
105
|
-
|
105
|
+
should "return a formatted string with result.format!" do
|
106
|
+
assert_equal String, @result.format!.class
|
107
|
+
end
|
106
108
|
end
|
107
109
|
end
|
108
|
-
end
|
109
110
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
context "with groups set up that do not match all files" do
|
112
|
+
setup do
|
113
|
+
SimpleCov.configure do
|
114
|
+
add_group 'Models', 'app/models'
|
115
|
+
add_group 'Controllers', 'app/controllers'
|
116
|
+
end
|
117
|
+
@result = SimpleCov::Result.new(@original_result)
|
115
118
|
end
|
116
|
-
@result = SimpleCov::Result.new(@original_result)
|
117
|
-
end
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
should "have 3 groups" do
|
121
|
+
assert_equal 3, @result.groups.length
|
122
|
+
end
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
should "have 1 item per group" do
|
125
|
+
@result.groups.each do |name, files|
|
126
|
+
assert_equal 1, files.length, "Group #{name} should have 1 file"
|
127
|
+
end
|
126
128
|
end
|
127
|
-
end
|
128
129
|
|
129
|
-
|
130
|
-
|
130
|
+
should "have sample.rb in 'Ungrouped' group" do
|
131
|
+
assert_equal 'sample.rb', File.basename(@result.groups['Ungrouped'].first.filename)
|
132
|
+
end
|
131
133
|
end
|
132
134
|
end
|
133
135
|
end
|