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,209 +0,0 @@
1
- require "helper"
2
-
3
- if SimpleCov.usable?
4
- describe "result" do
5
- context "with a (mocked) Coverage.result" do
6
- before do
7
- @prev_filters = SimpleCov.filters
8
- SimpleCov.filters = []
9
- @prev_groups = SimpleCov.groups
10
- SimpleCov.groups = {}
11
- @prev_formatter = SimpleCov.formatter
12
- SimpleCov.formatter = nil
13
- end
14
-
15
- after do
16
- SimpleCov.filters = @prev_filters
17
- SimpleCov.groups = @prev_groups
18
- SimpleCov.formatter = @prev_formatter
19
- end
20
-
21
- let(:original_result) do
22
- {
23
- source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
24
- source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
25
- source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
26
- }
27
- end
28
-
29
- context "a simple cov result initialized from that" do
30
- subject { SimpleCov::Result.new(original_result) }
31
-
32
- it "has 3 filenames" do
33
- expect(subject.filenames.count).to eq(3)
34
- end
35
-
36
- it "has 3 source files" do
37
- expect(subject.source_files.count).to eq(3)
38
- subject.source_files.each do |source_file|
39
- expect(source_file).to be_a SimpleCov::SourceFile
40
- end
41
- end
42
-
43
- it "returns an instance of SimpleCov::FileList for source_files and files" do
44
- expect(subject.files).to be_a SimpleCov::FileList
45
- expect(subject.source_files).to be_a SimpleCov::FileList
46
- end
47
-
48
- it "has files equal to source_files" do
49
- expect(subject.files).to eq(subject.source_files)
50
- end
51
-
52
- it "has accurate covered percent" do
53
- # in our fixture, there are 13 covered line (result in 1) in all 15 relevant line (result in non-nil)
54
- expect(subject.covered_percent).to eq(86.66666666666667)
55
- end
56
-
57
- it "has accurate covered percentages" do
58
- expect(subject.covered_percentages).to eq([80.0, 80.0, 100.0])
59
- end
60
-
61
- it "has accurate least covered file" do
62
- expect(subject.least_covered_file).to match(/sample_controller.rb/)
63
- end
64
-
65
- [:covered_percent, :covered_percentages, :least_covered_file, :covered_strength, :covered_lines, :missed_lines, :total_lines].each do |msg|
66
- it "responds to #{msg}" do
67
- expect(subject).to respond_to(msg)
68
- end
69
- end
70
-
71
- context "dumped with to_hash" do
72
- it "is a hash" do
73
- expect(subject.to_hash).to be_a Hash
74
- end
75
-
76
- context "loaded back with from_hash" do
77
- let(:dumped_result) do
78
- SimpleCov::Result.from_hash(subject.to_hash)
79
- end
80
-
81
- it "has 3 source files" do
82
- expect(dumped_result.source_files.count).to eq(subject.source_files.count)
83
- end
84
-
85
- it "has the same covered_percent" do
86
- expect(dumped_result.covered_percent).to eq(subject.covered_percent)
87
- end
88
-
89
- it "has the same covered_percentages" do
90
- expect(dumped_result.covered_percentages).to eq(subject.covered_percentages)
91
- end
92
-
93
- it "has the same timestamp" do
94
- expect(dumped_result.created_at.to_i).to eq(subject.created_at.to_i)
95
- end
96
-
97
- it "has the same command_name" do
98
- expect(dumped_result.command_name).to eq(subject.command_name)
99
- end
100
-
101
- it "has the same original_result" do
102
- expect(dumped_result.original_result).to eq(subject.original_result)
103
- end
104
- end
105
- end
106
- end
107
-
108
- context "with some filters set up" do
109
- before do
110
- SimpleCov.add_filter "sample.rb"
111
- end
112
-
113
- it "has 2 files in a new simple cov result" do
114
- expect(SimpleCov::Result.new(original_result).source_files.length).to eq(2)
115
- end
116
-
117
- it "has 80 covered percent" do
118
- expect(SimpleCov::Result.new(original_result).covered_percent).to eq(80)
119
- end
120
-
121
- it "has [80.0, 80.0] covered percentages" do
122
- expect(SimpleCov::Result.new(original_result).covered_percentages).to eq([80.0, 80.0])
123
- end
124
- end
125
-
126
- context "with groups set up for all files" do
127
- before do
128
- SimpleCov.add_group "Models", "app/models"
129
- SimpleCov.add_group "Controllers", ["app/controllers"]
130
- SimpleCov.add_group "Other" do |src_file|
131
- File.basename(src_file.filename) == "sample.rb"
132
- end
133
- end
134
-
135
- subject do
136
- SimpleCov::Result.new(original_result)
137
- end
138
-
139
- it "has 3 groups" do
140
- expect(subject.groups.length).to eq(3)
141
- end
142
-
143
- it "has user.rb in 'Models' group" do
144
- expect(File.basename(subject.groups["Models"].first.filename)).to eq("user.rb")
145
- end
146
-
147
- it "has sample_controller.rb in 'Controllers' group" do
148
- expect(File.basename(subject.groups["Controllers"].first.filename)).to eq("sample_controller.rb")
149
- end
150
-
151
- context "and simple formatter being used" do
152
- before do
153
- SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter
154
- end
155
-
156
- it "returns a formatted string with result.format!" do
157
- expect(subject.format!).to be_a String
158
- end
159
- end
160
-
161
- context "and multi formatter being used" do
162
- before do
163
- SimpleCov.formatters = [
164
- SimpleCov::Formatter::SimpleFormatter,
165
- SimpleCov::Formatter::SimpleFormatter,
166
- ]
167
- end
168
-
169
- it "returns an array containing formatted string with result.format!" do
170
- formatted = subject.format!
171
- expect(formatted.count).to eq(2)
172
- expect(formatted.first).to be_a String
173
- end
174
- end
175
- end
176
-
177
- context "with groups set up that do not match all files" do
178
- before do
179
- SimpleCov.configure do
180
- add_group "Models", "app/models"
181
- add_group "Controllers", "app/controllers"
182
- end
183
- end
184
-
185
- subject { SimpleCov::Result.new(original_result) }
186
-
187
- it "has 3 groups" do
188
- expect(subject.groups.length).to eq(3)
189
- end
190
-
191
- it "has 1 item per group" do
192
- subject.groups.each_value do |files|
193
- expect(files.length).to eq(1)
194
- end
195
- end
196
-
197
- it 'has sample.rb in "Ungrouped" group' do
198
- expect(File.basename(subject.groups["Ungrouped"].first.filename)).to eq("sample.rb")
199
- end
200
-
201
- it "returns all groups as instances of SimpleCov::FileList" do
202
- subject.groups.each_value do |files|
203
- expect(files).to be_a SimpleCov::FileList
204
- end
205
- end
206
- end
207
- end
208
- end
209
- end
@@ -1,34 +0,0 @@
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
- around do |test|
8
- Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks")) do
9
- FileUtils.rm_rf("./coverage")
10
- test.call
11
- end
12
- end
13
-
14
- it "has return code 0 when running testunit_good.rb" do
15
- `ruby testunit_good.rb`
16
- expect($?.exitstatus).to be_zero
17
- end
18
-
19
- it "has return code 0 when running rspec_good.rb" do
20
- `rspec rspec_good.rb`
21
- expect($?.exitstatus).to be_zero
22
- end
23
-
24
- it "has non-0 return code when running testunit_bad.rb" do
25
- `ruby testunit_bad.rb`
26
- expect($?.exitstatus).not_to be_zero
27
- end
28
-
29
- it "has return code 1 when running rspec_bad.rb" do
30
- `rspec rspec_bad.rb`
31
- expect($?.exitstatus).not_to be_zero
32
- end
33
- end
34
- end
@@ -1,109 +0,0 @@
1
- require "helper"
2
-
3
- if SimpleCov.usable?
4
- describe SimpleCov do
5
- describe ".result" do
6
- before do
7
- SimpleCov.clear_result
8
- allow(Coverage).to receive(:result).once.and_return({})
9
- end
10
-
11
- context "with merging disabled" do
12
- before do
13
- allow(SimpleCov).to receive(:use_merging).once.and_return(false)
14
- end
15
-
16
- context "when not running" do
17
- before do
18
- allow(SimpleCov).to receive(:running).and_return(false)
19
- end
20
-
21
- it "returns nil" do
22
- expect(SimpleCov.result).to be_nil
23
- end
24
- end
25
-
26
- context "when running" do
27
- before do
28
- allow(SimpleCov).to receive(:running).and_return(true, false)
29
- end
30
-
31
- it "uses the result from Coverage" do
32
- expect(Coverage).to receive(:result).once.and_return(__FILE__ => [0, 1])
33
- expect(SimpleCov.result.filenames).to eq [__FILE__]
34
- end
35
-
36
- it "adds not-loaded-files" do
37
- expect(SimpleCov).to receive(:add_not_loaded_files).once.and_return({})
38
- SimpleCov.result
39
- end
40
-
41
- it "doesn't store the current coverage" do
42
- expect(SimpleCov::ResultMerger).not_to receive(:store_result)
43
- SimpleCov.result
44
- end
45
-
46
- it "doesn't merge the result" do
47
- expect(SimpleCov::ResultMerger).not_to receive(:merged_result)
48
- SimpleCov.result
49
- end
50
-
51
- it "caches its result" do
52
- result = SimpleCov.result
53
- expect(SimpleCov.result).to be(result)
54
- end
55
- end
56
- end
57
-
58
- context "with merging enabled" do
59
- let(:the_merged_result) { double }
60
-
61
- before do
62
- allow(SimpleCov).to receive(:use_merging).once.and_return(true)
63
- allow(SimpleCov::ResultMerger).to receive(:store_result).once
64
- allow(SimpleCov::ResultMerger).to receive(:merged_result).once.and_return(the_merged_result)
65
- end
66
-
67
- context "when not running" do
68
- before do
69
- allow(SimpleCov).to receive(:running).and_return(false)
70
- end
71
-
72
- it "merges the result" do
73
- expect(SimpleCov.result).to be(the_merged_result)
74
- end
75
- end
76
-
77
- context "when running" do
78
- before do
79
- allow(SimpleCov).to receive(:running).and_return(true, false)
80
- end
81
-
82
- it "uses the result from Coverage" do
83
- expect(Coverage).to receive(:result).once.and_return({})
84
- SimpleCov.result
85
- end
86
-
87
- it "adds not-loaded-files" do
88
- expect(SimpleCov).to receive(:add_not_loaded_files).once.and_return({})
89
- SimpleCov.result
90
- end
91
-
92
- it "stores the current coverage" do
93
- expect(SimpleCov::ResultMerger).to receive(:store_result).once
94
- SimpleCov.result
95
- end
96
-
97
- it "merges the result" do
98
- expect(SimpleCov.result).to be(the_merged_result)
99
- end
100
-
101
- it "caches its result" do
102
- result = SimpleCov.result
103
- expect(SimpleCov.result).to be(result)
104
- end
105
- end
106
- end
107
- end
108
- end
109
- end
@@ -1,155 +0,0 @@
1
- require "helper"
2
-
3
- if SimpleCov.usable?
4
- describe SimpleCov::SourceFile::Line do
5
- context "a source line" do
6
- subject do
7
- SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
8
- end
9
-
10
- it 'returns "# the ruby source" as src' do
11
- expect(subject.src).to eq("# the ruby source")
12
- end
13
-
14
- it "returns the same for source as for src" do
15
- expect(subject.src).to eq(subject.source)
16
- end
17
-
18
- it "has line number 5" do
19
- expect(subject.line_number).to eq(5)
20
- end
21
-
22
- it "has equal line_number, line and number" do
23
- expect(subject.line).to eq(subject.line_number)
24
- expect(subject.number).to eq(subject.line_number)
25
- end
26
-
27
- context "flagged as skipped!" do
28
- before do
29
- subject.skipped!
30
- end
31
- it "is not covered" do
32
- expect(subject).not_to be_covered
33
- end
34
-
35
- it "is skipped" do
36
- expect(subject).to be_skipped
37
- end
38
-
39
- it "is not missed" do
40
- expect(subject).not_to be_missed
41
- end
42
-
43
- it "is not never" do
44
- expect(subject).not_to be_never
45
- end
46
-
47
- it "status is skipped" do
48
- expect(subject.status).to eq("skipped")
49
- end
50
- end
51
- end
52
-
53
- context "A source line with coverage" do
54
- subject do
55
- SimpleCov::SourceFile::Line.new("# the ruby source", 5, 3)
56
- end
57
-
58
- it "has coverage of 3" do
59
- expect(subject.coverage).to eq(3)
60
- end
61
-
62
- it "is covered" do
63
- expect(subject).to be_covered
64
- end
65
-
66
- it "is not skipped" do
67
- expect(subject).not_to be_skipped
68
- end
69
-
70
- it "is not missed" do
71
- expect(subject).not_to be_missed
72
- end
73
-
74
- it "is not never" do
75
- expect(subject).not_to be_never
76
- end
77
-
78
- it "status is covered" do
79
- expect(subject.status).to eq("covered")
80
- end
81
- end
82
-
83
- context "A source line without coverage" do
84
- subject do
85
- SimpleCov::SourceFile::Line.new("# the ruby source", 5, 0)
86
- end
87
-
88
- it "has coverage of 0" do
89
- expect(subject.coverage).to be_zero
90
- end
91
-
92
- it "is not covered" do
93
- expect(subject).not_to be_covered
94
- end
95
-
96
- it "is not skipped" do
97
- expect(subject).not_to be_skipped
98
- end
99
-
100
- it "is missed" do
101
- expect(subject).to be_missed
102
- end
103
-
104
- it "is not never" do
105
- expect(subject).not_to be_never
106
- end
107
-
108
- it "status is missed" do
109
- expect(subject.status).to eq("missed")
110
- end
111
- end
112
-
113
- context "A source line with no code" do
114
- subject do
115
- SimpleCov::SourceFile::Line.new("# the ruby source", 5, nil)
116
- end
117
-
118
- it "has nil coverage" do
119
- expect(subject.coverage).to be_nil
120
- end
121
-
122
- it "is not covered" do
123
- expect(subject).not_to be_covered
124
- end
125
-
126
- it "is not skipped" do
127
- expect(subject).not_to be_skipped
128
- end
129
-
130
- it "is not missed" do
131
- expect(subject).not_to be_missed
132
- end
133
-
134
- it "is never" do
135
- expect(subject).to be_never
136
- end
137
-
138
- it "status is never" do
139
- expect(subject.status).to eq("never")
140
- end
141
- end
142
-
143
- it "raises ArgumentError when initialized with invalid src" do
144
- expect { SimpleCov::SourceFile::Line.new(:symbol, 5, 3) }.to raise_error(ArgumentError)
145
- end
146
-
147
- it "raises ArgumentError when initialized with invalid line_number" do
148
- expect { SimpleCov::SourceFile::Line.new("some source", "five", 3) }.to raise_error(ArgumentError)
149
- end
150
-
151
- it "raises ArgumentError when initialized with invalid coverage" do
152
- expect { SimpleCov::SourceFile::Line.new("some source", 5, "three") }.to raise_error(ArgumentError)
153
- end
154
- end
155
- end