simplecov-oj 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE +21 -0
- data/README.md +64 -0
- data/lib/simple_cov/formatter/oj_formatter.rb +56 -0
- data/lib/simple_cov/oj/output_message.rb +57 -0
- data/lib/simple_cov/oj/result_to_hash.rb +61 -0
- data/lib/simple_cov/oj/result_wrapper.rb +63 -0
- data/lib/simple_cov/oj/source_file_wrapper.rb +82 -0
- data/lib/simple_cov/oj/version.rb +14 -0
- data/lib/simplecov-oj.rb +12 -0
- data/lib/tasks/changelog.rake +24 -0
- data/spec/simple_cov/formatter/oj_formatter_spec.rb +80 -0
- data/spec/spec_helper.rb +31 -0
- metadata +217 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a5cb1f33b1f2da7cf91879ec6ab44c70ea9d3069a1d67bc7953426da1c06489
|
4
|
+
data.tar.gz: 64abb42d0f448f50854ab31fc41b004122c41c4e3ea5b1379aaf1ceb1e503fc8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 266222bbef8d53d90d3eb6f9d8b1fa352b7ecd542180e37f509e87c783197a1ea130d3135a92947c2c991d579240346b0869814ebe7442c9efbdd81c7bf3ef72
|
7
|
+
data.tar.gz: 4afe0864271389a015292f944035bc354e1be3d64ed4a105c4f221a8119c1f0362d95c5c464af5b73b1b7155beac92e008f5f9f3a52549a1f5b013d48f8088eb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v0.2](https://github.com/mhenrixon/simplecov-oj/tree/v0.2) (2013-07-20)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/mhenrixon/simplecov-oj/compare/aa3f4993ad39ba63229938d23ac2470b6f2cee3e...v0.2)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2020 Mikael Henriksson http://mhenrixon.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# simplecov-json
|
2
|
+
|
3
|
+
JSON formatter for the ruby 1.9+ code coverage gem SimpleCov
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
1. Add simplecov-json to your `Gemfile` and `bundle install`:
|
8
|
+
|
9
|
+
gem 'simplecov-json', :require => false, :group => :test
|
10
|
+
|
11
|
+
2. Require simplecov-json and set it up as SimpleCov's formatter:
|
12
|
+
|
13
|
+
require 'simplecov-json'
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
|
15
|
+
|
16
|
+
## Result
|
17
|
+
|
18
|
+
Generated JSON can be found in coverage/coverage.json
|
19
|
+
|
20
|
+
The format you can expect is:
|
21
|
+
```json
|
22
|
+
{
|
23
|
+
"timestamp": 1348489587,
|
24
|
+
"command_name": "RSpec",
|
25
|
+
"files": [
|
26
|
+
{
|
27
|
+
"filename": "/home/user/rails/environment.rb",
|
28
|
+
"covered_percent": 50.0,
|
29
|
+
"coverage": [
|
30
|
+
null,
|
31
|
+
1,
|
32
|
+
null,
|
33
|
+
null,
|
34
|
+
1
|
35
|
+
],
|
36
|
+
"covered_strength": 0.50,
|
37
|
+
"covered_lines": 2,
|
38
|
+
"lines_of_code": 4
|
39
|
+
},
|
40
|
+
...
|
41
|
+
],
|
42
|
+
"metrics": {
|
43
|
+
"covered_percent": 81.70731707317073,
|
44
|
+
"covered_strength": 0.8170731707317073,
|
45
|
+
"covered_lines": 67,
|
46
|
+
"total_lines": 82
|
47
|
+
}
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
## Making Contributions
|
52
|
+
|
53
|
+
If you want to contribute, please:
|
54
|
+
|
55
|
+
* Fork the project.
|
56
|
+
* Make your feature addition or bug fix.
|
57
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
58
|
+
* Send me a pull request on Github.
|
59
|
+
* Check that travis build passes for your pull request.
|
60
|
+
|
61
|
+
|
62
|
+
## Copyright
|
63
|
+
|
64
|
+
Copyright (c) 2013 Mikael Llongo. See LICENSE for details.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @see SimpleCov https://github.com/colszowka/simplecov
|
4
|
+
module SimpleCov
|
5
|
+
# @see SimpleCov::Formatter https://github.com/colszowka/simplecov
|
6
|
+
module Formatter
|
7
|
+
#
|
8
|
+
# Formats Simplecov Results into a json file `coverage.json`
|
9
|
+
#
|
10
|
+
# @author Mikael Henriksson <mikael@mhenrixon.se>
|
11
|
+
#
|
12
|
+
class OjFormatter
|
13
|
+
#
|
14
|
+
# @return [String] name of the file with coverage.json data
|
15
|
+
FILE_NAME = "coverage.json"
|
16
|
+
|
17
|
+
#
|
18
|
+
# Formats the result as a hash, dump it to json with Oj and then save it to disk
|
19
|
+
#
|
20
|
+
# @param [SimpleCov::Result] result
|
21
|
+
#
|
22
|
+
# @return [<type>] <description>
|
23
|
+
#
|
24
|
+
def format(result)
|
25
|
+
json = dump_json(result)
|
26
|
+
puts SimpleCov::Oj::OutputMessage.new(result, output_filepath)
|
27
|
+
|
28
|
+
json
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @private
|
34
|
+
def dump_json(result)
|
35
|
+
data = SimpleCov::Oj::ResultToHash.new(result).to_h
|
36
|
+
json = ::Oj.dump(data, mode: :compat)
|
37
|
+
|
38
|
+
File.open(output_filepath, "w+") do |file|
|
39
|
+
file.puts json
|
40
|
+
end
|
41
|
+
|
42
|
+
json
|
43
|
+
end
|
44
|
+
|
45
|
+
# @private
|
46
|
+
def output_filename
|
47
|
+
FILE_NAME
|
48
|
+
end
|
49
|
+
|
50
|
+
# @private
|
51
|
+
def output_filepath
|
52
|
+
File.join(SimpleCov.coverage_path, output_filename)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
module Oj
|
5
|
+
#
|
6
|
+
# Generates a nicely formatted string about generated coverage
|
7
|
+
#
|
8
|
+
# @author Mikael Henriksson <mikael@mhenrixon.se>
|
9
|
+
#
|
10
|
+
class OutputMessage
|
11
|
+
#
|
12
|
+
# Initialize a new OutputMessage
|
13
|
+
#
|
14
|
+
# @param [SimplCov::Result] result the final simplecov result
|
15
|
+
# @param [String] output_filepath path to the filename
|
16
|
+
#
|
17
|
+
def initialize(result, output_filepath)
|
18
|
+
@result = result
|
19
|
+
@output_filepath = output_filepath
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Returns a nicely formatted string about the generated coverage data
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
#
|
28
|
+
def to_s
|
29
|
+
"Coverage report generated" \
|
30
|
+
" for #{command_name}" \
|
31
|
+
" to #{output_filepath}." \
|
32
|
+
" #{covered_lines} / #{total_lines} LOC (#{covered_percent.round(2)}%) covered."
|
33
|
+
end
|
34
|
+
alias inspect to_s
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :result, :output_filepath
|
39
|
+
|
40
|
+
def command_name
|
41
|
+
result.command_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def covered_lines
|
45
|
+
result.total_lines
|
46
|
+
end
|
47
|
+
|
48
|
+
def total_lines
|
49
|
+
result.total_lines
|
50
|
+
end
|
51
|
+
|
52
|
+
def covered_percent
|
53
|
+
result.covered_percent
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
module Oj
|
5
|
+
#
|
6
|
+
# Massage result into a hash that can be dumped to json by OJ
|
7
|
+
#
|
8
|
+
# @author Mikael Henriksson <mikael@mhenrixon.se>
|
9
|
+
#
|
10
|
+
class ResultToHash
|
11
|
+
#
|
12
|
+
# Initialize a new ResultToHash
|
13
|
+
#
|
14
|
+
# @param [SimpleCov::Result] result the final result from simplecov
|
15
|
+
#
|
16
|
+
def initialize(result)
|
17
|
+
@result = result
|
18
|
+
@data = {
|
19
|
+
timestamp: result.created_at.to_i,
|
20
|
+
command_name: result.command_name,
|
21
|
+
files: [],
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Create a hash from the result that can be used for JSON dumping
|
27
|
+
#
|
28
|
+
#
|
29
|
+
# @return [Hash]
|
30
|
+
#
|
31
|
+
def to_h
|
32
|
+
extract_files
|
33
|
+
extract_metrics
|
34
|
+
data
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :result, :data
|
40
|
+
|
41
|
+
# @private
|
42
|
+
def extract_files
|
43
|
+
data[:files] = source_file_collection
|
44
|
+
end
|
45
|
+
|
46
|
+
# @private
|
47
|
+
def source_file_collection
|
48
|
+
result.files.each_with_object([]) do |source_file, memo|
|
49
|
+
next unless result.filenames.include?(source_file.filename)
|
50
|
+
|
51
|
+
memo << SourceFileWrapper.new(source_file).to_h
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @private
|
56
|
+
def extract_metrics
|
57
|
+
data[:metrics] = ResultWrapper.new(result).to_h
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
module Oj
|
5
|
+
#
|
6
|
+
# Representation of the simplecov result including it's coverage data, source code,
|
7
|
+
# source lines and featuring helpers to interpret that data.
|
8
|
+
#
|
9
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
10
|
+
#
|
11
|
+
class ResultWrapper
|
12
|
+
#
|
13
|
+
# Wrap the SimpleCov::Result to enable hash conversion without monkey patching
|
14
|
+
#
|
15
|
+
# @param [SimpleCov::Result] result the simplecov result to generate hash for
|
16
|
+
#
|
17
|
+
def initialize(result)
|
18
|
+
@result = result
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Returns a nicely formatted hash from the simplecov result data
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# @return [Hash]
|
26
|
+
#
|
27
|
+
def to_h
|
28
|
+
{
|
29
|
+
covered_percent: covered_percent,
|
30
|
+
covered_strength: covered_strength,
|
31
|
+
covered_lines: covered_lines,
|
32
|
+
total_lines: total_lines,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :result
|
39
|
+
|
40
|
+
# @private
|
41
|
+
def covered_strength
|
42
|
+
return 0.0 unless (coverage = result.covered_strength)
|
43
|
+
|
44
|
+
coverage.nan? ? 0.0 : coverage
|
45
|
+
end
|
46
|
+
|
47
|
+
# @private
|
48
|
+
def covered_percent
|
49
|
+
result.covered_percent
|
50
|
+
end
|
51
|
+
|
52
|
+
# @private
|
53
|
+
def covered_lines
|
54
|
+
result.covered_lines
|
55
|
+
end
|
56
|
+
|
57
|
+
# @private
|
58
|
+
def total_lines
|
59
|
+
result.total_lines
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
module Oj
|
5
|
+
#
|
6
|
+
# Representation of a source file including it's coverage data, source code,
|
7
|
+
# source lines and featuring helpers to interpret that data.
|
8
|
+
#
|
9
|
+
# @author Mikael Henriksson <mikael@mhenrixon.com>
|
10
|
+
#
|
11
|
+
class SourceFileWrapper
|
12
|
+
#
|
13
|
+
# Wrap the SimpleCov::SourceFile to enable hash conversion without monkey patching
|
14
|
+
#
|
15
|
+
# @param [SimpleCov::SourceFile] source_file the source file to generate hash for
|
16
|
+
#
|
17
|
+
def initialize(source_file)
|
18
|
+
@source_file = source_file
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# Returns a nicely formatted hash from the source file data
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# @return [Hash]
|
26
|
+
#
|
27
|
+
def to_h
|
28
|
+
{ filename: filename,
|
29
|
+
covered_percent: covered_percent,
|
30
|
+
coverage: coverage_data,
|
31
|
+
covered_strength: covered_strength,
|
32
|
+
covered_lines: covered_lines_count,
|
33
|
+
lines_of_code: lines_of_code }
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :source_file
|
39
|
+
|
40
|
+
# @private
|
41
|
+
def coverage_data
|
42
|
+
if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
|
43
|
+
source_file.coverage_data
|
44
|
+
else
|
45
|
+
source_file.coverage
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @private
|
50
|
+
def covered_lines
|
51
|
+
source_file.covered_lines
|
52
|
+
end
|
53
|
+
|
54
|
+
# @private
|
55
|
+
def covered_lines_count
|
56
|
+
covered_lines.count
|
57
|
+
end
|
58
|
+
|
59
|
+
# @private
|
60
|
+
def covered_percent
|
61
|
+
source_file.covered_percent
|
62
|
+
end
|
63
|
+
|
64
|
+
# @private
|
65
|
+
def covered_strength
|
66
|
+
return 0.0 unless (coverage = source_file.covered_strength)
|
67
|
+
|
68
|
+
coverage.nan? ? 0.0 : coverage
|
69
|
+
end
|
70
|
+
|
71
|
+
# @private
|
72
|
+
def filename
|
73
|
+
source_file.filename
|
74
|
+
end
|
75
|
+
|
76
|
+
# @private
|
77
|
+
def lines_of_code
|
78
|
+
source_file.lines_of_code
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
#
|
5
|
+
# Module Oj provides formatting of simplecov results as JSON using the oj gem
|
6
|
+
#
|
7
|
+
# @author Mikael Henriksson <mikael@zoolutions.se>
|
8
|
+
#
|
9
|
+
module Oj
|
10
|
+
#
|
11
|
+
# @return [String] the current version of the gem
|
12
|
+
VERSION = "0.18.0"
|
13
|
+
end
|
14
|
+
end
|
data/lib/simplecov-oj.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simplecov"
|
4
|
+
require "oj"
|
5
|
+
|
6
|
+
require "simple_cov/oj/result_wrapper"
|
7
|
+
require "simple_cov/oj/source_file_wrapper"
|
8
|
+
require "simple_cov/oj/result_to_hash"
|
9
|
+
require "simple_cov/oj/result_to_hash"
|
10
|
+
require "simple_cov/oj/output_message"
|
11
|
+
require "simple_cov/oj/version"
|
12
|
+
require "simple_cov/formatter/oj_formatter"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
desc "Generate a Changelog"
|
4
|
+
task :changelog do
|
5
|
+
# rubocop:disable Style/MutableConstant
|
6
|
+
CHANGELOG_CMD ||= %w[
|
7
|
+
github_changelog_generator
|
8
|
+
--no-verbose
|
9
|
+
--no-http-cache
|
10
|
+
--user
|
11
|
+
mhenrixon
|
12
|
+
--project
|
13
|
+
simplecov-oj
|
14
|
+
--token
|
15
|
+
]
|
16
|
+
ADD_CHANGELOG_CMD ||= "git add --all"
|
17
|
+
COMMIT_CHANGELOG_CMD ||= "git commit -a -m 'Update changelog'"
|
18
|
+
# rubocop:enable Style/MutableConstant
|
19
|
+
|
20
|
+
sh("git checkout master")
|
21
|
+
sh(*CHANGELOG_CMD.push(ENV["CHANGELOG_GITHUB_TOKEN"]))
|
22
|
+
sh(ADD_CHANGELOG_CMD)
|
23
|
+
sh(COMMIT_CHANGELOG_CMD)
|
24
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe SimpleCov::Formatter::OjFormatter do
|
4
|
+
let(:formatter) { described_class.new }
|
5
|
+
let(:result) { instance_double(SimpleCov::Result) }
|
6
|
+
let(:command_name) { "RSpec" }
|
7
|
+
let(:created_at) { Time.now.to_s }
|
8
|
+
let(:foo) { instance_double(SimpleCov::SourceFile) }
|
9
|
+
let(:foo_line_list) { instance_double(Array) }
|
10
|
+
let(:bar) { instance_double(SimpleCov::SourceFile) }
|
11
|
+
let(:bar_line_list) { instance_double(Array) }
|
12
|
+
|
13
|
+
describe "#format" do
|
14
|
+
subject(:format) { formatter.format(result) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
allow(result).to receive(:created_at).and_return(created_at)
|
18
|
+
allow(result).to receive(:command_name).and_return(command_name)
|
19
|
+
allow(result).to receive(:covered_lines).and_return(11)
|
20
|
+
allow(result).to receive(:covered_percent).and_return(73.33)
|
21
|
+
allow(result).to receive(:covered_strength).twice.and_return(0.87)
|
22
|
+
allow(result).to receive(:files).and_return([foo, bar])
|
23
|
+
allow(result).to receive(:filenames).twice.and_return(["/lib/foo.rb", "/lib/bar.rb"])
|
24
|
+
allow(result).to receive(:total_lines).and_return(15)
|
25
|
+
|
26
|
+
allow(foo).to receive(:filename).twice.and_return("/lib/foo.rb")
|
27
|
+
allow(foo).to receive(:covered_percent).and_return(50.0)
|
28
|
+
if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
|
29
|
+
allow(foo).to receive(:coverage_data).and_return([1, nil, 0, 0, nil, 1, nil])
|
30
|
+
else
|
31
|
+
allow(foo).to receive(:coverage).and_return([1, nil, 0, 0, nil, 1, nil])
|
32
|
+
end
|
33
|
+
allow(foo).to receive(:covered_strength).twice.and_return(0.50)
|
34
|
+
allow(foo).to receive(:covered_lines).and_return(foo_line_list)
|
35
|
+
allow(foo).to receive(:lines_of_code).and_return(4)
|
36
|
+
|
37
|
+
allow(foo_line_list).to receive(:count).and_return(2)
|
38
|
+
|
39
|
+
allow(bar).to receive(:filename).twice.and_return("/lib/bar.rb")
|
40
|
+
allow(bar).to receive(:covered_percent).and_return(71.42)
|
41
|
+
if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
|
42
|
+
allow(bar).to receive(:coverage_data).and_return([nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
|
43
|
+
else
|
44
|
+
allow(bar).to receive(:coverage).and_return([nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
|
45
|
+
end
|
46
|
+
allow(bar).to receive(:covered_strength).twice.and_return(0.71)
|
47
|
+
allow(bar).to receive(:covered_lines).and_return(bar_line_list)
|
48
|
+
allow(bar).to receive(:lines_of_code).and_return(7)
|
49
|
+
|
50
|
+
allow(bar_line_list).to receive(:count).and_return(5)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "formats json nicely" do
|
54
|
+
expect(format).to eq({
|
55
|
+
"timestamp" => created_at.to_i,
|
56
|
+
"command_name" => "RSpec",
|
57
|
+
"files" => [
|
58
|
+
{ "filename" => "/lib/foo.rb",
|
59
|
+
"covered_percent" => 50.0,
|
60
|
+
"coverage" => [1, nil, 0, 0, nil, 1, nil],
|
61
|
+
"covered_strength" => 0.50,
|
62
|
+
"covered_lines" => 2,
|
63
|
+
"lines_of_code" => 4 },
|
64
|
+
{ "filename" => "/lib/bar.rb",
|
65
|
+
"covered_percent" => 71.42,
|
66
|
+
"coverage" => [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil],
|
67
|
+
"covered_strength" => 0.71,
|
68
|
+
"covered_lines" => 5,
|
69
|
+
"lines_of_code" => 7 },
|
70
|
+
],
|
71
|
+
"metrics" => {
|
72
|
+
"covered_percent" => 73.33,
|
73
|
+
"covered_strength" => 0.87,
|
74
|
+
"covered_lines" => 11,
|
75
|
+
"total_lines" => 15,
|
76
|
+
},
|
77
|
+
}.to_json)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "simplecov-oj"
|
4
|
+
require "pry"
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.define_derived_metadata do |meta|
|
8
|
+
meta[:aggregate_failures] = true
|
9
|
+
end
|
10
|
+
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.verify_partial_doubles = true
|
17
|
+
end
|
18
|
+
|
19
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
20
|
+
config.filter_run_when_matching :focus
|
21
|
+
config.example_status_persistence_file_path = "spec/.rspec-status"
|
22
|
+
config.disable_monkey_patching!
|
23
|
+
config.warnings = true
|
24
|
+
config.default_formatter = "doc" if config.files_to_run.one?
|
25
|
+
config.profile_examples = 10
|
26
|
+
config.order = :random
|
27
|
+
|
28
|
+
Kernel.srand config.seed
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 10_000
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simplecov-oj
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.18.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mikael Henriksson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oj
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: simplecov
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.14'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.14'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: appraisal
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: bundler
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.1'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '2.1'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: gem-release
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '13.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '13.0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rspec
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '3.9'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '3.9'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: github-markup
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '3.0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: github_changelog_generator
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '1.14'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.14'
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: yard
|
153
|
+
requirement: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0.9'
|
158
|
+
type: :development
|
159
|
+
prerelease: false
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "~>"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0.9'
|
165
|
+
description: 'Oj formatter for SimpleCov code coverage tool for ruby 2.4+
|
166
|
+
|
167
|
+
'
|
168
|
+
email:
|
169
|
+
- mikael@mhenrixon.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- CHANGELOG.md
|
175
|
+
- LICENSE
|
176
|
+
- README.md
|
177
|
+
- lib/simple_cov/formatter/oj_formatter.rb
|
178
|
+
- lib/simple_cov/oj/output_message.rb
|
179
|
+
- lib/simple_cov/oj/result_to_hash.rb
|
180
|
+
- lib/simple_cov/oj/result_wrapper.rb
|
181
|
+
- lib/simple_cov/oj/source_file_wrapper.rb
|
182
|
+
- lib/simple_cov/oj/version.rb
|
183
|
+
- lib/simplecov-oj.rb
|
184
|
+
- lib/tasks/changelog.rake
|
185
|
+
- spec/simple_cov/formatter/oj_formatter_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
homepage: https://github.com/mhenrixon/simplecov-oj
|
188
|
+
licenses:
|
189
|
+
- MIT
|
190
|
+
metadata:
|
191
|
+
homepage_uri: https://github.com/mhenrixon/simplecov-oj
|
192
|
+
bug_tracker_uri: https://github.com/mhenrixon/mhenrixon/issues
|
193
|
+
documentation_uri: https://mhenrixon.github.io/simplecov-oj
|
194
|
+
source_code_uri: https://github.com/mhenrixon/simplecov-oj
|
195
|
+
changelog_uri: https://github.com/mhenrixon/simplecov-oj/CHANGELOG.md
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubygems_version: 3.1.2
|
212
|
+
signing_key:
|
213
|
+
specification_version: 4
|
214
|
+
summary: Oj formatter for SimpleCov code coverage tool for ruby 2.4+
|
215
|
+
test_files:
|
216
|
+
- spec/spec_helper.rb
|
217
|
+
- spec/simple_cov/formatter/oj_formatter_spec.rb
|