simplecov-oj 0.18.2 → 0.18.3

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: fb418a561162036e2741a76baef6dba8ab9339c915970f32428232127e0dce86
4
- data.tar.gz: 798f34594159560b6f64fd0f69b799c2a428add53275e88d292622244ccf3433
3
+ metadata.gz: c79725e77c65ffc720f386f1fc92a5bb131c3ed85253f5020b211397cf51c864
4
+ data.tar.gz: 41c1cf717b408c4b6e8e7abf1504178d2d020b662d6a256cd55b7477d301ab4c
5
5
  SHA512:
6
- metadata.gz: 13a883c1bc3c5e070262350b838a6ba9ef777b6e4b67b6549a1b63d1c2a8e6b1ea7c507391e9150f5b86a1863f8fed31b2444e0bae5c09a8ba591d3b980feec1
7
- data.tar.gz: 3c028c0280f7eba299e0ffc2d3143c4fb415d00ea7e09a1bb223684d2bcbd4b3a9e4f23d7a6aaed331f3207b3312cf20b9f4316069629bef4140f7ffd956fb29
6
+ metadata.gz: ea9788ab04d7a288938cfd83298991d94b24801acfe9397809345a0c200ad5e2c05ffde92e6079477bdbe2806cdac203f59c9f9767998c94ec6a5d1f91a92f1f
7
+ data.tar.gz: 1a5cc01c0056abada359228d2681fb50d67c2a17f75597241908e33b4004d06c5b3804ed60b353489105cad1ff81dd98cc3108c4fe1d1ae412433e5406deec9a
@@ -42,14 +42,9 @@ module SimpleCov
42
42
  json
43
43
  end
44
44
 
45
- # @private
46
- def output_filename
47
- FILE_NAME
48
- end
49
-
50
45
  # @private
51
46
  def output_filepath
52
- File.join(SimpleCov.coverage_path, output_filename)
47
+ File.join(SimpleCov.coverage_path, FILE_NAME)
53
48
  end
54
49
  end
55
50
  end
@@ -39,11 +39,18 @@ module SimpleCov
39
39
 
40
40
  # @private
41
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
42
+ return coverage if coverage.is_a?(Array)
43
+
44
+ coverage['lines']
45
+ end
46
+
47
+ def coverage
48
+ @coverage ||=
49
+ if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
50
+ source_file.coverage_data
51
+ else
52
+ source_file.coverage
53
+ end
47
54
  end
48
55
 
49
56
  # @private
@@ -9,6 +9,6 @@ module SimpleCov
9
9
  module Oj
10
10
  #
11
11
  # @return [String] the current version of the gem
12
- VERSION = '0.18.2'
12
+ VERSION = '0.18.3'
13
13
  end
14
14
  end
@@ -1,19 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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) }
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(:foo_coverage_data) { [1, nil, 0, 0, nil, 1, nil] }
11
+ let(:bar) { instance_double(SimpleCov::SourceFile) }
12
+ let(:bar_line_list) { instance_double(Array) }
13
+ let(:bar_coverage_data) { [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil] }
12
14
 
13
15
  describe '#format' do
14
16
  subject(:format) { formatter.format(result) }
15
17
 
16
- let(:formatted_hash) do
18
+ let(:expected_hash) do
17
19
  {
18
20
  'timestamp' => created_at.to_i,
19
21
  'command_name' => 'RSpec',
@@ -53,9 +55,9 @@ RSpec.describe SimpleCov::Formatter::OjFormatter do
53
55
  allow(foo).to receive(:filename).twice.and_return('/lib/foo.rb')
54
56
  allow(foo).to receive(:covered_percent).and_return(50.0)
55
57
  if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
56
- allow(foo).to receive(:coverage_data).and_return([1, nil, 0, 0, nil, 1, nil])
58
+ allow(foo).to receive(:coverage_data).and_return(foo_coverage_data)
57
59
  else
58
- allow(foo).to receive(:coverage).and_return([1, nil, 0, 0, nil, 1, nil])
60
+ allow(foo).to receive(:coverage).and_return(foo_coverage_data)
59
61
  end
60
62
  allow(foo).to receive(:covered_strength).twice.and_return(0.50)
61
63
  allow(foo).to receive(:covered_lines).and_return(foo_line_list)
@@ -66,9 +68,9 @@ RSpec.describe SimpleCov::Formatter::OjFormatter do
66
68
  allow(bar).to receive(:filename).twice.and_return('/lib/bar.rb')
67
69
  allow(bar).to receive(:covered_percent).and_return(71.42)
68
70
  if SimpleCov::SourceFile.instance_methods.include?(:coverage_data)
69
- allow(bar).to receive(:coverage_data).and_return([nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
71
+ allow(bar).to receive(:coverage_data).and_return(bar_coverage_data)
70
72
  else
71
- allow(bar).to receive(:coverage).and_return([nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
73
+ allow(bar).to receive(:coverage).and_return(bar_coverage_data)
72
74
  end
73
75
  allow(bar).to receive(:covered_strength).twice.and_return(0.71)
74
76
  allow(bar).to receive(:covered_lines).and_return(bar_line_list)
@@ -77,6 +79,13 @@ RSpec.describe SimpleCov::Formatter::OjFormatter do
77
79
  allow(bar_line_list).to receive(:count).and_return(5)
78
80
  end
79
81
 
80
- it { is_expected.to eq(formatted_hash) }
82
+ it { is_expected.to be_json_eql(expected_hash) }
83
+
84
+ context 'when coverage_data is a hash with the key `lines:`' do
85
+ let(:foo_coverage_data) { { lines: [1, nil, 0, 0, nil, 1, nil] } }
86
+ let(:bar_coverage_data) { { lines: [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil] } }
87
+
88
+ it { is_expected.to be_json_eql(expected_hash) }
89
+ end
81
90
  end
82
91
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'simplecov-oj'
3
+ require 'bundler/setup'
4
+ require 'simplecov'
5
+
4
6
  require 'pry'
7
+ require 'rspec'
8
+ require 'json_spec'
9
+
10
+ require 'simplecov-oj'
11
+
12
+ RSpec.configure do |config|
13
+ config.include JsonSpec::Helpers
14
+ end
5
15
 
6
16
  RSpec.configure do |config|
7
17
  config.define_derived_metadata do |meta|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.2
4
+ version: 0.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-02 00:00:00.000000000 Z
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '2.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: json_spec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: rake
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +134,20 @@ dependencies:
120
134
  - - "~>"
121
135
  - !ruby/object:Gem::Version
122
136
  version: '3.9'
137
+ - !ruby/object:Gem::Dependency
138
+ name: simplecov-json
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
123
151
  - !ruby/object:Gem::Dependency
124
152
  name: github-markup
125
153
  requirement: !ruby/object:Gem::Requirement