simplecov 0.3.7 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- def self.should_guess_command_name(expectation, *argv)
5
- argv.each do |args|
6
- should "return '#{expectation}' for '#{args}'" do
7
- assert_equal expectation, SimpleCov::CommandGuesser.guess(args)
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
- should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb'
13
- should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb'
14
- should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb'
15
- should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
16
- should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
17
- should_guess_command_name "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments'
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
- context "A source file initialized with some coverage data" do
5
- setup do
6
- @source_file = SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])
7
- end
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
- should "pass a new SimpleCov::StringFilter 'foobar'" do
10
- assert SimpleCov::StringFilter.new('foobar').passes?(@source_file)
11
- end
10
+ should "pass a new SimpleCov::StringFilter 'foobar'" do
11
+ assert SimpleCov::StringFilter.new('foobar').passes?(@source_file)
12
+ end
12
13
 
13
- should "pass a new SimpleCov::StringFilter 'some/path'" do
14
- assert SimpleCov::StringFilter.new('some/path').passes?(@source_file)
15
- end
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
- should "not pass a new SimpleCov::StringFilter 'test/fixtures'" do
18
- assert !SimpleCov::StringFilter.new('test/fixtures').passes?(@source_file)
19
- end
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
- should "not pass a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do
22
- assert !SimpleCov::StringFilter.new('test/fixtures/sample.rb').passes?(@source_file)
23
- end
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
- should "not pass a new SimpleCov::StringFilter 'sample.rb'" do
26
- assert !SimpleCov::StringFilter.new('sample.rb').passes?(@source_file)
27
- end
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
- should "pass a new SimpleCov::BlockFilter that is not applicable" do
30
- assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).passes?(@source_file)
31
- end
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
- should "not pass a new SimpleCov::BlockFilter that is applicable" do
34
- assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).passes?(@source_file)
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
- context "with no filters set up and a basic source file in an array" do
39
- setup do
40
- SimpleCov.filters = []
41
- @files = [SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])]
42
- end
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
- should "return 0 items after executing SimpleCov.filtered on files when using a 'sample' string filter" do
45
- SimpleCov.add_filter "sample"
46
- assert_equal 0, SimpleCov.filtered(@files).count
47
- end
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
- should "return 0 items after executing SimpleCov.filtered on files when using a 'test/fixtures/' string filter" do
50
- SimpleCov.add_filter "test/fixtures"
51
- assert_equal 0, SimpleCov.filtered(@files).count
52
- end
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
- should "return 1 item after executing SimpleCov.filtered on files when using a 'fooo' string filter" do
55
- SimpleCov.add_filter "fooo"
56
- assert_equal 1, SimpleCov.filtered(@files).count
57
- end
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
- should "return 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do
60
- SimpleCov.add_filter do |src_file|
61
- true
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
- should "return 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do
67
- SimpleCov.add_filter do |src_file|
68
- false
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
@@ -1,105 +1,107 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestMergeHelpers < Test::Unit::TestCase
4
- context "With two faked coverage resultsets" do
5
- setup do
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
- assert @merged = @resultset1.merge_resultset(@resultset2)
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
- should "have proper results for sample.rb" do
24
- assert_equal [1, 1, 2, 2, nil, nil, 2, 2, nil, nil], @merged[source_fixture('sample.rb')]
25
- end
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
- should "have proper results for user.rb" do
28
- assert_equal [nil, 2, 6, 2, nil, nil, 2, 0, nil, nil], @merged[source_fixture('app/models/user.rb')]
29
- end
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
- should "have proper results for sample_controller.rb" do
32
- assert_equal [nil, 4, 2, 1, nil, nil, 2, 0, nil, nil], @merged[source_fixture('app/controllers/sample_controller.rb')]
33
- end
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
- should "have proper results for resultset1.rb" do
36
- assert_equal [1, 1, 1, 1], @merged[source_fixture('resultset1.rb')]
37
- end
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
- should "have proper results for resultset2.rb" do
40
- assert_equal [nil, 1, 1, nil], @merged[source_fixture('resultset2.rb')]
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
- # See Github issue #6
45
- should "return an empty hash when the resultset cache file is empty" do
46
- File.open(SimpleCov::ResultMerger.resultset_path, "w+") {|f| f.puts ""}
47
- assert_equal Hash.new, SimpleCov::ResultMerger.resultset
48
- end
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
- # See Github issue #6
51
- should "return an empty hash when the resultset cache file is not present" do
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
- @result1 = SimpleCov::Result.new(@resultset1)
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 "with stored results" do
56
+
57
+ context "and results generated from those" do
66
58
  setup do
67
- assert SimpleCov::ResultMerger.store_result(@result1)
68
- assert SimpleCov::ResultMerger.store_result(@result2)
69
- end
70
-
71
- should "have stored data in resultset_path yaml file" do
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
- should "return a hash containing keys ['result1' and 'result2'] for resultset" do
76
- assert_equal ['result1', 'result2'], SimpleCov::ResultMerger.resultset.keys.sort
77
- end
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
- should "return proper values for merged_result" do
80
- 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)
81
- end
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
- context "with second result way above the merge_timeout" do
84
- setup do
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
- should "have only one result in SimpleCov::ResultMerger.results" do
90
- assert_equal 1, SimpleCov::ResultMerger.results.length
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
- context "with merging disabled" do
95
- setup { SimpleCov.use_merging false }
95
+ context "with merging disabled" do
96
+ setup { SimpleCov.use_merging false }
96
97
 
