simplecov 0.6.4 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +378 -12
  3. data/CONTRIBUTING.md +51 -0
  4. data/ISSUE_TEMPLATE.md +23 -0
  5. data/LICENSE +1 -1
  6. data/README.md +456 -252
  7. data/doc/alternate-formatters.md +56 -0
  8. data/doc/commercial-services.md +20 -0
  9. data/doc/editor-integration.md +18 -0
  10. data/lib/simplecov.rb +223 -44
  11. data/lib/simplecov/command_guesser.rb +47 -35
  12. data/lib/simplecov/configuration.rb +281 -191
  13. data/lib/simplecov/defaults.rb +38 -43
  14. data/lib/simplecov/exit_codes.rb +10 -0
  15. data/lib/simplecov/file_list.rb +51 -34
  16. data/lib/simplecov/filter.rb +50 -3
  17. data/lib/simplecov/formatter.rb +4 -1
  18. data/lib/simplecov/formatter/multi_formatter.rb +34 -0
  19. data/lib/simplecov/formatter/simple_formatter.rb +18 -12
  20. data/lib/simplecov/jruby_fix.rb +44 -0
  21. data/lib/simplecov/last_run.rb +26 -0
  22. data/lib/simplecov/lines_classifier.rb +48 -0
  23. data/lib/simplecov/load_global_config.rb +8 -0
  24. data/lib/simplecov/no_defaults.rb +4 -0
  25. data/lib/simplecov/profiles.rb +33 -0
  26. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  27. data/lib/simplecov/profiles/hidden_filter.rb +5 -0
  28. data/lib/simplecov/profiles/rails.rb +18 -0
  29. data/lib/simplecov/profiles/root_filter.rb +10 -0
  30. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  31. data/lib/simplecov/railtie.rb +3 -1
  32. data/lib/simplecov/railties/tasks.rake +9 -7
  33. data/lib/simplecov/raw_coverage.rb +41 -0
  34. data/lib/simplecov/result.rb +17 -55
  35. data/lib/simplecov/result_merger.rb +100 -67
  36. data/lib/simplecov/source_file.rb +82 -67
  37. data/lib/simplecov/version.rb +4 -2
  38. metadata +153 -222
  39. data/.gitignore +0 -31
  40. data/.travis.yml +0 -15
  41. data/Appraisals +0 -8
  42. data/Gemfile +0 -5
  43. data/Rakefile +0 -19
  44. data/cucumber.yml +0 -13
  45. data/features/config_adapters.feature +0 -44
  46. data/features/config_autoload.feature +0 -46
  47. data/features/config_command_name.feature +0 -33
  48. data/features/config_coverage_dir.feature +0 -20
  49. data/features/config_deactivate_merging.feature +0 -42
  50. data/features/config_merge_timeout.feature +0 -39
  51. data/features/config_nocov_token.feature +0 -79
  52. data/features/config_project_name.feature +0 -27
  53. data/features/config_styles.feature +0 -93
  54. data/features/cucumber_basic.feature +0 -29
  55. data/features/merging_test_unit_and_rspec.feature +0 -44
  56. data/features/rspec_basic.feature +0 -31
  57. data/features/rspec_fails_on_initialization.feature +0 -14
  58. data/features/rspec_groups_and_filters_basic.feature +0 -29
  59. data/features/rspec_groups_and_filters_complex.feature +0 -35
  60. data/features/rspec_groups_using_filter_class.feature +0 -40
  61. data/features/rspec_without_simplecov.feature +0 -20
  62. data/features/skipping_code_blocks_manually.feature +0 -70
  63. data/features/step_definitions/html_steps.rb +0 -45
  64. data/features/step_definitions/simplecov_steps.rb +0 -66
  65. data/features/step_definitions/transformers.rb +0 -13
  66. data/features/step_definitions/web_steps.rb +0 -64
  67. data/features/support/env.rb +0 -26
  68. data/features/test_unit_basic.feature +0 -34
  69. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  70. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  71. data/features/test_unit_groups_using_filter_class.feature +0 -40
  72. data/features/test_unit_without_simplecov.feature +0 -20
  73. data/features/unicode_compatiblity.feature +0 -67
  74. data/gemfiles/multi_json-legacy.gemfile +0 -7
  75. data/gemfiles/multi_json-legacy.gemfile.lock +0 -85
  76. data/gemfiles/multi_json-new.gemfile +0 -7
  77. data/gemfiles/multi_json-new.gemfile.lock +0 -85
  78. data/lib/simplecov/adapters.rb +0 -29
  79. data/lib/simplecov/merge_helpers.rb +0 -39
  80. data/simplecov.gemspec +0 -29
  81. data/test/faked_project/Gemfile +0 -6
  82. data/test/faked_project/Rakefile +0 -8
  83. data/test/faked_project/cucumber.yml +0 -13
  84. data/test/faked_project/features/step_definitions/my_steps.rb +0 -23
  85. data/test/faked_project/features/support/env.rb +0 -12
  86. data/test/faked_project/features/test_stuff.feature +0 -6
  87. data/test/faked_project/lib/faked_project.rb +0 -11
  88. data/test/faked_project/lib/faked_project/framework_specific.rb +0 -18
  89. data/test/faked_project/lib/faked_project/meta_magic.rb +0 -24
  90. data/test/faked_project/lib/faked_project/some_class.rb +0 -29
  91. data/test/faked_project/spec/faked_spec.rb +0 -11
  92. data/test/faked_project/spec/meta_magic_spec.rb +0 -10
  93. data/test/faked_project/spec/some_class_spec.rb +0 -10
  94. data/test/faked_project/spec/spec_helper.rb +0 -15
  95. data/test/faked_project/test/faked_test.rb +0 -11
  96. data/test/faked_project/test/meta_magic_test.rb +0 -13
  97. data/test/faked_project/test/some_class_test.rb +0 -15
  98. data/test/faked_project/test/test_helper.rb +0 -16
  99. data/test/fixtures/app/controllers/sample_controller.rb +0 -10
  100. data/test/fixtures/app/models/user.rb +0 -10
  101. data/test/fixtures/deleted_source_sample.rb +0 -15
  102. data/test/fixtures/frameworks/rspec_bad.rb +0 -9
  103. data/test/fixtures/frameworks/rspec_good.rb +0 -9
  104. data/test/fixtures/frameworks/testunit_bad.rb +0 -9
  105. data/test/fixtures/frameworks/testunit_good.rb +0 -9
  106. data/test/fixtures/iso-8859.rb +0 -3
  107. data/test/fixtures/resultset1.rb +0 -4
  108. data/test/fixtures/resultset2.rb +0 -5
  109. data/test/fixtures/sample.rb +0 -16
  110. data/test/fixtures/utf-8.rb +0 -3
  111. data/test/helper.rb +0 -35
  112. data/test/shoulda_macros.rb +0 -29
  113. data/test/test_1_8_fallbacks.rb +0 -33
  114. data/test/test_command_guesser.rb +0 -21
  115. data/test/test_deleted_source.rb +0 -16
  116. data/test/test_file_list.rb +0 -24
  117. data/test/test_filters.rb +0 -80
  118. data/test/test_merge_helpers.rb +0 -107
  119. data/test/test_result.rb +0 -147
  120. data/test/test_return_codes.rb +0 -39
  121. data/test/test_source_file.rb +0 -95
  122. data/test/test_source_file_line.rb +0 -110
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SomeClassTest < Test::Unit::TestCase
4
- def setup
5
- @instance = SomeClass.new("foo")
6
- end
7
-
8
- def test_reverse
9
- assert_equal 'oof', @instance.reverse
10
- end
11
-
12
- def test_comparison
13
- assert @instance.compare_with('foo')
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- # We're injecting simplecov_config via aruba in cucumber here
4
- # depending on what the test case is...
5
- begin
6
- require File.join(File.dirname(__FILE__), 'simplecov_config')
7
- rescue LoadError => err
8
- $stderr.puts "No SimpleCov config file found!"
9
- end
10
-
11
- require 'faked_project'
12
-
13
- require 'test/unit'
14
-
15
- class Test::Unit::TestCase
16
- end
@@ -1,10 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start { command_name "Test" }
4
-
5
- dir = File.expand_path(File.dirname(__FILE__))
6
- file = File.join(dir, "generated_buddha.rb")
7
- code = %{
8
- def kill_the_buddha(z)
9
- z**z
10
- end
11
- }
12
- File.open(file, "w") { |f| f.print code }
13
- load file
14
- File.unlink file
15
- raise unless kill_the_buddha(3) == 27
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
4
- SimpleCov.start
5
- describe 'exit status' do
6
- it "should exit with a non-zero exit status when assertion fails" do
7
- 1.should == 2
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- require 'rspec'
4
- SimpleCov.start
5
- describe 'exit status' do
6
- it "should exit with a zero exit status when assertion fails" do
7
- 1.should == 1
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start
4
- require 'test/unit'
5
- class FooTest < Test::Unit::TestCase
6
- def test_foo
7
- assert false
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
2
- require 'lib/simplecov'
3
- SimpleCov.start
4
- require 'test/unit'
5
- class FooTest < Test::Unit::TestCase
6
- def test_foo
7
- assert true
8
- end
9
- end
@@ -1,3 +0,0 @@
1
-
2
- # localized to Espa�ol thus:
3
-
@@ -1,4 +0,0 @@
1
- puts "foo"
2
- puts "foo"
3
- puts "foo"
4
- puts "foo"
@@ -1,5 +0,0 @@
1
-
2
- class Resultset
3
- VERSION = 2
4
- end
5
-
@@ -1,16 +0,0 @@
1
- # Foo class
2
- class Foo
3
- def initialize
4
- @foo = 'baz'
5
- end
6
-
7
- def bar
8
- @foo
9
- end
10
-
11
- #:nocov:
12
- def skipped
13
- @foo * 2
14
- end
15
- #:nocov:
16
- end
@@ -1,3 +0,0 @@
1
- # encoding: utf-8
2
-
3
- puts '135°C'
data/test/helper.rb DELETED
@@ -1,35 +0,0 @@
1
- require 'bundler/setup'
2
- require 'simplecov'
3
- require 'test/unit'
4
- require 'shoulda'
5
-
6
- SimpleCov.coverage_dir('tmp/coverage')
7
-
8
- class Test::Unit::TestCase
9
- def source_fixture(filename)
10
- File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
11
- end
12
-
13
- # Keep 1.8-rubies from complaining about missing tests in each file that covers only 1.9 functionality
14
- def default_test
15
- end
16
-
17
- end
18
-
19
- require 'shoulda_macros'
20
- Test::Unit::TestCase.send :extend, ShouldaMacros
21
-
22
- # Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
23
- require "stringio"
24
-
25
- def capture_stderr
26
- # The output stream must be an IO-like object. In this case we capture it in
27
- # an in-memory IO object so we can return the string value. You can assign any
28
- # IO object here.
29
- previous_stderr, $stderr = $stderr, StringIO.new
30
- yield
31
- $stderr.string
32
- ensure
33
- # Restore the previous value of stderr (typically equal to STDERR).
34
- $stderr = previous_stderr
35
- end
@@ -1,29 +0,0 @@
1
- module ShouldaMacros
2
- #
3
- # Simple block helper for running certain tests only on specific ruby versions.
4
- # The given strings will be regexp-matched against RUBY_VERSION
5
- #
6
- def on_ruby(*ruby_versions)
7
- context "On Ruby #{RUBY_VERSION}" do
8
- yield
9
- end if ruby_versions.any? {|v| RUBY_VERSION =~ /#{v}/ }
10
- end
11
-
12
- def should_be(boolean_flag)
13
- should "be #{boolean_flag}" do
14
- assert_equal true, subject.send(boolean_flag)
15
- end
16
- end
17
-
18
- def should_not_be(boolean_flag)
19
- should "not be #{boolean_flag}" do
20
- assert_equal false, subject.send(boolean_flag)
21
- end
22
- end
23
-
24
- def should_have(attr_name, expectation)
25
- should "have #{attr_name} == #{expectation.inspect}" do
26
- assert_equal expectation, subject.send(attr_name)
27
- end
28
- end
29
- end
@@ -1,33 +0,0 @@
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,21 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCommandGuesser < Test::Unit::TestCase
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
- SimpleCov::CommandGuesser.original_run_command = args
9
- assert_equal expectation, SimpleCov::CommandGuesser.guess
10
- end
11
- end
12
- end
13
-
14
- should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb'
15
- should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb'
16
- should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb'
17
- should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features'
18
- should_guess_command_name "RSpec", '/some/path/spec/foo.rb'
19
- should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined!
20
- end
21
- end
@@ -1,16 +0,0 @@
1
- require 'helper'
2
-
3
- # Test to verify correct handling of deleted files,
4
- # see issue #9 on github
5
- class TestDeletedSource < Test::Unit::TestCase
6
- on_ruby '1.8', '1.9' do
7
- context "A source file which is subsequently deleted" do
8
- should "not cause an error" do
9
- Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures')) do
10
- `ruby deleted_source_sample.rb`
11
- assert_equal 0, $?.exitstatus
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,24 +0,0 @@
1
- require 'helper'
2
-
3
- class TestFileList < Test::Unit::TestCase
4
- on_ruby "1.9" do
5
- context "With a file list from a result" do
6
- setup do
7
- original_result = {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
- @file_list = SimpleCov::Result.new(original_result).files
11
- end
12
-
13
- should("have 13 covered_lines") { assert_equal 13, @file_list.covered_lines }
14
- should("have 2 missed_lines") { assert_equal 2, @file_list.missed_lines }
15
- should("have 18 never_lines") { assert_equal 18, @file_list.never_lines }
16
- should("have 15 lines_of_code") { assert_equal 15, @file_list.lines_of_code }
17
- should("have 3 skipped_lines") { assert_equal 3, @file_list.skipped_lines }
18
-
19
- should "have correct covered_percent" do
20
- assert_equal 100.0*13/15, @file_list.covered_percent
21
- end
22
- end
23
- end
24
- end
data/test/test_filters.rb DELETED
@@ -1,80 +0,0 @@
1
- require 'helper'
2
-
3
- class TestFilters < Test::Unit::TestCase
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
9
-
10
- should "not match a new SimpleCov::StringFilter 'foobar'" do
11
- assert !SimpleCov::StringFilter.new('foobar').matches?(@source_file)
12
- end
13
-
14
- should "not match a new SimpleCov::StringFilter 'some/path'" do
15
- assert !SimpleCov::StringFilter.new('some/path').matches?(@source_file)
16
- end
17
-
18
- should "match a new SimpleCov::StringFilter 'test/fixtures'" do
19
- assert SimpleCov::StringFilter.new('test/fixtures').matches?(@source_file)
20
- end
21
-
22
- should "match a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do
23
- assert SimpleCov::StringFilter.new('test/fixtures/sample.rb').matches?(@source_file)
24
- end
25
-
26
- should "match a new SimpleCov::StringFilter 'sample.rb'" do
27
- assert SimpleCov::StringFilter.new('sample.rb').matches?(@source_file)
28
- end
29
-
30
- should "not match a new SimpleCov::BlockFilter that is not applicable" do
31
- assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).matches?(@source_file)
32
- end
33
-
34
- should "match a new SimpleCov::BlockFilter that is applicable" do
35
- assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).matches?(@source_file)
36
- end
37
- end
38
-
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
44
-
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
49
-
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
54
-
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
59
-
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
65
- end
66
-
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
72
- end
73
-
74
- should "return a FileList after filtering" do
75
- SimpleCov.add_filter "fooo"
76
- assert_equal SimpleCov::FileList, SimpleCov.filtered(@files).class
77
- end
78
- end
79
- end
80
- end
@@ -1,107 +0,0 @@
1
- require 'helper'
2
-
3
- class TestMergeHelpers < Test::Unit::TestCase
4
- on_ruby '1.9' do
5
- context "With two faked coverage resultsets" do
6
- setup do
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]}
17
- end
18
-
19
- context "a merge" do
20
- setup do
21
- assert @merged = @resultset1.merge_resultset(@resultset2)
22
- end
23
-
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
27
-
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
31
-
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
35
-
36
- should "have proper results for resultset1.rb" do
37
- assert_equal [1, 1, 1, 1], @merged[source_fixture('resultset1.rb')]
38
- end
39
-
40
- should "have proper results for resultset2.rb" do
41
- assert_equal [nil, 1, 1, nil], @merged[source_fixture('resultset2.rb')]
42
- end
43
- end
44
-
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
50
-
51
- # See Github issue #6
52
- should "return an empty hash when the resultset cache file is not present" do
53
- system "rm #{SimpleCov::ResultMerger.resultset_path}" if File.exist?(SimpleCov::ResultMerger.resultset_path)
54
- assert_equal Hash.new, SimpleCov::ResultMerger.resultset
55
- end
56
-
57
- context "and results generated from those" do
58
- setup do
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"
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
71
-
72
- should "have stored data in resultset_path yaml file" do
73
- assert File.readlines(SimpleCov::ResultMerger.resultset_path).length > 50
74
- end
75
-
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
79
-
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)
82
- end
83
-
84
- context "with second result way above the merge_timeout" do
85
- setup do
86
- @result2.created_at = Time.now - 172800 # two days ago
87
- assert SimpleCov::ResultMerger.store_result(@result2)
88
- end
89
-
90
- should "have only one result in SimpleCov::ResultMerger.results" do
91
- assert_equal 1, SimpleCov::ResultMerger.results.length
92
- end
93
- end
94
-
95
- context "with merging disabled" do
96
- setup { SimpleCov.use_merging false }
97
-
98
- should "return nil for SimpleCov.result" do
99
- assert_nil SimpleCov.result
100
- end
101
- end
102
- end
103
-
104
- end
105
- end
106
- end
107
- end