simplecov 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -7
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +69 -0
  4. data/.travis.yml +12 -0
  5. data/CHANGELOG.md +59 -21
  6. data/Gemfile +22 -15
  7. data/MIT-LICENSE +1 -1
  8. data/README.md +198 -176
  9. data/Rakefile +17 -8
  10. data/doc/alternate-formatters.md +36 -0
  11. data/doc/commercial-services.md +20 -0
  12. data/doc/editor-integration.md +13 -0
  13. data/features/rspec_basic.feature +3 -2
  14. data/features/rspec_groups_and_filters_complex.feature +2 -0
  15. data/features/rspec_groups_using_filter_class.feature +3 -2
  16. data/features/step_definitions/html_steps.rb +6 -7
  17. data/features/step_definitions/simplecov_steps.rb +18 -16
  18. data/features/step_definitions/transformers.rb +2 -2
  19. data/features/step_definitions/web_steps.rb +4 -4
  20. data/features/support/env.rb +18 -15
  21. data/lib/simplecov/command_guesser.rb +33 -34
  22. data/lib/simplecov/configuration.rb +238 -234
  23. data/lib/simplecov/defaults.rb +37 -36
  24. data/lib/simplecov/exit_codes.rb +7 -5
  25. data/lib/simplecov/file_list.rb +38 -36
  26. data/lib/simplecov/filter.rb +12 -2
  27. data/lib/simplecov/formatter/simple_formatter.rb +1 -1
  28. data/lib/simplecov/formatter.rb +2 -2
  29. data/lib/simplecov/jruby_fix.rb +4 -4
  30. data/lib/simplecov/last_run.rb +15 -13
  31. data/lib/simplecov/merge_helpers.rb +26 -27
  32. data/lib/simplecov/no_defaults.rb +2 -2
  33. data/lib/simplecov/profiles.rb +21 -19
  34. data/lib/simplecov/railtie.rb +1 -1
  35. data/lib/simplecov/railties/tasks.rake +7 -7
  36. data/lib/simplecov/result.rb +5 -5
  37. data/lib/simplecov/result_merger.rb +65 -62
  38. data/lib/simplecov/source_file.rb +23 -24
  39. data/lib/simplecov/version.rb +20 -1
  40. data/lib/simplecov.rb +35 -24
  41. data/simplecov.gemspec +15 -12
  42. data/test/faked_project/Gemfile +5 -5
  43. data/test/faked_project/Rakefile +4 -4
  44. data/test/faked_project/features/step_definitions/my_steps.rb +3 -4
  45. data/test/faked_project/features/support/env.rb +5 -5
  46. data/test/faked_project/lib/faked_project/some_class.rb +3 -4
  47. data/test/faked_project/lib/faked_project.rb +1 -1
  48. data/test/faked_project/spec/faked_spec.rb +2 -2
  49. data/test/faked_project/spec/forking_spec.rb +7 -0
  50. data/test/faked_project/spec/meta_magic_spec.rb +1 -1
  51. data/test/faked_project/spec/some_class_spec.rb +3 -3
  52. data/test/faked_project/spec/spec_helper.rb +4 -8
  53. data/test/faked_project/test/faked_test.rb +2 -2
  54. data/test/faked_project/test/meta_magic_test.rb +1 -1
  55. data/test/faked_project/test/some_class_test.rb +3 -3
  56. data/test/faked_project/test/test_helper.rb +5 -9
  57. data/test/fixtures/app/controllers/sample_controller.rb +1 -1
  58. data/test/fixtures/app/models/user.rb +1 -1
  59. data/test/fixtures/deleted_source_sample.rb +3 -3
  60. data/test/fixtures/frameworks/rspec_bad.rb +4 -4
  61. data/test/fixtures/frameworks/rspec_good.rb +4 -4
  62. data/test/fixtures/frameworks/testunit_bad.rb +3 -3
  63. data/test/fixtures/frameworks/testunit_good.rb +3 -3
  64. data/test/fixtures/resultset2.rb +0 -1
  65. data/test/fixtures/sample.rb +1 -1
  66. data/test/fixtures/utf-8.rb +1 -1
  67. data/test/helper.rb +9 -11
  68. data/test/test_1_8_fallbacks.rb +7 -7
  69. data/test/test_command_guesser.rb +8 -8
  70. data/test/test_deleted_source.rb +3 -3
  71. data/test/test_file_list.rb +9 -7
  72. data/test/test_filters.rb +30 -14
  73. data/test/test_merge_helpers.rb +31 -24
  74. data/test/test_result.rb +32 -23
  75. data/test/test_return_codes.rb +10 -6
  76. data/test/test_source_file.rb +5 -38
  77. data/test/test_source_file_line.rb +17 -17
  78. metadata +146 -64
  79. data/lib/simplecov/json.rb +0 -27
