simplecov 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +17 -1
  3. data/CONTRIBUTING.md +12 -9
  4. data/ISSUE_TEMPLATE.md +23 -0
  5. data/README.md +41 -14
  6. data/doc/alternate-formatters.md +10 -0
  7. data/lib/simplecov.rb +91 -0
  8. data/lib/simplecov/command_guesser.rb +2 -0
  9. data/lib/simplecov/configuration.rb +2 -0
  10. data/lib/simplecov/defaults.rb +9 -80
  11. data/lib/simplecov/exit_codes.rb +2 -0
  12. data/lib/simplecov/file_list.rb +2 -0
  13. data/lib/simplecov/filter.rb +3 -1
  14. data/lib/simplecov/formatter.rb +2 -0
  15. data/lib/simplecov/formatter/multi_formatter.rb +2 -0
  16. data/lib/simplecov/formatter/simple_formatter.rb +2 -0
  17. data/lib/simplecov/jruby_fix.rb +2 -0
  18. data/lib/simplecov/last_run.rb +2 -0
  19. data/lib/simplecov/lines_classifier.rb +19 -3
  20. data/lib/simplecov/load_global_config.rb +2 -0
  21. data/lib/simplecov/no_defaults.rb +2 -0
  22. data/lib/simplecov/profiles.rb +2 -0
  23. data/lib/simplecov/profiles/bundler_filter.rb +5 -0
  24. data/lib/simplecov/profiles/rails.rb +18 -0
  25. data/lib/simplecov/profiles/root_filter.rb +10 -0
  26. data/lib/simplecov/profiles/test_frameworks.rb +8 -0
  27. data/lib/simplecov/railtie.rb +2 -0
  28. data/lib/simplecov/railties/tasks.rake +2 -0
  29. data/lib/simplecov/raw_coverage.rb +2 -0
  30. data/lib/simplecov/result.rb +2 -0
  31. data/lib/simplecov/result_merger.rb +2 -0
  32. data/lib/simplecov/source_file.rb +3 -1
  33. data/lib/simplecov/version.rb +3 -1
  34. metadata +22 -118
  35. data/.gitignore +0 -31
  36. data/.rspec +0 -3
  37. data/.rubocop.yml +0 -88
  38. data/.travis.yml +0 -29
  39. data/.yardopts +0 -1
  40. data/Gemfile +0 -38
  41. data/MIT-LICENSE +0 -20
  42. data/Rakefile +0 -39
  43. data/cucumber.yml +0 -13
  44. data/features/config_autoload.feature +0 -46
  45. data/features/config_command_name.feature +0 -45
  46. data/features/config_coverage_dir.feature +0 -33
  47. data/features/config_deactivate_merging.feature +0 -42
  48. data/features/config_formatters.feature +0 -77
  49. data/features/config_merge_timeout.feature +0 -39
  50. data/features/config_nocov_token.feature +0 -79
  51. data/features/config_profiles.feature +0 -44
  52. data/features/config_project_name.feature +0 -27
  53. data/features/config_styles.feature +0 -121
  54. data/features/config_tracked_files.feature +0 -29
  55. data/features/config_tracked_files_relevant_lines.feature +0 -31
  56. data/features/cucumber_basic.feature +0 -29
  57. data/features/maximum_coverage_drop.feature +0 -89
  58. data/features/merging_test_unit_and_rspec.feature +0 -44
  59. data/features/minimum_coverage.feature +0 -59
  60. data/features/refuse_coverage_drop.feature +0 -95
  61. data/features/rspec_basic.feature +0 -32
  62. data/features/rspec_fails_on_initialization.feature +0 -14
  63. data/features/rspec_groups_and_filters_basic.feature +0 -29
  64. data/features/rspec_groups_and_filters_complex.feature +0 -37
  65. data/features/rspec_groups_using_filter_class.feature +0 -41
  66. data/features/rspec_without_simplecov.feature +0 -20
  67. data/features/skipping_code_blocks_manually.feature +0 -70
  68. data/features/step_definitions/html_steps.rb +0 -44
  69. data/features/step_definitions/simplecov_steps.rb +0 -68
  70. data/features/step_definitions/transformers.rb +0 -13
  71. data/features/step_definitions/web_steps.rb +0 -64
  72. data/features/support/aruba_freedom_patch.rb +0 -53
  73. data/features/support/env.rb +0 -50
  74. data/features/test_unit_basic.feature +0 -34
  75. data/features/test_unit_groups_and_filters_basic.feature +0 -29
  76. data/features/test_unit_groups_and_filters_complex.feature +0 -35
  77. data/features/test_unit_groups_using_filter_class.feature +0 -40
  78. data/features/test_unit_without_simplecov.feature +0 -20
  79. data/features/unicode_compatiblity.feature +0 -67
  80. data/simplecov.gemspec +0 -27
  81. data/spec/1_8_fallbacks_spec.rb +0 -31
  82. data/spec/command_guesser_spec.rb +0 -48
  83. data/spec/config_loader_spec.rb +0 -14
  84. data/spec/configuration_spec.rb +0 -35
  85. data/spec/defaults_spec.rb +0 -41
  86. data/spec/deleted_source_spec.rb +0 -12
  87. data/spec/faked_project/Gemfile +0 -6
  88. data/spec/faked_project/Rakefile +0 -8
  89. data/spec/faked_project/cucumber.yml +0 -13
  90. data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
  91. data/spec/faked_project/features/support/env.rb +0 -12
  92. data/spec/faked_project/features/test_stuff.feature +0 -6
  93. data/spec/faked_project/lib/faked_project.rb +0 -11
  94. data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
  95. data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
  96. data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
  97. data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
  98. data/spec/faked_project/spec/faked_spec.rb +0 -11
  99. data/spec/faked_project/spec/forking_spec.rb +0 -8
  100. data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
  101. data/spec/faked_project/spec/some_class_spec.rb +0 -13
  102. data/spec/faked_project/spec/spec_helper.rb +0 -11
  103. data/spec/faked_project/test/faked_test.rb +0 -11
  104. data/spec/faked_project/test/meta_magic_test.rb +0 -13
  105. data/spec/faked_project/test/some_class_test.rb +0 -15
  106. data/spec/faked_project/test/test_helper.rb +0 -12
  107. data/spec/file_list_spec.rb +0 -50
  108. data/spec/filters_spec.rb +0 -202
  109. data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
  110. data/spec/fixtures/app/models/user.rb +0 -10
  111. data/spec/fixtures/deleted_source_sample.rb +0 -15
  112. data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
  113. data/spec/fixtures/frameworks/rspec_good.rb +0 -9
  114. data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
  115. data/spec/fixtures/frameworks/testunit_good.rb +0 -9
  116. data/spec/fixtures/iso-8859.rb +0 -3
  117. data/spec/fixtures/never.rb +0 -2
  118. data/spec/fixtures/resultset1.rb +0 -4
  119. data/spec/fixtures/resultset2.rb +0 -4
  120. data/spec/fixtures/sample.rb +0 -16
  121. data/spec/fixtures/skipped.rb +0 -4
  122. data/spec/fixtures/skipped_and_executed.rb +0 -8
  123. data/spec/fixtures/utf-8.rb +0 -3
  124. data/spec/helper.rb +0 -26
  125. data/spec/last_run_spec.rb +0 -48
  126. data/spec/lines_classifier_spec.rb +0 -103
  127. data/spec/multi_formatter_spec.rb +0 -20
  128. data/spec/raw_coverage_spec.rb +0 -92
  129. data/spec/result_merger_spec.rb +0 -171
  130. data/spec/result_spec.rb +0 -209
  131. data/spec/return_codes_spec.rb +0 -34
  132. data/spec/simplecov_spec.rb +0 -109
  133. data/spec/source_file_line_spec.rb +0 -155
  134. data/spec/source_file_spec.rb +0 -145
  135. data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
