coco 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.markdown +17 -0
- data/Gemfile.lock +23 -23
- data/README.markdown +39 -34
- data/TODO.md +3 -0
- data/VERSION +1 -1
- data/lib/coco.rb +1 -1
- data/lib/coco/configuration.rb +1 -0
- data/lib/coco/cover/summary.rb +3 -3
- data/lib/coco/project.rb +17 -0
- data/template/index.erb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43c9f3652fdd1a0d076a55cc16ff8f479c6e243a
|
4
|
+
data.tar.gz: 922a59fa96f022356bbd639b94f02299a44d209f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466b4ece64b0ba67bc5537094ec57f2b2289e7b8d043c163bf889e361fc48c45145404837924e492cf74b43b0df6bf1ccb3260eea80efc8ec8963f0ed0063bea
|
7
|
+
data.tar.gz: 39f8c68fc9edb94231328c5aae8b37ff0c311fdea2c904e28c4d76d58f8bb987d208783ab80b7558b6a8a393d1ad565e8a5dfd47367a769c9badae21bb9f5f5f
|
data/Changelog.markdown
CHANGED
@@ -2,6 +2,23 @@ Next version (Unreleased)
|
|
2
2
|
=================================================
|
3
3
|
|
4
4
|
|
5
|
+
v0.15.0 (2017-02-27)
|
6
|
+
=================================================
|
7
|
+
|
8
|
+
## Added
|
9
|
+
|
10
|
+
* It's now possible to exit (with code status 2) from coco when the coverage
|
11
|
+
is less than a particular threshold. This feature allow the build to fail in
|
12
|
+
continuous integration. This behavior is controlled by the option
|
13
|
+
`:exit_if_coverage_below` and is to 0 by default (that is it's not active).
|
14
|
+
|
15
|
+
## Changed
|
16
|
+
|
17
|
+
* The coverage rate is now displayed in decimal format. So it's 12.34% instead
|
18
|
+
of 12%. This change affect the console summary as well as the index page of
|
19
|
+
the HTML report.
|
20
|
+
|
21
|
+
|
5
22
|
v0.14.0 (2016-04-16)
|
6
23
|
=================================================
|
7
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
coco (0.
|
4
|
+
coco (0.15.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
builder (3.2.
|
10
|
-
cucumber (2.
|
9
|
+
builder (3.2.3)
|
10
|
+
cucumber (2.4.0)
|
11
11
|
builder (>= 2.1.2)
|
12
|
-
cucumber-core (~> 1.
|
12
|
+
cucumber-core (~> 1.5.0)
|
13
13
|
cucumber-wire (~> 0.0.1)
|
14
14
|
diff-lcs (>= 1.1.3)
|
15
|
-
gherkin (~>
|
15
|
+
gherkin (~> 4.0)
|
16
16
|
multi_json (>= 1.7.5, < 2.0)
|
17
17
|
multi_test (>= 0.1.2)
|
18
|
-
cucumber-core (1.
|
19
|
-
gherkin (~>
|
18
|
+
cucumber-core (1.5.0)
|
19
|
+
gherkin (~> 4.0)
|
20
20
|
cucumber-wire (0.0.1)
|
21
|
-
diff-lcs (1.
|
22
|
-
gherkin (
|
23
|
-
multi_json (1.
|
21
|
+
diff-lcs (1.3)
|
22
|
+
gherkin (4.0.0)
|
23
|
+
multi_json (1.12.1)
|
24
24
|
multi_test (0.1.2)
|
25
|
-
rake (
|
26
|
-
rspec (3.
|
27
|
-
rspec-core (~> 3.
|
28
|
-
rspec-expectations (~> 3.
|
29
|
-
rspec-mocks (~> 3.
|
30
|
-
rspec-core (3.
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-expectations (3.
|
25
|
+
rake (12.0.0)
|
26
|
+
rspec (3.5.0)
|
27
|
+
rspec-core (~> 3.5.0)
|
28
|
+
rspec-expectations (~> 3.5.0)
|
29
|
+
rspec-mocks (~> 3.5.0)
|
30
|
+
rspec-core (3.5.4)
|
31
|
+
rspec-support (~> 3.5.0)
|
32
|
+
rspec-expectations (3.5.0)
|
33
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-mocks (3.
|
34
|
+
rspec-support (~> 3.5.0)
|
35
|
+
rspec-mocks (3.5.0)
|
36
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-support (3.
|
37
|
+
rspec-support (~> 3.5.0)
|
38
|
+
rspec-support (3.5.0)
|
39
39
|
|
40
40
|
PLATFORMS
|
41
41
|
ruby
|
@@ -48,4 +48,4 @@ DEPENDENCIES
|
|
48
48
|
rspec (~> 3.4)
|
49
49
|
|
50
50
|
BUNDLED WITH
|
51
|
-
1.
|
51
|
+
1.13.7
|
data/README.markdown
CHANGED
@@ -3,11 +3,9 @@ coco [![Build Status](https://travis-ci.org/lkdjiin/coco.png)](https://travis-ci
|
|
3
3
|
|
4
4
|
— *«If it's well-covered it doesn't mean it's well-tested!»* —
|
5
5
|
|
6
|
-
Code coverage tool for ruby 2.
|
7
|
-
=======
|
6
|
+
# Code coverage tool for ruby 2.x
|
8
7
|
|
9
|
-
Install
|
10
|
-
--------------------------------
|
8
|
+
## Install
|
11
9
|
|
12
10
|
In your Gemfile:
|
13
11
|
|
@@ -23,8 +21,7 @@ And in case you want to test the latest development:
|
|
23
21
|
|
24
22
|
gem 'coco', github: 'lkdjiin/coco', branch: 'development'
|
25
23
|
|
26
|
-
Usage
|
27
|
-
--------------------------------
|
24
|
+
## Usage
|
28
25
|
Require the coco library at the beginning of your tests:
|
29
26
|
|
30
27
|
require 'coco'
|
@@ -50,8 +47,7 @@ the `coverage/index.html` to access a line by line report.
|
|
50
47
|
_Note: files with a coverage of 0% are only listed in index.html ; there
|
51
48
|
is no line by line report for such files._
|
52
49
|
|
53
|
-
Basic Configuration
|
54
|
-
----------------------------------
|
50
|
+
## Basic Configuration
|
55
51
|
|
56
52
|
Configuration is done via a YAML file. You can configure:
|
57
53
|
|
@@ -144,21 +140,7 @@ _Note: YAML is very punctilious with the syntax. In particular, paid attention
|
|
144
140
|
to not put any leading spaces or tab at all._
|
145
141
|
|
146
142
|
|
147
|
-
Advanced configuration
|
148
|
-
---------------------------------
|
149
|
-
|
150
|
-
### See coverage of all files in the console
|
151
|
-
|
152
|
-
By default, with a multilines report style on the console, Coco will display
|
153
|
-
only the files with a coverage above the threshold. And as the threshold is
|
154
|
-
100% by default, nothing will be displayed if your test suite is 100% covered.
|
155
|
-
This could be annoying for some people, or worst, you could even feel like Coco
|
156
|
-
doing something the wrong way.
|
157
|
-
|
158
|
-
So, to display in green the covered files, put this in your `.coco.yml`
|
159
|
-
configuration file:
|
160
|
-
|
161
|
-
:exclude_above_threshold: false
|
143
|
+
## Advanced configuration
|
162
144
|
|
163
145
|
### When to start coco, and when not to start it
|
164
146
|
|
@@ -191,6 +173,34 @@ environement variable `COCO`, like this:
|
|
191
173
|
|
192
174
|
COCO=1 rspec
|
193
175
|
|
176
|
+
### Premature exit if coverage is under a particular threshold
|
177
|
+
|
178
|
+
If you're using some kind of continuous integration, there is some chance you
|
179
|
+
would like the build to fail if the coverage is under a particular threshold.
|
180
|
+
In such case you want to set the `exit_if_coverage_below` option.
|
181
|
+
|
182
|
+
#### Example
|
183
|
+
|
184
|
+
Put this in your `.coco.yml` configuration file:
|
185
|
+
|
186
|
+
:exit_if_coverage_below: 95
|
187
|
+
|
188
|
+
This will make coco fail if the coverage percentage is below 95%.
|
189
|
+
|
190
|
+
|
191
|
+
### See coverage of all files in the console
|
192
|
+
|
193
|
+
By default, with a multilines report style on the console, Coco will display
|
194
|
+
only the files with a coverage above the threshold. And as the threshold is
|
195
|
+
100% by default, nothing will be displayed if your test suite is 100% covered.
|
196
|
+
This could be annoying for some people, or worst, you could even feel like Coco
|
197
|
+
doing something the wrong way.
|
198
|
+
|
199
|
+
So, to display in green the covered files, put this in your `.coco.yml`
|
200
|
+
configuration file:
|
201
|
+
|
202
|
+
:exclude_above_threshold: false
|
203
|
+
|
194
204
|
### Index page URI in your terminal
|
195
205
|
|
196
206
|
If your terminal supports opening an URI with a double-clic (or any
|
@@ -213,8 +223,7 @@ Now, when running tests, you will see something like the following:
|
|
213
223
|
See file:///path/to/your/coverage/index.html
|
214
224
|
|
215
225
|
|
216
|
-
How is this different than [SimpleCov](https://github.com/colszowka/simplecov) ?
|
217
|
-
--------------------------------
|
226
|
+
## How is this different than [SimpleCov](https://github.com/colszowka/simplecov) ?
|
218
227
|
|
219
228
|
I designed Coco from the start to have only the features I need. And I don't
|
220
229
|
need much: 95% of the time, all I want is a tiny one line summary in my console.
|
@@ -229,26 +238,22 @@ To synthesize, if you have big needs, give SimpleCov a try ; if you have small
|
|
229
238
|
needs, give Coco a try.
|
230
239
|
|
231
240
|
|
232
|
-
Contributing
|
233
|
-
--------------------------------
|
241
|
+
## Contributing
|
234
242
|
|
235
243
|
1. Fork it.
|
236
|
-
2. Create your feature branch
|
237
|
-
- `git
|
238
|
-
- `git pull origin development`
|
244
|
+
2. Create your feature branch
|
245
|
+
- `git pull origin master`
|
239
246
|
- `git checkout -b my-new-feature`
|
240
247
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
241
248
|
4. Push to the branch (`git push origin my-new-feature`)
|
242
249
|
5. Create a Pull Request.
|
243
250
|
|
244
251
|
|
245
|
-
License
|
246
|
-
--------------------------------
|
252
|
+
## License
|
247
253
|
MIT, see LICENSE.
|
248
254
|
|
249
255
|
|
250
|
-
Questions and/or Comments
|
251
|
-
--------------------------------
|
256
|
+
## Questions and/or Comments
|
252
257
|
|
253
258
|
Feel free to email [Xavier Nayrac](mailto:xavier.nayrac@gmail.com)
|
254
259
|
with any questions, or contact me on [twitter](https://twitter.com/lkdjiin).
|
data/TODO.md
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.15.0
|
data/lib/coco.rb
CHANGED
data/lib/coco/configuration.rb
CHANGED
data/lib/coco/cover/summary.rb
CHANGED
@@ -12,7 +12,7 @@ module Coco
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_s
|
15
|
-
"Cover #{average}% | #{uncovered_count} uncovered | #{count} files"
|
15
|
+
"Cover #{'%.2f' % average}% | #{uncovered_count} uncovered | #{count} files"
|
16
16
|
end
|
17
17
|
|
18
18
|
# Public: Computes the average coverage rate.
|
@@ -25,10 +25,10 @@ module Coco
|
|
25
25
|
# In words: Take the sum of the coverage's percentage of all files
|
26
26
|
# and divide this sum by the number of files.
|
27
27
|
#
|
28
|
-
# Returns the
|
28
|
+
# Returns the Float average rate of coverage.
|
29
29
|
#
|
30
30
|
def average
|
31
|
-
files_present? ?
|
31
|
+
files_present? ? sum / count : 0
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
data/lib/coco/project.rb
CHANGED
@@ -3,6 +3,7 @@ module Coco
|
|
3
3
|
# A project reports statistics about the code coverage.
|
4
4
|
#
|
5
5
|
class Project
|
6
|
+
EXIT_ON_LOW_COVERAGE_CODE = 2
|
6
7
|
|
7
8
|
# raw_result - The hash obtain by the call to `Coverage.result`.
|
8
9
|
# out - The output where results will be displayed, by
|
@@ -23,10 +24,26 @@ module Coco
|
|
23
24
|
|
24
25
|
report_on_console
|
25
26
|
report_in_html
|
27
|
+
|
28
|
+
maybe_exit_if_low_coverage
|
26
29
|
end
|
27
30
|
|
28
31
|
private
|
29
32
|
|
33
|
+
def maybe_exit_if_low_coverage
|
34
|
+
return if coverage_is_satisfying?
|
35
|
+
|
36
|
+
message = "Sadly, the code coverage is below the required value of " +
|
37
|
+
"#{@config[:exit_if_coverage_below]}%"
|
38
|
+
@out.puts ColoredString.new(message).red
|
39
|
+
|
40
|
+
exit(EXIT_ON_LOW_COVERAGE_CODE)
|
41
|
+
end
|
42
|
+
|
43
|
+
def coverage_is_satisfying?
|
44
|
+
Summary.new(result, uncovered).average >= @config[:exit_if_coverage_below]
|
45
|
+
end
|
46
|
+
|
30
47
|
def report_on_console
|
31
48
|
formatter = ConsoleFormatter.new(uncovered, @config[:threshold],
|
32
49
|
result, @config)
|
data/template/index.erb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
<section class="summary">
|
21
21
|
<p>
|
22
|
-
<span class="summary-rate">Rate <%= @summary.average %>%</span>
|
22
|
+
<span class="summary-rate">Rate <%= '%.2f' % @summary.average %>%</span>
|
23
23
|
<span class="summary-uncovered">Uncovered <%= @summary.uncovered_count %></span>
|
24
24
|
<span class="summary-files">Files <%= @summary.count %></span>
|
25
25
|
</p>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Nayrac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- LICENSE
|
85
85
|
- README.markdown
|
86
86
|
- Rakefile
|
87
|
+
- TODO.md
|
87
88
|
- VERSION
|
88
89
|
- lib/coco.rb
|
89
90
|
- lib/coco/configuration.rb
|
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
138
|
version: '0'
|
138
139
|
requirements: []
|
139
140
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.6.8
|
141
142
|
signing_key:
|
142
143
|
specification_version: 4
|
143
144
|
summary: Code coverage tool for ruby 2.x
|