data/README.md CHANGED
@@ -9,7 +9,7 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
9
9
  * [Mailing List]
10
10
  * [Continuous Integration]
11
11
 
12
- **Important Notice: There is a bug that affects exit code handling on the 0.8 line of SimpleCov, see [#281](https://github.com/colszowka/simplecov/issues/281). Please use versions `~> 0.7.1` or `~> 0.9.0` to avoid this.**
12
+ **Important Notice: There is a bug that affects exit code handling on the 0.8 line of SimpleCov, see [#281](https://github.com/colszowka/simplecov/issues/281). Please use versions `>= 0.9` to avoid this.**
13
13
 
14
14
  [Coverage]: http://www.ruby-doc.org/stdlib-2.1.0/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
15
15
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
@@ -43,7 +43,7 @@ automatically when you launch SimpleCov. If you're curious, you can find it [on
43
43
  *Code and Bug Reports*
44
44
 
45
45
  * [Issue Tracker](https://github.com/colszowka/simplecov/issues)
46
- * See [CONTRIBUTING](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md) for how to contribute along with some common problems to check out before creating an issue.
46
+ * See [CONTRIBUTING](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md) for how to contribute along with some common problems to check out before creating an issue.
47
47
 
48
48
  *Questions, Problems, Suggestions, etc.*
49
49
 
@@ -51,54 +51,58 @@ automatically when you launch SimpleCov. If you're curious, you can find it [on
51
51
 
52
52
  Getting started
53
53
  ---------------
54
-
55
54
  1. Add SimpleCov to your `Gemfile` and `bundle install`:
56
55
 
57
- ```ruby
58
- gem 'simplecov', :require => false, :group => :test
59
- ```
60
-
61
- 2. Load and launch SimpleCov **at the very top** of your `test/test_helper.rb` (*or `spec_helper.rb`, cucumber `env.rb`, or whatever
62
- your preferred test framework uses*):
63
-
64
- ```ruby
65
- require 'simplecov'
66
- SimpleCov.start
67
-
68
- # Previous content of test helper now starts here
69
- ```
70
-
71
- **Note:** If SimpleCov starts after your application code is already loaded (via `require`), it won't be able to
72
- track your files and their coverage! The `SimpleCov.start` **must** be issued **before any of your application code
73
- is required!**
74
-
75
- SimpleCov must be running in the process that you want the code coverage analysis to happen on. When testing a server
76
- process (i.e. a JSON API endpoint) via a separate test process (i.e. when using Selenium) where you want to see all
77
- code executed by the `rails server`, and not just code executed in your actual test files, you'll want to add something
78
- like this to the top of `script/rails`:
79
-
80
- ```ruby
81
- if ENV['RAILS_ENV'] == 'test'
82
- require 'simplecov'
83
- SimpleCov.start 'rails'
84
- puts "required simplecov"
85
- end
86
- ```
87
-
88
- 3. Run your tests, open up `coverage/index.html` in your browser and check out what you've missed so far.
89
-
90
- 4. Add the following to your `.gitignore` file to ensure that coverage results are not tracked by Git (optional):
91
-
56
+ ```ruby
57
+ gem 'simplecov', :require => false, :group => :test
58
+ ```
59
+ 2. Load and launch SimpleCov **at the very top** of your `test/test_helper.rb`
60
+ (*or `spec_helper.rb`, cucumber `env.rb`, or whatever your preferred test
61
+ framework uses*):
62
+
63
+ ```ruby
64
+ require 'simplecov'
65
+ SimpleCov.start
66
+
67
+ # Previous content of test helper now starts here
68
+ ```
69
+
70
+ **Note:** If SimpleCov starts after your application code is already loaded
71
+ (via `require`), it won't be able to track your files and their coverage!
72
+ The `SimpleCov.start` **must** be issued **before any of your application
73
+ code is required!**
74
+
75
+ SimpleCov must be running in the process that you want the code coverage
76
+ analysis to happen on. When testing a server process (i.e. a JSON API
77
+ endpoint) via a separate test process (i.e. when using Selenium) where you
78
+ want to see all code executed by the `rails server`, and not just code
79
+ executed in your actual test files, you'll want to add something like this
80
+ to the top of `script/rails` (or `bin/rails` for Rails 4):
81
+
82
+ ```ruby
83
+ if ENV['RAILS_ENV'] == 'test'
84
+ require 'simplecov'
85
+ SimpleCov.start 'rails'
86
+ puts "required simplecov"
87
+ end
88
+ ```
89
+ 3. Run your tests, open up `coverage/index.html` in your browser and check out
90
+ what you've missed so far.
91
+ 4. Add the following to your `.gitignore` file to ensure that coverage results
92
+ are not tracked by Git (optional):
93
+
94
+ ```
92
95
  coverage
96
+ ```
93
97
 
94
- If you're making a Rails application, SimpleCov comes with built-in configurations (see below for information on profiles)
95
- that will get you started with groups for your Controllers, Views, Models and Helpers. To use it, the first two lines of
96
- your test_helper should be like this:
98
+ If you're making a Rails application, SimpleCov comes with built-in configurations (see below for information on profiles)
99
+ that will get you started with groups for your Controllers, Views, Models and Helpers. To use it, the first two lines of
100
+ your test_helper should be like this:
97
101
 
98
- ```ruby
99
- require 'simplecov'
100
- SimpleCov.start 'rails'
101
- ```
102
+ ```ruby
103
+ require 'simplecov'
104
+ SimpleCov.start 'rails'
105
+ ```
102
106
 
103
107
  ## Example output
104
108
 
@@ -111,8 +115,6 @@ SimpleCov.start 'rails'
111
115
 
112
116
  ![SimpleCov source file detail view](http://colszowka.github.com/simplecov/devise_source_file-0.5.3.png)
113
117
 
114
-
115
-
116
118
  ## Use it with any framework!
117
119
 
118
120
  Similarly to the usage with Test::Unit described above, the only thing you have to do is to add the SimpleCov
@@ -135,71 +137,88 @@ For some frameworks and testing tools there are quirks and problems you might wa
135
137
  to use SimpleCov with them. Here's an overview of the known ones:
136
138
 
137
139
  <table>
138
- <tr><th>Framework</th><th>Notes</th><th>Issue #</th></tr>
139
- <tr>
140
- <td>
141
- <b>Test/Unit 2</b>
142
- </td>
143
- <td>
144
- Test Unit 2 used to mess with ARGV, leading to a failure to detect the test process name in SimpleCov.
145
- <code>test-unit</code> releases 2.4.3+ (Dec 11th, 2011) should have this problem resolved.
146
- </td>
147
- <td>
148
- <a href="https://github.com/colszowka/simplecov/issues/45">SimpleCov #45</a> &
149
- <a href="https://github.com/test-unit/test-unit/pull/12">Test/Unit #12</a>
150
- </td>
151
- </tr>
152
- <tr>
153
- <td>
154
- <b>Spork</b>
155
- </td>
156
- <td>
157
- Because of how Spork works internally (using preforking), there used to be trouble when using SimpleCov
158
- with it, but that has apparently been resolved with a specific configuration strategy. See
159
- <a href="https://github.com/colszowka/simplecov/issues/42#issuecomment-4440284">this</a> comment.
160
- </td>
161
- <td>
162
- <a href="https://github.com/colszowka/simplecov/issues/42#issuecomment-4440284">SimpleCov #42</a>
163
- </td>
164
- </tr>
165
- <tr>
166
- <td>
167
- <b>parallel_tests</b>
168
- </td>
169
- <td>
170
- As of 0.8.0, SimpleCov should correctly recognize parallel_tests and supplement your test suite names
171
- with their corresponding test env numbers. Locking of the resultset cache should ensure no race conditions
172
- occur when results are merged.
173
- </td>
174
- <td>
175
- <a href="https://github.com/colszowka/simplecov/issues/64">SimpleCov #64</a>
176
- <a href="https://github.com/colszowka/simplecov/pull/185">SimpleCov #185</a>
177
- </td>
178
- </tr>
179
- <tr>
180
- <td>
181
- <b>Riot</b>
182
- </td>
183
- <td>
184
- A user has reported problems with the coverage report using the riot framework. If you experience
185
- similar trouble please follow up on the related GitHub issue.
186
- </td>
187
- <td>
188
- <a href="https://github.com/colszowka/simplecov/issues/80">SimpleCov #80</a>
189
- </td>
190
- </tr>
191
- <tr>
192
- <td>
193
- <b>RubyMine</b>
194
- </td>
195
- <td>
196
- The <a href="https://www.jetbrains.com/ruby/">RubyMine IDE</a> has built-in support for SimpleCov's coverage reports,
197
- though you might need to explicitly set the output root using `SimpleCov.root('foo/bar/baz')`
198
- </td>
199
- <td>
200
- <a href="https://github.com/colszowka/simplecov/issues/95">SimpleCov #95</a>
201
- </td>
202
- </tr>
140
+ <tr><th>Framework</th><th>Notes</th><th>Issue</th></tr>
141
+ <tr>
142
+ <th>
143
+ parallel_tests
144
+ </th>
145
+ <td>
146
+ As of 0.8.0, SimpleCov should correctly recognize parallel_tests and
147
+ supplement your test suite names with their corresponding test env
148
+ numbers. Locking of the resultset cache should ensure no race conditions
149
+ occur when results are merged.
150
+ </td>
151
+ <td>
152
+ <a href="https://github.com/colszowka/simplecov/issues/64">#64</a> &amp;
153
+ <a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
154
+ </td>
155
+ </tr>
156
+ <tr>
157
+ <th>
158
+ Riot
159
+ </th>
160
+ <td>
161
+ A user has reported problems with the coverage report using the riot
162
+ framework. If you experience similar trouble please follow up on the
163
+ related GitHub issue.
164
+ </td>
165
+ <td>
166
+ <a href="https://github.com/colszowka/simplecov/issues/80">#80</a>
167
+ </td>
168
+ </tr>
169
+ <tr>
170
+ <th>
171
+ RubyMine
172
+ </th>
173
+ <td>
174
+ The <a href="https://www.jetbrains.com/ruby/">RubyMine IDE</a> has
175
+ built-in support for SimpleCov's coverage reports, though you might need
176
+ to explicitly set the output root using `SimpleCov.root('foo/bar/baz')`
177
+ </td>
178
+ <td>
179
+ <a href="https://github.com/colszowka/simplecov/issues/95">#95</a>
180
+ </td>
181
+ </tr>
182
+ <tr>
183
+ <th>
184
+ Spork
185
+ </th>
186
+ <td>
187
+ Because of how Spork works internally (using preforking), there used to
188
+ be trouble when using SimpleCov with it, but that has apparently been
189
+ resolved with a specific configuration strategy. See <a
190
+ href="https://github.com/colszowka/simplecov/issues/42#issuecomment-4440284">this</a>
191
+ comment.
192
+ </td>
193
+ <td>
194
+ <a href="https://github.com/colszowka/simplecov/issues/42#issuecomment-4440284">#42</a>
195
+ </td>
196
+ </tr>
197
+ <tr>
198
+ <th>
199
+ Spring
200
+ </th>
201
+ <td>
202
+ <a href="#want-to-use-spring-with-simplecov">See section below.</a>
203
+ </td>
204
+ <td>
205
+ <a href="https://github.com/colszowka/simplecov/issues/381">#381</a>
206
+ </td>
207
+ </tr>
208
+ <tr>
209
+ <th>
210
+ Test/Unit
211
+ </th>
212
+ <td>
213
+ Test Unit 2 used to mess with ARGV, leading to a failure to detect the
214
+ test process name in SimpleCov. <code>test-unit</code> releases 2.4.3+
215
+ (Dec 11th, 2011) should have this problem resolved.
216
+ </td>
217
+ <td>
218
+ <a href="https://github.com/colszowka/simplecov/issues/45">#45</a> &amp;
219
+ <a href="https://github.com/test-unit/test-unit/pull/12">test-unit/test-unit#12</a>
220
+ </td>
221
+ </tr>
203
222
  </table>
204
223
 
205
224
  ## Configuring SimpleCov
@@ -208,29 +227,26 @@ to use SimpleCov with them. Here's an overview of the known ones:
208
227
 
209
228
  * The most common way is to configure it directly in your start block:
210
229
 
211
- ```ruby
212
- SimpleCov.start do
213
- some_config_option 'foo'
214
- end
215
- ```
216
-
230
+ ```ruby
231
+ SimpleCov.start do
232
+ some_config_option 'foo'
233
+ end
234
+ ```
217
235
  * You can also set all configuration options directly:
218
236
 
219
- ```ruby
220
- SimpleCov.some_config_option 'foo'
221
- ```
222
-
237
+ ```ruby
238
+ SimpleCov.some_config_option 'foo'
239
+ ```
223
240
  * If you do not want to start coverage immediately after launch or want to add additional configuration later on in a concise way, use:
224
241
 
225
- ```ruby
226
- SimpleCov.configure do
227
- some_config_option 'foo'
228
- end
229
- ```
242
+ ```ruby
243
+ SimpleCov.configure do
244
+ some_config_option 'foo'
245
+ end
246
+ ```
230
247
 
231
248
  Please check out the [Configuration] API documentation to find out what you can customize.
232
249
 
233
-
234
250
  ## Using .simplecov for centralized config
235
251
 
236
252
  If you use SimpleCov to merge multiple test suite results (i.e. Test/Unit and Cucumber) into a single report, you'd normally have to
@@ -251,6 +267,7 @@ SimpleCov.start 'rails' do
251
267
  # any custom configs like groups and filters can be here at a central place
252
268
  end
253
269
  ```
270
+ Using `.simplecov` rather than separately requiring SimpleCov multiple times is recommended if you are merging multiple test frameworks like Cucumber and RSpec that rely on each other, as invoking SimpleCov multiple times can cause coverage information to be lost.
254
271
 
255
272
  ## Filters
256
273
 
@@ -333,7 +350,7 @@ that shows how you can achieve just that:
333
350
 
334
351
  ```ruby
335
352
  SimpleCov.start :rails do
336
- filters.clear # This will remove the :root_filter that comes via simplecov's defaults
353
+ filters.clear # This will remove the :root_filter and :bundler_filter that come via simplecov's defaults
337
354
  add_filter do |src|
338
355
  !(src.filename =~ /^#{SimpleCov.root}/) unless src.filename =~ /my_engine/
339
356
  end
@@ -356,6 +373,7 @@ SimpleCov.start do
356
373
  add_group "Long files" do |src_file|
357
374
  src_file.lines.count > 100
358
375
  end
376
+ add_group "Multiple Files", ["app/models", "app/controllers"] # You can also pass in an array
359
377
  add_group "Short files", LineFilter.new(5) # Using the LineFilter class defined in Filters section above
360
378
  end
361
379
  ```
@@ -378,7 +396,7 @@ on. This should work fine for Unit Tests, RSpec, and Cucumber. If it fails, it w
378
396
  that invoked the test suite as a command name.
379
397
 
380
398
  If you have some non-standard setup and still want nicely labeled test suites, you have to give Simplecov a cue as to what the
381
- name of the currently running test suite is. You can do so by specifying SimpleCov.command_name in one test file that is
399
+ name of the currently running test suite is. You can do so by specifying `SimpleCov.command_name` in one test file that is
382
400
  part of your specific suite.
383
401
 
384
402
  To customize the suite names on a Rails app (yeah, sorry for being Rails-biased, but everyone knows what
@@ -402,18 +420,28 @@ SimpleCov.command_name "features"
402
420
  Note that this only has to be invoked ONCE PER TEST SUITE, so even if you have 200 unit test files, specifying it in
403
421
  some_test.rb is enough.
404
422
 
423
+ Last but not least **if multiple suites resolve to the same `command_name`** be aware that the coverage results **will
424
+ clobber each other instead of being merged**. SimpleCov is smart enough to detect unique names for the most common
425
+ setups, but if you have more than one test suite that doesn't follow a common pattern then you will want to manually
426
+ ensure that each suite gets a unique `command_name`.
427
+
428
+ If you are running tests in parallel each process has the potential to clobber results from the other test processes.
429
+ If you are relying on the default `command_name` then SimpleCov will attempt to detect and avoid parallel test suite
430
+ `command_name` collisions based on the presence of `ENV['PARALLEL_TEST_GROUPS']` and `ENV['TEST_ENV_NUMBER']`. If your
431
+ parallel test runner does not set one or both of these then *you must* set a `command_name` and ensure that it is unique
432
+ per process (eg. `command_name "Unit Tests PID #{$$}"`).
433
+
405
434
  [simplecov-html] prints the used test suites in the footer of the generated coverage report.
406
435
 
407
436
  ### Timeout for merge
408
437
 
409
438
  Of course, your cached coverage data is likely to become invalid at some point. Thus, result sets that are older than
410
- SimpleCov.merge_timeout will not be used any more. By default, the timeout is 600 seconds (10 minutes), and you can
439
+ `SimpleCov.merge_timeout` will not be used any more. By default, the timeout is 600 seconds (10 minutes), and you can
411
440
  raise (or lower) it by specifying `SimpleCov.merge_timeout 3600` (1 hour), or, inside a configure/start block, with
412
- just "merge_timeout 3600".
441
+ just `merge_timeout 3600`.
413
442
 
414
443
  You can deactivate merging altogether with `SimpleCov.use_merging false`.
415
444
 
416
-
417
445
  ## Running coverage only on demand
418
446
 
419
447
  The Ruby STDLIB Coverage library that SimpleCov builds upon is *very* fast (i.e. on a ~10 min Rails test suite, the speed drop was
@@ -434,7 +462,6 @@ Then, SimpleCov will only run if you execute your tests like this:
434
462
  COVERAGE=true rake test
435
463
  ```
436
464
 
437
-
438
465
  ## Profiles
439
466
 
440
467
  By default, SimpleCov's only config assumption is that you only want coverage reports for files inside your project
@@ -462,7 +489,7 @@ As you can see, it's just a SimpleCov.configure block. In your test_helper.rb, l
462
489
  SimpleCov.start 'rails'
463
490
  ```
464
491
 
465
- **OR**
492
+ or
466
493
 
467
494
  ```ruby
468
495
  SimpleCov.start 'rails' do
@@ -492,7 +519,6 @@ require 'simplecov_custom_profile'
492
519
  SimpleCov.start 'myprofile'
493
520
  ```
494
521
 
495
-
496
522
  ## Customizing exit behaviour
497
523
 
498
524
  You can define what SimpleCov should do when your test suite finishes by customizing the at_exit hook:
@@ -543,7 +569,7 @@ being an instance of SimpleCov::Result. Do whatever your wish with that!
543
569
 
544
570
  ## Using multiple formatters
545
571
 
546
- As for SimpleCov 0.9.0, you can specify multiple result formats:
572
+ As of SimpleCov 0.9, you can specify multiple result formats:
547
573
 
548
574
  ```ruby
549
575
  SimpleCov.formatters = [
@@ -552,55 +578,51 @@ SimpleCov.formatters = [
552
578
  ]
553
579
  ```
554
580
 
555
- ## Available formatters
556
-
557
- Apart from the direct companion [simplecov-html], there are other formatters
558
- available:
559
-
560
- #### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
561
- *by Fernando Guillen*
562
-
563
- "The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov."
564
-
565
- #### [simplecov-csv](https://github.com/fguillen/simplecov-csv)
566
- *by Fernando Guillen*
567
-
568
- CSV formatter for SimpleCov
569
-
570
- #### [cadre](https://github.com/nyarly/cadre)
571
- *by Judson Lester*
581
+ ## Available formatters, editor integrations and hosted services
572
582
 
573
- Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
583
+ * [Open Source formatter and integration plugins for SimpleCov](doc/alternate-formatters.md)
584
+ * [Editor Integration](doc/editor-integration.md)
585
+ * [Hosted (commercial) services](doc/commercial-services.md)
574
586
 
575
- #### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
576
- *by [Michael Grosser](http://grosser.it)*
577
-
578
- A formatter that prints the coverage of the file under test when you run a single test file.
579
-
580
- #### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
581
- *by Vicent Llongo*
587
+ ## Ruby version compatibility
582
588
 
583
- JSON formatter for SimpleCov
589
+ Only Ruby 1.9+ ships with the coverage library that SimpleCov depends upon.
590
+ SimpleCov is built against various other Rubies, including Rubinius and JRuby,
591
+ in [Continuous Integration], but this happens only to ensure that SimpleCov
592
+ does not make your test suite crash right now. Whether SimpleCov will support
593
+ JRuby/Rubinius in the future depends solely on whether those Ruby interpreters
594
+ add the coverage library.
584
595
 
585
- #### [simplecov-badge](https://github.com/matthew342/simplecov-badge)
586
- *by Matt Hale*
596
+ SimpleCov is built in [Continuous Integration] on Ruby 1.9.3, 2.0.0, 2.1, and 2.2.
587
597
 
588
- A formatter that generates a coverage badge for use in your project's readme using ImageMagick.
598
+ ## Want to find dead code in production?
589
599
 
590
- ## Ruby version compatibility
600
+ Try [Coverband](https://github.com/danmayer/coverband).
591
601
 
592
- [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)](http://travis-ci.org/colszowka/simplecov)
602
+ ## Want to use Spring with SimpleCov?
593
603
 
594
- Only Ruby 1.9+ ships with the coverage library that SimpleCov depends upon. SimpleCov is built against various other Rubies,
595
- including Rubinius and JRuby, in [Continuous Integration], but this happens only to ensure that SimpleCov does not make your
596
- test suite crash right now. Whether SimpleCov will support JRuby/Rubinius in the future depends solely on whether those Ruby
597
- interpreters add the coverage library.
604
+ If you're using [Spring](https://github.com/rails/spring) to speed up test suite runs and want to run SimpleCov along with them, you'll find that it often misreports coverage with the default config due to some sort of eager loading issue. Don't despair!
598
605
 
599
- SimpleCov is built in [Continuous Integration] on 1.9.3, 2.0.0, 2.1.0 and ruby-head.
606
+ 1. Change the following settings in `development.rb` and `test.rb`.
600
607
 
601
- ## Want to find dead code in production?
608
+ ```ruby
609
+ # Disable Rails's static asset server (Apache or nginx will already do this)
610
+ config.serve_static_files = false
611
+ config.eager_load = false
612
+ ```
613
+ 2. Add your SimpleCov config, as you normally would, to your `spec_helper.rb`
614
+ (or `rails_helper.rb` for RSpec 3). If you have a `config/spring.rb` file
615
+ (or anything similar), add it to the start of such file. Here's a simple
616
+ version of what the config should look like:
602
617
 
603
- Try [coverband](https://github.com/danmayer/coverband).
618
+ ```ruby
619
+ if ENV['RAILS_ENV'] == 'test'
620
+ require 'simplecov'
621
+ SimpleCov.start
622
+ end
623
+ ```
624
+ 3. Run `spring rspec <path>` as normal. Remember to run `spring stop` after
625
+ making important changes to your app or its specs!
604
626
 
605
627
  ## Contributing
606
628
 
@@ -612,4 +634,4 @@ Thanks to Aaron Patterson for the original idea for this!
612
634
 
613
635
  ## Copyright
614
636
 
615
- Copyright (c) 2010-2013 Christoph Olszowka. See MIT-LICENSE for details.
637
+ Copyright (c) 2010-2015 Christoph Olszowka. See MIT-LICENSE for details.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
- require 'rubygems'
4
- require 'bundler/setup'
3
+ require "rubygems"
4
+ require "bundler/setup"
5
5
  Bundler::GemHelper.install_tasks
6
6
 
7
7
  # See https://github.com/colszowka/simplecov/issues/171
@@ -12,19 +12,28 @@ end
12
12
  # Enforce proper permissions on each build
13
13
  Rake::Task[:build].prerequisites.unshift :fix_permissions
14
14
 
15
- require 'rake/testtask'
15
+ require "rake/testtask"
16
16
  Rake::TestTask.new(:test) do |test|
17
- test.libs << 'lib' << 'test'
18
- test.test_files = FileList['test/test_*.rb']
17
+ test.libs << "lib" << "test"
18
+ test.test_files = FileList["test/test_*.rb"]
19
19
  test.verbose = true
20
20
  test.warning = true
21
21
  end
22
22
 
23
+ begin
24
+ require "rubocop/rake_task"
25
+ RuboCop::RakeTask.new
26
+ rescue LoadError
27
+ task :rubocop do
28
+ $stderr.puts "Rubocop is disabled"
29
+ end
30
+ end
31
+
23
32
  # Cucumber integration test suite is for impls that work with simplecov only - a.k.a. 1.9+
24
- if '1.9+'.respond_to? :encoding
25
- require 'cucumber/rake/task'
33
+ if RUBY_VERSION >= "1.9"
34
+ require "cucumber/rake/task"
26
35
  Cucumber::Rake::Task.new
27
- task :default => [:test, :cucumber]
36
+ task :default => [:test, :cucumber, :rubocop]
28
37
  else
29
38
  task :default => [:test]
30
39
  end
@@ -0,0 +1,36 @@
1
+ ## Alternate coverage report formatters
2
+
3
+ The community around simplecov provides a whole bunch of alternate formatters beyond the official
4
+ [simplecov-html](https://github.com/colszowka/simplecov-html) gem.
5
+
6
+ If you have built or found one that is missing here, please send a Pull Request for this document!
7
+
8
+ #### [simplecov-badge](https://github.com/matthew342/simplecov-badge)
9
+ *by Matt Hale*
10
+
11
+ A formatter that generates a coverage badge for use in your project's readme using ImageMagick.
12
+
13
+ #### [simplecov-cobertura](https://github.com/dashingrocket/simplecov-cobertura)
14
+ *by Jesse Bowes*
15
+
16
+ A formatter that generates Cobertura XML.
17
+
18
+ #### [simplecov-csv](https://github.com/fguillen/simplecov-csv)
19
+ *by Fernando Guillen*
20
+
21
+ CSV formatter for SimpleCov
22
+
23
+ #### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
24
+ *by Vicent Llongo*
25
+
26
+ JSON formatter for SimpleCov
27
+
28
+ #### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
29
+ *by Fernando Guillen*
30
+
31
+ "The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov."
32
+
33
+ #### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
34
+ *by [Michael Grosser](http://grosser.it)*
35
+
36
+ A formatter that prints the coverage of the file under test when you run a single test file.
@@ -0,0 +1,20 @@
1
+ ## Commercial Services with SimpleCov integration
2
+
3
+ There is a bunch of services that offer integration with your existing CI pipeline and SimpleCov coverage
4
+ reports. Please note these are not associated with the SimpleCov project itself, so please report problems with
5
+ these integrations with their respective owners.
6
+
7
+ #### [codeclimate](https://github.com/codeclimate/ruby-test-reporter)
8
+ *by [Code Climate](https://codeclimate.com/)*
9
+
10
+ Upload coverage reports to [codeclimate.com](https://codeclimate.com/), a hosted software quality analysis and that also includes coverage reporting.
11
+
12
+ #### [codecov](https://github.com/codecov/codecov-ruby)
13
+ *by [Codecov](https://codecov.io/)*
14
+
15
+ Upload coverage reports to [codecov.io](https://codecov.io/), a hosted coverage reporting solution.
16
+
17
+ #### [coveralls](https://github.com/lemurheavy/coveralls-ruby)
18
+ *by [Coveralls](https://coveralls.io/)*
19
+
20
+ Upload coverage reports to [coveralls.io](https://coveralls.io/), a hosted coverage reporting solution.
@@ -0,0 +1,13 @@
1
+ ## Editor integration
2
+
3
+ Some editors have a graphical integration for the simplecov gem.
4
+
5
+ #### [Atom Editor: coverage](https://atom.io/packages/coverage)
6
+ *by Philip Giuliani*
7
+
8
+ Adds an overview of your current test coverage to Atom.
9
+
10
+ #### [cadre](https://github.com/nyarly/cadre)
11
+ *by Judson Lester*
12
+
13
+ Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
@@ -14,14 +14,15 @@ Feature:
14
14
  When I open the coverage report generated with `bundle exec rspec spec`
15
15
  Then I should see the groups:
16
16
  | name | coverage | files |
17
- | All Files | 91.23% | 6 |
17
+ | All Files | 91.8% | 7 |
18
18
 
19
19
  And I should see the source files:
20
20
  | name | coverage |
21
21
  | lib/faked_project.rb | 100.0 % |
22
- | lib/faked_project/some_class.rb | 80.0 % |
22
+ | lib/faked_project/some_class.rb | 80.0 % |
23
23
  | lib/faked_project/framework_specific.rb | 75.0 % |
24
24
  | lib/faked_project/meta_magic.rb | 100.0 % |
25
+ | spec/forking_spec.rb | 100.0 % |
25
26
  | spec/meta_magic_spec.rb | 100.0 % |
26
27
  | spec/some_class_spec.rb | 100.0 % |
27
28