simplecov-cobertura 1.4.0 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b29f6564857059dcac6619f01b7677ca3e47371dfced0f19bf559dd2ae1b92c5
4
- data.tar.gz: 22f51901a3a8edf6348681ae479d3f2dffc5b1bc59847b5a96c3d2514a0a75cd
3
+ metadata.gz: e4a11c2c152ba855cb63e6df239c4a184bda9da9a2ead876fbc27d39e66b7f77
4
+ data.tar.gz: 74a55b1d64b191ac6fc09c0fd5850bf3808515deb0a854a26c1227f979350d21
5
5
  SHA512:
6
- metadata.gz: 50ac805361f155508d1d11739815aaef6bf112674c13cf41d6e6c4e758ade1a3f09c7ac4bc8410012dcbf23edaf5f9e37a2aef60d8863bb3b007a459e5907a2c
7
- data.tar.gz: b0eaa11f8f5f8a0758368019ce9de0bfb24eb2c2343d22cb5b5bff0cd5efee410ac0668ca22310babe976ff55517cb2c94885867e4e9db90ae87ca69519e84e4
6
+ metadata.gz: 9875b3bd65b54edccde1c463a2fc60ba72d5b43096a4b0a83b2daa2ed62396b1ef21b13609aa2a0ed4ecbe2cb1c895be022b09deb6e614f4b050b62cac920ea9
7
+ data.tar.gz: 1d3cd10afc26cb1a5564b7c7d570bb38b940a2609945d40009fba9f15de9c10be86cd3ed86bbcc9fafcb3d42bfbeb3299db2fa7928f9ee3e8b9e3d9d3a6c311a
@@ -2,6 +2,7 @@ require 'simplecov'
2
2
 
3
3
  require 'rexml/document'
4
4
  require 'rexml/element'
5
+ require 'pathname'
5
6
 
6
7
  require_relative 'simplecov-cobertura/version'
7
8
 
@@ -94,9 +95,8 @@ module SimpleCov
94
95
 
95
96
  def set_class_attributes(class_, file)
96
97
  filename = file.filename
97
- path = filename[SimpleCov.root.length+1..-1]
98
98
  class_.attributes['name'] = File.basename(filename, '.*')
99
- class_.attributes['filename'] = path
99
+ class_.attributes['filename'] = resolve_filename(filename)
100
100
  class_.attributes['line-rate'] = (file.covered_percent/100).round(2).to_s
101
101
  class_.attributes['branch-rate'] = '0'
102
102
  class_.attributes['complexity'] = '0'
@@ -116,7 +116,15 @@ module SimpleCov
116
116
  end
117
117
 
118
118
  def coverage_output(result)
119
- "#{result.covered_lines} / #{result.covered_lines + result.missed_lines} LOC (#{result.covered_percent.round(2)}%) covered."
119
+ "#{result.covered_lines} / #{result.covered_lines + result.missed_lines} LOC (#{result.covered_percent.round(2)}%) covered."
120
+ end
121
+
122
+ def resolve_filename(filename)
123
+ Pathname.new(filename).relative_path_from(project_root).to_s
124
+ end
125
+
126
+ def project_root
127
+ @project_root ||= Pathname.new(SimpleCov.root)
120
128
  end
121
129
  end
122
130
  end
@@ -1,7 +1,7 @@
1
1
  module SimpleCov
2
2
  module Formatter
3
3
  class CoberturaFormatter
4
- VERSION = '1.4.0'
4
+ VERSION = '1.4.1'
5
5
  end
6
6
  end
7
7
  end
@@ -135,4 +135,21 @@ class CoberturaFormatterTest < Test::Unit::TestCase
135
135
  assert_equal 'false', last_line.attribute('branch').value
136
136
  assert_equal '2', last_line.attribute('hits').value
137
137
  end
138
+
139
+ def test_supports_root_project_path
140
+ old_root = SimpleCov.root
141
+ SimpleCov.root('/')
142
+ expected_base = old_root[1..-1] # Remove leading "/"
143
+
144
+ xml = @formatter.format(@result)
145
+ doc = Nokogiri::XML::Document.parse(xml)
146
+
147
+ classes = doc.xpath '/coverage/packages/package/classes/class'
148
+ assert_equal 1, classes.length
149
+ clazz = classes.first
150
+ assert_equal 'simplecov-cobertura_test', clazz.attribute('name').value
151
+ assert_equal "#{expected_base}/test/simplecov-cobertura_test.rb", clazz.attribute('filename').value
152
+ ensure
153
+ SimpleCov.root(old_root)
154
+ end
138
155
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-cobertura
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Bowes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-16 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit