simplecov-shield-json 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01c9721262cad024c222b265ad16e893b80c4a110622282e18c049a0f650046f
4
- data.tar.gz: 31477a0965102557aea98f772b8da3076983e0aa9b4dc6cd1f0c8085933e5943
3
+ metadata.gz: e4ae7844bac6556edaf7ad55d133aa73c7965acb9b43f57a083217688dfca11d
4
+ data.tar.gz: b61e4964ffd48ed08bcbbd538dc2e0731000125265b89e0bfbddba44ce72dc5c
5
5
  SHA512:
6
- metadata.gz: b430ce2eb68efe48fb04090c8a883ae12e3b6116fed4654d5a825d87040dad46cb6511c10dabcd7f5dddd8d05adfead1ff68862d39d33ec49253ab92ab9820bc
7
- data.tar.gz: 7423ce6678125ee7263cc609cc17fc1c707531762d57894e624661a9a4b6feee7d249068ea6c8909dc8479cdf72e6930a5a3bc8a6c816ada04c9857499a5ef12
6
+ metadata.gz: e62cee88e3a0b2282db85c42b7873ac3ed882909dd926de9d1f51749c7e8aaca71400c2ffcca5838ae8eee6eae9cc5a8d153b896af4771cd543f85fa626d4fe3
7
+ data.tar.gz: c5daca06b0d90819da609c8c8f4d8429e847657984c5f1864402ff9a267ed86ae477fa4b9062b2e2b3f44e991bc5000488ef6c1b3613616ceaa09b04cde39bb4
@@ -3,7 +3,7 @@
3
3
  module SimpleCov
4
4
  module Formatter
5
5
  class ShieldJSONFormatter
6
- VERSION = '0.0.5'
6
+ VERSION = '0.0.6'
7
7
  end
8
8
  end
9
9
  end
@@ -3,8 +3,44 @@
3
3
  require File.expand_path('../../lib/simplecov-shield-json', __dir__)
4
4
  require File.expand_path('../spec_helper', __dir__)
5
5
 
6
+ # rubocop:disable Metrics/BlockLength
6
7
  describe SimpleCov::Formatter::ShieldJSONFormatter do
8
+ shared_examples 'percentage color' do |percentage, color|
9
+ context 'generating report' do
10
+ before do
11
+ allow(simplecov_result).to receive(:covered_percent).and_return(percentage)
12
+ end
13
+
14
+ it "with #{percentage} should return #{color}" do
15
+ expect(described_class.new.format(simplecov_result)).to eq(
16
+ {
17
+ 'schemaVersion': 1,
18
+ 'label': 'Coverage',
19
+ 'message': "#{percentage}%",
20
+ 'color': color,
21
+ 'cacheSeconds': 1800
22
+ }.to_json
23
+ )
24
+ end
25
+ end
26
+ end
27
+
7
28
  it 'should be a class' do
8
29
  expect(described_class.new).to be_a SimpleCov::Formatter::ShieldJSONFormatter
9
30
  end
31
+
32
+ context '#format' do
33
+ let(:simplecov_result) { double('SimpleCov::Result') }
34
+
35
+ before do
36
+ allow(simplecov_result).to receive(:command_name).and_return('RSpec')
37
+ allow(simplecov_result).to receive(:covered_lines).and_return(3214)
38
+ allow(simplecov_result).to receive(:total_lines).and_return(2714)
39
+ end
40
+
41
+ it_behaves_like 'percentage color', 90.12, 'brightgreen'
42
+ it_behaves_like 'percentage color', 83.09, 'yellow'
43
+ it_behaves_like 'percentage color', 51.98, 'red'
44
+ end
10
45
  end
46
+ # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-shield-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Pereira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-08 00:00:00.000000000 Z
11
+ date: 2020-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json