@@ -1,29 +0,0 @@
1
- @cucumber
2
- Feature:
3
-
4
- Simply adding the basic simplecov lines to a project should get
5
- the user a coverage report after running `cucumber features`
6
-
7
- Scenario:
8
- Given SimpleCov for Cucumber is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start
12
- """
13
-
14
- When I open the coverage report generated with `bundle exec cucumber features`
15
- Then I should see the groups:
16
- | name | coverage | files |
17
- | All Files | 91.23% | 6 |
18
-
19
- And I should see the source files:
20
- | name | coverage |
21
- | lib/faked_project.rb | 100.0 % |
22
- | lib/faked_project/some_class.rb | 80.0 % |
23
- | lib/faked_project/framework_specific.rb | 75.0 % |
24
- | lib/faked_project/meta_magic.rb | 100.0 % |
25
- | features/step_definitions/my_steps.rb | 100.0 % |
26
- | features/support/simplecov_config.rb | 100.0 % |
27
-
28
- And the report should be based upon:
29
- | Cucumber Features |
@@ -1,89 +0,0 @@
1
- @test_unit @config
2
- Feature:
3
-
4
- Exit code should be non-zero if the overall coverage decreases by more than
5
- the maximum_coverage_drop threshold.
6
-
7
- Scenario: maximum_coverage_drop configured cam cause spec failure
8
- Given SimpleCov for Test/Unit is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter 'test.rb'
13
- maximum_coverage_drop 3.14
14
- end
15
- """
16
-
17
- When I run `bundle exec rake test`
18
- Then the exit status should be 0
19
- And a file named "coverage/.last_run.json" should exist
20
-
21
- Given a file named "lib/faked_project/missed.rb" with:
22
- """
23
- class UncoveredSourceCode
24
- def foo
25
- never_reached
26
- rescue => err
27
- but no one cares about invalid ruby here
28
- end
29
- end
30
- """
31
-
32
- When I run `bundle exec rake test`
33
- Then the exit status should not be 0
34
- And the output should contain "Coverage has dropped by 3.32% since the last time (maximum allowed: 3.14%)."
35
- And a file named "coverage/.last_run.json" should exist
36
- And the file "coverage/.last_run.json" should contain:
37
- """
38
- {
39
- "result": {
40
- "covered_percent": 88.1
41
- }
42
- }
43
- """
44
-
45
- Scenario: maximum_coverage_drop not configured updates resultset
46
- Given SimpleCov for Test/Unit is configured with:
47
- """
48
- require 'simplecov'
49
- SimpleCov.start do
50
- add_filter 'test.rb'
51
- end
52
- """
53
-
54
- When I run `bundle exec rake test`
55
- Then the exit status should be 0
56
- And a file named "coverage/.last_run.json" should exist
57
- And the file "coverage/.last_run.json" should contain:
58
- """
59
- {
60
- "result": {
61
- "covered_percent": 88.1
62
- }
63
- }
64
- """
65
-
66
- Given a file named "lib/faked_project/missed.rb" with:
67
- """
68
- class UncoveredSourceCode
69
- def foo
70
- never_reached
71
- rescue => err
72
- but no one cares about invalid ruby here
73
- end
74
- end
75
- """
76
-
77
- When I run `bundle exec rake test`
78
- Then the exit status should be 0
79
- And a file named "coverage/.last_run.json" should exist
80
- And the file "coverage/.last_run.json" should contain:
81
- """
82
- {
83
- "result": {
84
- "covered_percent": 84.78
85
- }
86
- }
87
- """
88
-
89
-
@@ -1,44 +0,0 @@
1
- @test_unit @rspec @merging
2
- Feature:
3
-
4
- Test suites like RSpec and Test/Unit should be merged automatically
5
- when both have been run recently. The coverage report will feature
6
- the joined results of all test suites that are using SimpleCov.
7
-
8
- Scenario:
9
- Given SimpleCov for Test/Unit is configured with:
10
- """
11
- require 'simplecov'
12
- SimpleCov.start do
13
- add_filter 'test.rb'
14
- add_filter 'spec.rb'
15
- end
16
- """
17
- And SimpleCov for RSpec is configured with:
18
- """
19
- require 'simplecov'
20
- SimpleCov.start do
21
- add_filter 'test.rb'
22
- add_filter 'spec.rb'
23
- end
24
- """
25
-
26
- When I open the coverage report generated with `bundle exec rake test`
27
- Then the report should be based upon:
28
- | Unit Tests |
29
-
30
- When I open the coverage report generated with `bundle exec rspec spec`
31
- Then the report should be based upon:
32
- | RSpec |
33
- | Unit Tests |
34
-
35
- And I should see the groups:
36
- | name | coverage | files |
37
- | All Files | 90.48% | 4 |
38
-
39
- And I should see the source files:
40
- | name | coverage |
41
- | lib/faked_project.rb | 100.0 % |
42
- | lib/faked_project/some_class.rb | 80.0 % |
43
- | lib/faked_project/framework_specific.rb | 87.5 % |
44
- | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -1,59 +0,0 @@
1
- @test_unit @config
2
- Feature:
3
-
4
- Exit code should be non-zero if the overall coverage is below the
5
- minimum_coverage threshold.
6
-
7
- Scenario:
8
- Given SimpleCov for Test/Unit is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter 'test.rb'
13
- minimum_coverage 90
14
- end
15
- """
16
-
17
- When I run `bundle exec rake test`
18
- Then the exit status should not be 0
19
- And the output should contain "Coverage (88.10%) is below the expected minimum coverage (90.00%)."
20
-
21
- Scenario:
22
- Given SimpleCov for Test/Unit is configured with:
23
- """
24
- require 'simplecov'
25
- SimpleCov.start do
26
- add_filter 'test.rb'
27
- minimum_coverage 88.11
28
- end
29
- """
30
-
31
- When I run `bundle exec rake test`
32
- Then the exit status should not be 0
33
- And the output should contain "Coverage (88.10%) is below the expected minimum coverage (88.11%)."
34
-
35
- Scenario:
36
- Given SimpleCov for Test/Unit is configured with:
37
- """
38
- require 'simplecov'
39
- SimpleCov.start do
40
- add_filter 'test.rb'
41
- minimum_coverage 88.10
42
- end
43
- """
44
-
45
- When I run `bundle exec rake test`
46
- Then the exit status should be 0
47
-
48
- Scenario:
49
- Given SimpleCov for Test/Unit is configured with:
50
- """
51
- require 'simplecov'
52
- SimpleCov.start do
53
- add_filter 'test.rb'
54
- end
55
- """
56
-
57
- When I run `bundle exec rake test`
58
- Then the exit status should be 0
59
-
@@ -1,95 +0,0 @@
1
- @test_unit @config
2
- Feature:
3
-
4
- Exit code should be non-zero if the overall coverage decreases.
5
- And last_run file should not be overwritten with new coverage value.
6
-
7
- Scenario: refuse_coverage_drop configured
8
- Given SimpleCov for Test/Unit is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_filter 'test.rb'
13
- refuse_coverage_drop
14
- end
15
- """
16
-
17
- When I run `bundle exec rake test`
18
- Then the exit status should be 0
19
- And a file named "coverage/.last_run.json" should exist
20
- And the file "coverage/.last_run.json" should contain:
21
- """
22
- {
23
- "result": {
24
- "covered_percent": 88.1
25
- }
26
- }
27
- """
28
-
29
- Given a file named "lib/faked_project/missed.rb" with:
30
- """
31
- class UncoveredSourceCode
32
- def foo
33
- never_reached
34
- rescue => err
35
- but no one cares about invalid ruby here
36
- end
37
- end
38
- """
39
-
40
- When I run `bundle exec rake test`
41
- Then the exit status should not be 0
42
- And the output should contain "Coverage has dropped by 3.32% since the last time (maximum allowed: 0.00%)."
43
- And a file named "coverage/.last_run.json" should exist
44
- And the file "coverage/.last_run.json" should contain:
45
- """
46
- {
47
- "result": {
48
- "covered_percent": 88.1
49
- }
50
- }
51
- """
52
-
53
- Scenario: refuse_coverage_drop not configured updates resultset
54
- Given SimpleCov for Test/Unit is configured with:
55
- """
56
- require 'simplecov'
57
- SimpleCov.start do
58
- add_filter 'test.rb'
59
- end
60
- """
61
-
62
- When I run `bundle exec rake test`
63
- Then the exit status should be 0
64
- And a file named "coverage/.last_run.json" should exist
65
- And the file "coverage/.last_run.json" should contain:
66
- """
67
- {
68
- "result": {
69
- "covered_percent": 88.1
70
- }
71
- }
72
- """
73
-
74
- Given a file named "lib/faked_project/missed.rb" with:
75
- """
76
- class UncoveredSourceCode
77
- def foo
78
- never_reached
79
- rescue => err
80
- but no one cares about invalid ruby here
81
- end
82
- end
83
- """
84
-
85
- When I run `bundle exec rake test`
86
- Then the exit status should be 0
87
- And a file named "coverage/.last_run.json" should exist
88
- And the file "coverage/.last_run.json" should contain:
89
- """
90
- {
91
- "result": {
92
- "covered_percent": 84.78
93
- }
94
- }
95
- """
@@ -1,32 +0,0 @@
1
- @rspec
2
- Feature:
3
-
4
- Simply adding the basic simplecov lines to a project should get
5
- the user a coverage report after running `rspec`
6
-
7
- Scenario:
8
- Given SimpleCov for RSpec is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start
12
- """
13
-
14
- When I open the coverage report generated with `bundle exec rspec spec`
15
- Then I should see the groups:
16
- | name | coverage | files |
17
- | All Files | 91.8% | 7 |
18
-
19
- And I should see the source files:
20
- | name | coverage |
21
- | lib/faked_project.rb | 100.0 % |
22
- | lib/faked_project/some_class.rb | 80.0 % |
23
- | lib/faked_project/framework_specific.rb | 75.0 % |
24
- | lib/faked_project/meta_magic.rb | 100.0 % |
25
- | spec/forking_spec.rb | 100.0 % |
26
- | spec/meta_magic_spec.rb | 100.0 % |
27
- | spec/some_class_spec.rb | 100.0 % |
28
-
29
- # Note: faked_spec.rb is not appearing here since that's the first unit test file
30
- # loaded by Rake, and only there test_helper is required, which then loads simplecov
31
- # and triggers tracking of all other loaded files! Solution for this would be to
32
- # configure simplecov in this first test instead of test_helper.
@@ -1,14 +0,0 @@
1
- @rspec
2
- Feature:
3
-
4
- Running specs with a failing rspec setup
5
-
6
- Scenario: Fail if rspec fails before starting its tests
7
- Given a file named "spec/spec_helper.rb" with:
8
- """
9
- require 'simplecov'
10
- SimpleCov.start
11
- raise "some exception in the class loading before the tests start"
12
- """
13
- When I run `bundle exec rspec spec`
14
- Then the exit status should not be 0
@@ -1,29 +0,0 @@
1
- @rspec
2
- Feature:
3
-
4
- Defining some groups and filters should give a corresponding
5
- coverage report that respects those settings after running rspec
6
-
7
- Scenario:
8
- Given SimpleCov for RSpec is configured with:
9
- """
10
- require 'simplecov'
11
- SimpleCov.start do
12
- add_group 'Libs', 'lib/faked_project/'
13
- add_filter '/spec/'
14
- end
15
- """
16
-
17
- When I open the coverage report generated with `bundle exec rspec spec`
18
- And I should see the groups:
19
- | name | coverage | files |
20
- | All Files | 88.1% | 4 |
21
- | Libs | 86.11% | 3 |
22
- | Ungrouped | 100.0% | 1 |
23
-
24
- And I should see the source files:
25
- | name | coverage |
26
- | lib/faked_project.rb | 100.0 % |
27
- | lib/faked_project/some_class.rb | 80.0 % |
28
- | lib/faked_project/framework_specific.rb | 75.0 % |
29
- | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -1,37 +0,0 @@
1
- @rspec
2
- Feature: Sophisticated grouping and filtering on RSpec
3
-
4
- Defining groups and filters can be done by passing blocks or strings.
5
- Blocks get each SimpleCov::SourceFile instance passed an can use arbitrary
6
- and potentially weird conditions to remove files from the report or add them
7
- to specific groups.
8
-
9
- Scenario:
10
- Given SimpleCov for RSpec is configured with:
11
- """
12
- require 'simplecov'
13
- SimpleCov.start do
14
- add_group 'By block' do |src_file|
15
- src_file.filename =~ /MaGiC/i
16
- end
17
- add_group 'By string', 'project/meta_magic'
18
- add_group 'By array', ['project/meta_magic']
19
-
20
- add_filter 'faked_project.rb'
21
- # Remove all files that include "describe" in their source
22
- add_filter {|src_file| src_file.lines.any? {|line| line.src =~ /describe/ } }
23
- add_filter {|src_file| src_file.covered_percent < 100 }
24
- end
25
- """
26
-
27
- When I open the coverage report generated with `bundle exec rspec spec`
28
- Then I should see the groups:
29
- | name | coverage | files |
30
- | All Files | 100.0% | 1 |
31
- | By block | 100.0% | 1 |
32
- | By string | 100.0% | 1 |
33
- | By array | 100.0% | 1 |
34
-
35
- And I should see the source files:
36
- | name | coverage |
37
- | lib/faked_project/meta_magic.rb | 100.0 % |
@@ -1,41 +0,0 @@
1
- @rspec
2
- Feature: Grouping on RSpec using a custom filter class
3
-
4
- Next to passing a block or a string to define a group, you can also pass
5
- a filter class. The filter class inherits from SimpleCov::Filter and
6
- must implement the matches? method, which is used to determine whether
7
- or not a file should be added to the group.
8
-
9
- Scenario:
10
- Given SimpleCov for RSpec is configured with:
11
- """
12
- require 'simplecov'
13
- class CoverageFilter < SimpleCov::Filter
14
- def matches?(source_file)
15
- source_file.covered_percent < filter_argument
16
- end
17
- end
18
- SimpleCov.start do
19
- add_group 'By filter class', CoverageFilter.new(90)
20
- add_group 'By string', 'project/meta_magic'
21
- end
22
- """
23
-
24
- When I open the coverage report generated with `bundle exec rspec spec`
25
- Then I should see the groups:
26
- | name | coverage | files |
27
- | All Files | 91.8% | 7 |
28
- | By filter class | 78.26% | 2 |
29
- | By string | 100.0% | 1 |
30
- | Ungrouped | 100.0% | 4 |
31
-
32
- And I should see the source files:
33
- | name | coverage |
34
- | lib/faked_project/framework_specific.rb | 75.0 % |
35
- | lib/faked_project/some_class.rb | 80.0 % |
36
- | lib/faked_project.rb | 100.0 % |
37
- | lib/faked_project/meta_magic.rb | 100.0 % |
38
- | spec/forking_spec.rb | 100.0 % |
39
- | spec/meta_magic_spec.rb | 100.0 % |
40
- | spec/some_class_spec.rb | 100.0 % |
41
-