97
- should "return nil for SimpleCov.result" do
98
- assert_nil SimpleCov.result
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
- context "With a (mocked) Coverage.result" do
5
- setup do
6
- SimpleCov.filters = []
7
- SimpleCov.groups = {}
8
- SimpleCov.formatter = nil
9
- @original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
10
- source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
11
- source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]}
12
- end
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
- context "a simple cov result initialized from that" do
15
- setup { @result = SimpleCov::Result.new(@original_result) }
15
+ context "a simple cov result initialized from that" do
16
+ setup { @result = SimpleCov::Result.new(@original_result) }
16
17
 
17
- should "have 3 filenames" do
18
- assert_equal 3, @result.filenames.count
19
- end
18
+ should "have 3 filenames" do
19
+ assert_equal 3, @result.filenames.count
20
+ end
20
21
 
21
- should "have 3 source files" do
22
- assert_equal 3, @result.source_files.count
23
- assert @result.source_files.all? {|s| s.instance_of?(SimpleCov::SourceFile)}, "Not alL instances are of SimpleCov::SourceFile type"
24
- end
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
- should "have files equal to source_files" do
27
- assert_equal @result.files, @result.source_files
28
- end
27
+ should "have files equal to source_files" do
28
+ assert_equal @result.files, @result.source_files
29
+ end
29
30
 
30
- should "have accurate covered percent" do
31
- # in our fixture, there are 13 covered line (result in 1) in all 15 relevant line (result in non-nil)
32
- assert_equal 100.0*13/15, @result.covered_percent
33
- end
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
- context "dumped with to_yaml" do
36
- setup { @yaml = @result.to_yaml }
37
- should("be a string") { assert_equal String, @yaml.class }
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
- context "loaded back with from_yaml" do
40
- setup { @dumped_result = SimpleCov::Result.from_yaml(@yaml) }
40
+ context "loaded back with from_yaml" do
41
+ setup { @dumped_result = SimpleCov::Result.from_yaml(@yaml) }
41
42
 
42
- should "have 3 source files" do
43
- assert_equal @result.source_files.count, @dumped_result.source_files.count
44
- end
43
+ should "have 3 source files" do
44
+ assert_equal @result.source_files.count, @dumped_result.source_files.count
45
+ end
45
46
 
46
- should "have the same covered_percent" do
47
- assert_equal @result.covered_percent, @dumped_result.covered_percent
48
- end
47
+ should "have the same covered_percent" do
48
+ assert_equal @result.covered_percent, @dumped_result.covered_percent
49
+ end
49
50
 
50
- should "have the same created_at" do
51
- assert_equal @result.created_at, @dumped_result.created_at
52
- end
51
+ should "have the same created_at" do
52
+ assert_equal @result.created_at, @dumped_result.created_at
53
+ end
53
54
 
54
- should "have the same command_name" do
55
- assert_equal @result.command_name, @dumped_result.command_name
56
- end
55
+ should "have the same command_name" do
56
+ assert_equal @result.command_name, @dumped_result.command_name
57
+ end
57
58
 
58
- should "have the same original_result" do
59
- assert_equal @result.original_result, @dumped_result.original_result
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
- context "with some filters set up" do
66
- setup do
67
- SimpleCov.add_filter 'sample.rb'
68
- end
66
+ context "with some filters set up" do
67
+ setup do
68
+ SimpleCov.add_filter 'sample.rb'
69
+ end
69
70
 
70
- should "have 2 files in a new simple cov result" do
71
- assert_equal 2, SimpleCov::Result.new(@original_result).source_files.length
72
- end
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
- should "have 80 covered percent" do
75
- assert_equal 80, SimpleCov::Result.new(@original_result).covered_percent
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
- context "with groups set up for all files" do
80
- setup do
81
- SimpleCov.add_group 'Models', 'app/models'
82
- SimpleCov.add_group 'Controllers', 'app/controllers'
83
- SimpleCov.add_group 'Other' do |src_file|
84
- File.basename(src_file.filename) == 'sample.rb'
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
- should "have 3 groups" do
90
- assert_equal 3, @result.groups.length
91
- end
90
+ should "have 3 groups" do
91
+ assert_equal 3, @result.groups.length
92
+ end
92
93
 
93
- should "have user.rb in 'Models' group" do
94
- assert_equal 'user.rb', File.basename(@result.groups['Models'].first.filename)
95
- end
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
- should "have sample_controller.rb in 'Controllers' group" do
98
- assert_equal 'sample_controller.rb', File.basename(@result.groups['Controllers'].first.filename)
99
- end
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
- context "and simple formatter being used" do
102
- setup {SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter}
102
+ context "and simple formatter being used" do
103
+ setup {SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter}
103
104
 
104
- should "return a formatted string with result.format!" do
105
- assert_equal String, @result.format!.class
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
- context "with groups set up that do not match all files" do
111
- setup do
112
- SimpleCov.configure do
113
- add_group 'Models', 'app/models'
114
- add_group 'Controllers', 'app/controllers'
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
- should "have 3 groups" do
120
- assert_equal 3, @result.groups.length
121
- end
120
+ should "have 3 groups" do
121
+ assert_equal 3, @result.groups.length
122
+ end
122
123
 
123
- should "have 1 item per group" do
124
- @result.groups.each do |name, files|
125
- assert_equal 1, files.length, "Group #{name} should have 1 file"
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
- should "have sample.rb in 'Ungrouped' group" do
130
- assert_equal 'sample.rb', File.basename(@result.groups['Ungrouped'].first.filename)
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