simplecov-markdown 0.2.0 → 1.1.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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +51 -41
- data/README.md +42 -12
- data/lib/simplecov-markdown/version.rb +1 -1
- data/lib/simplecov-markdown.rb +45 -18
- data/simplecov-markdown.gemspec +5 -7
- data/spec/fixtures/expected_report.md.erb +11 -0
- data/spec/fixtures/sample1.rb +8 -4
- data/spec/fixtures/sample2.rb +8 -4
- data/spec/fixtures/sample3.rb +22 -0
- data/spec/simplecov-markdown_spec.rb +41 -9
- data/spec/spec_helper.rb +4 -4
- metadata +18 -46
- data/spec/fixtures/report.md.erb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f38d023d1882b61f76b7896c5afeaafe8136a61d19431cd6b30714e4908f4d04
|
|
4
|
+
data.tar.gz: f4f797601b506642c93f04d8ef541a2dfc7bf4b4dea5b5a890aa3d6549081638
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1d2bbf9c36651b81b7c22e121c5e727836a0215ffff4a3831803757e456746b89ec71f016db5c15c9cc122130b670cd34efb3a3892b61e7c6f052690bb052ee
|
|
7
|
+
data.tar.gz: 4da7f098aae3329e934d12a21b16e30c76b16a5a145132d1d03f445b1a5273669adef416e0b3f0250644a94e0012df9cf2bb78f5362d70aa357d7e345fe9ebe6
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
ruby-version: ['3.2', '3.3', '4.0']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
20
|
+
uses: ruby/setup-ruby@v1
|
|
21
|
+
with:
|
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
23
|
+
bundler-cache: true
|
|
24
|
+
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: bundle exec rspec
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.0.1
|
data/Gemfile.lock
CHANGED
|
@@ -1,64 +1,74 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simplecov-markdown (
|
|
4
|
+
simplecov-markdown (1.1.0)
|
|
5
5
|
simplecov
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
10
|
ansi (1.5.0)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rake (10.5.0)
|
|
22
|
-
rspec (3.5.0)
|
|
23
|
-
rspec-core (~> 3.5.0)
|
|
24
|
-
rspec-expectations (~> 3.5.0)
|
|
25
|
-
rspec-mocks (~> 3.5.0)
|
|
26
|
-
rspec-core (3.5.3)
|
|
27
|
-
rspec-support (~> 3.5.0)
|
|
28
|
-
rspec-expectations (3.5.0)
|
|
11
|
+
diff-lcs (1.6.2)
|
|
12
|
+
docile (1.4.1)
|
|
13
|
+
rake (13.3.1)
|
|
14
|
+
rspec (3.13.2)
|
|
15
|
+
rspec-core (~> 3.13.0)
|
|
16
|
+
rspec-expectations (~> 3.13.0)
|
|
17
|
+
rspec-mocks (~> 3.13.0)
|
|
18
|
+
rspec-core (3.13.6)
|
|
19
|
+
rspec-support (~> 3.13.0)
|
|
20
|
+
rspec-expectations (3.13.5)
|
|
29
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
-
rspec-support (~> 3.
|
|
31
|
-
rspec-mocks (3.
|
|
22
|
+
rspec-support (~> 3.13.0)
|
|
23
|
+
rspec-mocks (3.13.8)
|
|
32
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
33
|
-
rspec-support (~> 3.
|
|
34
|
-
rspec-support (3.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
simplecov-html (~> 0.10.0)
|
|
41
|
-
simplecov-console (0.3.1)
|
|
25
|
+
rspec-support (~> 3.13.0)
|
|
26
|
+
rspec-support (3.13.7)
|
|
27
|
+
simplecov (0.22.0)
|
|
28
|
+
docile (~> 1.1)
|
|
29
|
+
simplecov-html (~> 0.11)
|
|
30
|
+
simplecov_json_formatter (~> 0.1)
|
|
31
|
+
simplecov-console (0.9.5)
|
|
42
32
|
ansi
|
|
43
|
-
hirb
|
|
44
33
|
simplecov
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
terminal-table
|
|
35
|
+
simplecov-html (0.13.2)
|
|
36
|
+
simplecov_json_formatter (0.1.4)
|
|
37
|
+
terminal-table (4.0.0)
|
|
38
|
+
unicode-display_width (>= 1.1.1, < 4)
|
|
39
|
+
unicode-display_width (3.2.0)
|
|
40
|
+
unicode-emoji (~> 4.1)
|
|
41
|
+
unicode-emoji (4.2.0)
|
|
50
42
|
|
|
51
43
|
PLATFORMS
|
|
44
|
+
arm64-darwin-25
|
|
52
45
|
ruby
|
|
53
46
|
|
|
54
47
|
DEPENDENCIES
|
|
55
|
-
bundler (
|
|
56
|
-
|
|
57
|
-
rake (~> 10.0)
|
|
48
|
+
bundler (>= 2.0)
|
|
49
|
+
rake (>= 10.0)
|
|
58
50
|
rspec
|
|
59
|
-
rspec-temp_dir (~> 0.0.3)
|
|
60
51
|
simplecov-console
|
|
61
52
|
simplecov-markdown!
|
|
62
53
|
|
|
54
|
+
CHECKSUMS
|
|
55
|
+
ansi (1.5.0) sha256=5408253274e33d9d27d4a98c46d2998266fd51cba58a7eb9d08f50e57ed23592
|
|
56
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
57
|
+
docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
|
|
58
|
+
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
|
|
59
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
60
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
61
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
62
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
63
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
64
|
+
simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
|
|
65
|
+
simplecov-console (0.9.5) sha256=b1108bcfff5f210143e2b8301698c367b01586f20d25a73e95475a5df6fc6ff6
|
|
66
|
+
simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
|
|
67
|
+
simplecov-markdown (1.1.0)
|
|
68
|
+
simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
|
|
69
|
+
terminal-table (4.0.0) sha256=f504793203f8251b2ea7c7068333053f0beeea26093ec9962e62ea79f94301d2
|
|
70
|
+
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
71
|
+
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
72
|
+
|
|
63
73
|
BUNDLED WITH
|
|
64
|
-
|
|
74
|
+
4.0.5
|
data/README.md
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
|
-
SimpleCov Markdown Formatter
|
|
2
|
-
==================================
|
|
1
|
+
# SimpleCov Markdown Formatter
|
|
3
2
|
|
|
4
|
-
[](
|
|
5
|
-
[](https://coveralls.io/r/holyshared/simplecov-markdown)
|
|
7
|
-
[](https://codeclimate.com/github/holyshared/simplecov-markdown)
|
|
3
|
+
[](https://badge.fury.io/rb/simplecov-markdown)
|
|
4
|
+
[](https://github.com/renuo/simplecov-markdown/actions/workflows/ci.yml)
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
----------------------------
|
|
6
|
+
Adds a report in markdown format. This can be useful in CI context or for LLMs.
|
|
11
7
|
|
|
12
|
-
|
|
8
|
+
## Install
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
```
|
|
11
|
+
gem install simplecov-markdown
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
16
15
|
|
|
17
16
|
```ruby
|
|
18
|
-
require 'simplecov-
|
|
17
|
+
require 'simplecov-markdown'
|
|
19
18
|
SimpleCov.formatter = SimpleCov::Formatter::MarkdownFormatter
|
|
20
19
|
```
|
|
20
|
+
|
|
21
|
+
if you want to configure multiple formatters:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
|
25
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
26
|
+
SimpleCov::Formatter::MarkdownFormatter
|
|
27
|
+
])
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Alternatives
|
|
31
|
+
|
|
32
|
+
LLMs and CI environments work well also with [simplecov-console](https://github.com/chetan/simplecov-console).
|
|
33
|
+
|
|
34
|
+
## Changelog
|
|
35
|
+
|
|
36
|
+
### 1.1.0
|
|
37
|
+
|
|
38
|
+
- **Support branch coverage**
|
|
39
|
+
|
|
40
|
+
### 1.0.0
|
|
41
|
+
|
|
42
|
+
- **Sorted results by coverage** — files are now sorted ascending by coverage percentage, so the least covered files appear first
|
|
43
|
+
- **Missing line numbers** — the report now includes a "Missing line numbers" column listing the exact line numbers not covered, instead of just a count
|
|
44
|
+
- **Revised table columns** — columns reordered and renamed: `Coverage`, `File`, `Total lines`, `Total missed`, `Missing line numbers`
|
|
45
|
+
- **Ruby 4.0 support** — tested against Ruby 3.2, 3.3, and 4.0 via GitHub Actions CI
|
|
46
|
+
- **Dropped legacy dependencies** — removed `coveralls`, `rspec-temp_dir`, and loosened `bundler`/`rake` version constraints
|
|
47
|
+
|
|
48
|
+
### 0.2.0
|
|
49
|
+
|
|
50
|
+
Initial release by [holyshared](https://github.com/holyshared/simplecov-markdown).
|
data/lib/simplecov-markdown.rb
CHANGED
|
@@ -8,6 +8,7 @@ class SimpleCov::Formatter::MarkdownFormatter
|
|
|
8
8
|
report_writer.write_result(result)
|
|
9
9
|
report_writer.destroy!
|
|
10
10
|
end
|
|
11
|
+
|
|
11
12
|
def self.output_path
|
|
12
13
|
File.join(SimpleCov.coverage_path, 'report.md')
|
|
13
14
|
end
|
|
@@ -17,7 +18,6 @@ class SimpleCov::Formatter::MarkdownFormatter
|
|
|
17
18
|
|
|
18
19
|
def initialize(report_path)
|
|
19
20
|
@report = File.open(report_path, 'w')
|
|
20
|
-
@table_writer = TableWriter.new(report)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def write_header(title)
|
|
@@ -33,44 +33,71 @@ class SimpleCov::Formatter::MarkdownFormatter
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def write_result(result)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
branch_coverage_enabled = result.files.any? { |f| f.total_branches.any? }
|
|
37
|
+
table_writer = TableWriter.new(@report, branch_coverage: branch_coverage_enabled)
|
|
38
|
+
table_writer.write_header
|
|
39
|
+
result.files.sort_by(&:covered_percent).each do |file|
|
|
40
|
+
missing_lines = format_line_numbers(file.missed_lines.map(&:line_number))
|
|
41
|
+
args = [
|
|
40
42
|
file.covered_percent.round(2).to_s + "%",
|
|
41
|
-
file.
|
|
43
|
+
relative_path(file.filename),
|
|
44
|
+
file.lines_of_code,
|
|
42
45
|
file.missed_lines.size,
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
missing_lines
|
|
47
|
+
]
|
|
48
|
+
if branch_coverage_enabled
|
|
49
|
+
missing_branches = file.missed_branches.map { |b| "#{b.start_line}[#{b.type}]" }.join(", ")
|
|
50
|
+
args += [file.branches_coverage_percent.round(2).to_s + "%", missing_branches]
|
|
51
|
+
end
|
|
52
|
+
table_writer.write_record(*args)
|
|
45
53
|
end
|
|
46
|
-
|
|
54
|
+
table_writer.destroy!
|
|
47
55
|
end
|
|
48
56
|
|
|
49
57
|
def destroy!
|
|
50
58
|
@report.close
|
|
51
59
|
@report = nil
|
|
52
60
|
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def relative_path(filename)
|
|
65
|
+
filename.delete_prefix(SimpleCov.root + "/")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def format_line_numbers(line_numbers)
|
|
69
|
+
return "" if line_numbers.empty?
|
|
70
|
+
|
|
71
|
+
line_numbers.chunk_while { |a, b| b == a + 1 }.map do |group|
|
|
72
|
+
group.size >= 2 ? "#{group.first}-#{group.last}" : group.first.to_s
|
|
73
|
+
end.join(", ")
|
|
74
|
+
end
|
|
53
75
|
end
|
|
54
76
|
|
|
55
77
|
class TableWriter
|
|
56
78
|
attr_reader :report, :columns_headers, :columns_header_aligns
|
|
57
79
|
|
|
58
|
-
def initialize(report)
|
|
80
|
+
def initialize(report, branch_coverage: false)
|
|
59
81
|
@report = report
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
if branch_coverage
|
|
83
|
+
@columns_headers = ["Coverage", "File", "Total lines", "Total missed", "Missing line numbers", "Branch coverage", "Missing branches"]
|
|
84
|
+
@columns_header_aligns = [:right, :left, :right, :right, :left, :right, :left]
|
|
85
|
+
else
|
|
86
|
+
@columns_headers = ["Coverage", "File", "Total lines", "Total missed", "Missing line numbers"]
|
|
87
|
+
@columns_header_aligns = [:right, :left, :right, :right, :left]
|
|
88
|
+
end
|
|
62
89
|
end
|
|
63
90
|
|
|
64
91
|
def write_header
|
|
65
92
|
write_values @columns_headers
|
|
66
93
|
headers = @columns_header_aligns.map do |align|
|
|
67
94
|
case align
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
95
|
+
when :left
|
|
96
|
+
":--"
|
|
97
|
+
when :right
|
|
98
|
+
"--:"
|
|
99
|
+
else
|
|
100
|
+
"--"
|
|
74
101
|
end
|
|
75
102
|
end
|
|
76
103
|
write_values headers
|
data/simplecov-markdown.gemspec
CHANGED
|
@@ -6,11 +6,11 @@ require 'simplecov-markdown/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "simplecov-markdown"
|
|
8
8
|
spec.version = SimpleCov::Formatter::MarkdownFormatter::VERSION
|
|
9
|
-
spec.authors = ["
|
|
10
|
-
spec.email = ["
|
|
9
|
+
spec.authors = ["Alessandro Rodi"]
|
|
10
|
+
spec.email = ["alessandro.rodi@renuo.ch"]
|
|
11
11
|
spec.summary = "Markdown formatter for simplecov"
|
|
12
12
|
spec.description = "Markdown formatter for simplecov"
|
|
13
|
-
spec.homepage = "https://github.com/
|
|
13
|
+
spec.homepage = "https://github.com/renuo/simplecov-markdown"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
|
@@ -20,10 +20,8 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
|
|
21
21
|
spec.add_dependency 'simplecov'
|
|
22
22
|
|
|
23
|
-
spec.add_development_dependency "
|
|
24
|
-
spec.add_development_dependency "
|
|
25
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "bundler", ">= 2.0"
|
|
24
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
|
26
25
|
spec.add_development_dependency "rspec"
|
|
27
|
-
spec.add_development_dependency "coveralls"
|
|
28
26
|
spec.add_development_dependency "simplecov-console"
|
|
29
27
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Code Coverage Report
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
Project name: <%= project_name %>
|
|
5
|
+
Created at: <%= created_at %>
|
|
6
|
+
|
|
7
|
+
|Coverage|File|Total lines|Total missed|Missing line numbers|Branch coverage|Missing branches|
|
|
8
|
+
|--:|:--|--:|--:|:--|--:|:--|
|
|
9
|
+
|54.55%|<%= root_directory.delete_prefix(SimpleCov.root + "/") %>/fixtures/sample3.rb|11|5|11, 15-17, 19|25.0%|11[else], 17[then], 19[else]|
|
|
10
|
+
|85.71%|<%= root_directory.delete_prefix(SimpleCov.root + "/") %>/fixtures/sample2.rb|7|1|11|50.0%|11[else]|
|
|
11
|
+
|100.0%|<%= root_directory.delete_prefix(SimpleCov.root + "/") %>/fixtures/sample1.rb|7|0||100.0%||
|
data/spec/fixtures/sample1.rb
CHANGED
data/spec/fixtures/sample2.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Sample3 class
|
|
2
|
+
class Sample3
|
|
3
|
+
def initialize(value)
|
|
4
|
+
@value = value
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def describe
|
|
8
|
+
if @value > 0
|
|
9
|
+
"positive"
|
|
10
|
+
else
|
|
11
|
+
"non-positive"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def check
|
|
16
|
+
if @value.zero?
|
|
17
|
+
"zero"
|
|
18
|
+
else
|
|
19
|
+
"non-zero"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,38 +1,70 @@
|
|
|
1
1
|
require 'simplecov'
|
|
2
2
|
require 'erb'
|
|
3
|
-
require 'rspec/temp_dir'
|
|
4
3
|
|
|
5
|
-
describe 'MarkdownFormatter' do
|
|
6
|
-
|
|
4
|
+
RSpec.describe 'MarkdownFormatter' do
|
|
5
|
+
let(:report_path) { File.expand_path('../../tmp/report.md', __FILE__) }
|
|
7
6
|
|
|
8
7
|
let(:formatter) do
|
|
9
8
|
allow(SimpleCov::Formatter::MarkdownFormatter).to receive(:output_path).and_return(report_path)
|
|
10
9
|
SimpleCov::Formatter::MarkdownFormatter.new
|
|
11
10
|
end
|
|
12
|
-
|
|
13
|
-
let(:
|
|
11
|
+
|
|
12
|
+
let(:expected_report) do
|
|
14
13
|
root_directory = File.dirname(__FILE__)
|
|
15
14
|
project_name = SimpleCov.project_name
|
|
16
15
|
created_at = result.created_at
|
|
17
|
-
erb_script = File.open(File.join(File.dirname(__FILE__), 'fixtures/
|
|
16
|
+
erb_script = File.open(File.join(File.dirname(__FILE__), 'fixtures/expected_report.md.erb')).read
|
|
18
17
|
ERB.new(erb_script).result(binding)
|
|
19
18
|
end
|
|
19
|
+
|
|
20
20
|
let(:result) do
|
|
21
21
|
sample1 = File.join(File.dirname(__FILE__), 'fixtures', 'sample1.rb')
|
|
22
22
|
sample2 = File.join(File.dirname(__FILE__), 'fixtures', 'sample2.rb')
|
|
23
|
+
sample3 = File.join(File.dirname(__FILE__), 'fixtures', 'sample3.rb')
|
|
23
24
|
|
|
24
25
|
original_result = {
|
|
25
|
-
sample1 =>
|
|
26
|
-
|
|
26
|
+
sample1 => {
|
|
27
|
+
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, 1, nil, 1, nil, nil, nil],
|
|
28
|
+
"branches" => {
|
|
29
|
+
[:if, 0, 8, 4, 12, 7] => {
|
|
30
|
+
[:then, 0, 9, 6, 9, 14] => 1,
|
|
31
|
+
[:else, 0, 11, 6, 11, 19] => 1
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
sample2 => {
|
|
36
|
+
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, 1, nil, 0, nil, nil, nil],
|
|
37
|
+
"branches" => {
|
|
38
|
+
[:if, 0, 8, 4, 12, 7] => {
|
|
39
|
+
[:then, 0, 9, 6, 9, 14] => 1,
|
|
40
|
+
[:else, 0, 11, 6, 11, 19] => 0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
sample3 => {
|
|
45
|
+
"lines" => [nil, 1, 1, 1, nil, nil, 1, 1, 1, nil, 0, nil, nil, nil, 0, 0, 0, nil, 0, nil, nil, nil],
|
|
46
|
+
"branches" => {
|
|
47
|
+
[:if, 0, 8, 4, 12, 7] => {
|
|
48
|
+
[:then, 0, 9, 6, 9, 14] => 1,
|
|
49
|
+
[:else, 0, 11, 6, 11, 19] => 0
|
|
50
|
+
},
|
|
51
|
+
[:if, 1, 16, 4, 20, 7] => {
|
|
52
|
+
[:then, 0, 17, 6, 17, 10] => 0,
|
|
53
|
+
[:else, 0, 19, 6, 19, 14] => 0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
27
57
|
}
|
|
28
58
|
SimpleCov::Result.new(original_result)
|
|
29
59
|
end
|
|
30
60
|
|
|
61
|
+
before { FileUtils.mkdir_p(File.dirname(report_path)) }
|
|
62
|
+
|
|
31
63
|
describe '#result' do
|
|
32
64
|
it 'format by markdown' do
|
|
33
65
|
formatter.format(result)
|
|
34
66
|
actual_report = File.open(report_path).read
|
|
35
|
-
expect(actual_report).to
|
|
67
|
+
expect(actual_report).to eq(expected_report)
|
|
36
68
|
end
|
|
37
69
|
end
|
|
38
70
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -2,12 +2,11 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
|
2
2
|
require 'simplecov'
|
|
3
3
|
require 'simplecov-console'
|
|
4
4
|
|
|
5
|
-
SimpleCov.
|
|
6
|
-
|
|
5
|
+
SimpleCov.start do
|
|
6
|
+
enable_coverage :branch
|
|
7
|
+
add_filter { |f| f.filename =~ /spec/ && !(f.filename =~ /fixtures/) }
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
SimpleCov.start
|
|
10
|
-
|
|
11
10
|
require 'simplecov-markdown'
|
|
12
11
|
|
|
13
12
|
if ENV["COVERALLS_REPO_TOKEN"]
|
|
@@ -15,6 +14,7 @@ if ENV["COVERALLS_REPO_TOKEN"]
|
|
|
15
14
|
Coveralls.wear!
|
|
16
15
|
else
|
|
17
16
|
SimpleCov.formatters = [
|
|
17
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
18
18
|
SimpleCov::Formatter::Console,
|
|
19
19
|
SimpleCov::Formatter::MarkdownFormatter
|
|
20
20
|
]
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simplecov-markdown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Alessandro Rodi
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: simplecov
|
|
@@ -24,46 +23,32 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rspec-temp_dir
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.0.3
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.0.3
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
27
|
name: bundler
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
44
29
|
requirements:
|
|
45
|
-
- - "
|
|
30
|
+
- - ">="
|
|
46
31
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
32
|
+
version: '2.0'
|
|
48
33
|
type: :development
|
|
49
34
|
prerelease: false
|
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
36
|
requirements:
|
|
52
|
-
- - "
|
|
37
|
+
- - ">="
|
|
53
38
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
39
|
+
version: '2.0'
|
|
55
40
|
- !ruby/object:Gem::Dependency
|
|
56
41
|
name: rake
|
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
|
58
43
|
requirements:
|
|
59
|
-
- - "
|
|
44
|
+
- - ">="
|
|
60
45
|
- !ruby/object:Gem::Version
|
|
61
46
|
version: '10.0'
|
|
62
47
|
type: :development
|
|
63
48
|
prerelease: false
|
|
64
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
50
|
requirements:
|
|
66
|
-
- - "
|
|
51
|
+
- - ">="
|
|
67
52
|
- !ruby/object:Gem::Version
|
|
68
53
|
version: '10.0'
|
|
69
54
|
- !ruby/object:Gem::Dependency
|
|
@@ -80,20 +65,6 @@ dependencies:
|
|
|
80
65
|
- - ">="
|
|
81
66
|
- !ruby/object:Gem::Version
|
|
82
67
|
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: coveralls
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
97
68
|
- !ruby/object:Gem::Dependency
|
|
98
69
|
name: simplecov-console
|
|
99
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -110,14 +81,16 @@ dependencies:
|
|
|
110
81
|
version: '0'
|
|
111
82
|
description: Markdown formatter for simplecov
|
|
112
83
|
email:
|
|
113
|
-
-
|
|
84
|
+
- alessandro.rodi@renuo.ch
|
|
114
85
|
executables: []
|
|
115
86
|
extensions: []
|
|
116
87
|
extra_rdoc_files: []
|
|
117
88
|
files:
|
|
118
89
|
- ".coveralls.yml"
|
|
90
|
+
- ".github/workflows/ci.yml"
|
|
119
91
|
- ".gitignore"
|
|
120
92
|
- ".rspec"
|
|
93
|
+
- ".ruby-version"
|
|
121
94
|
- ".travis.yml"
|
|
122
95
|
- Gemfile
|
|
123
96
|
- Gemfile.lock
|
|
@@ -127,16 +100,16 @@ files:
|
|
|
127
100
|
- lib/simplecov-markdown.rb
|
|
128
101
|
- lib/simplecov-markdown/version.rb
|
|
129
102
|
- simplecov-markdown.gemspec
|
|
130
|
-
- spec/fixtures/
|
|
103
|
+
- spec/fixtures/expected_report.md.erb
|
|
131
104
|
- spec/fixtures/sample1.rb
|
|
132
105
|
- spec/fixtures/sample2.rb
|
|
106
|
+
- spec/fixtures/sample3.rb
|
|
133
107
|
- spec/simplecov-markdown_spec.rb
|
|
134
108
|
- spec/spec_helper.rb
|
|
135
|
-
homepage: https://github.com/
|
|
109
|
+
homepage: https://github.com/renuo/simplecov-markdown
|
|
136
110
|
licenses:
|
|
137
111
|
- MIT
|
|
138
112
|
metadata: {}
|
|
139
|
-
post_install_message:
|
|
140
113
|
rdoc_options: []
|
|
141
114
|
require_paths:
|
|
142
115
|
- lib
|
|
@@ -151,14 +124,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
124
|
- !ruby/object:Gem::Version
|
|
152
125
|
version: '0'
|
|
153
126
|
requirements: []
|
|
154
|
-
|
|
155
|
-
rubygems_version: 2.5.1
|
|
156
|
-
signing_key:
|
|
127
|
+
rubygems_version: 4.0.3
|
|
157
128
|
specification_version: 4
|
|
158
129
|
summary: Markdown formatter for simplecov
|
|
159
130
|
test_files:
|
|
160
|
-
- spec/fixtures/
|
|
131
|
+
- spec/fixtures/expected_report.md.erb
|
|
161
132
|
- spec/fixtures/sample1.rb
|
|
162
133
|
- spec/fixtures/sample2.rb
|
|
134
|
+
- spec/fixtures/sample3.rb
|
|
163
135
|
- spec/simplecov-markdown_spec.rb
|
|
164
136
|
- spec/spec_helper.rb
|
data/spec/fixtures/report.md.erb
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Code Coverage Report
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
Project name: <%= project_name %>
|
|
5
|
-
Created at: <%= created_at %>
|
|
6
|
-
|
|
7
|
-
|File|Coverage|Covered|Missed|Total|
|
|
8
|
-
|:--|--:|--:|--:|--:|
|
|
9
|
-
|<%= root_directory %>/fixtures/sample1.rb|100.0%|5|0|5|
|
|
10
|
-
|<%= root_directory %>/fixtures/sample2.rb|80.0%|4|1|5|
|