solargraph_test_coverage 0.2.3 → 0.2.4

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: 69e0c33725c04d5fe0ccb51767c639d8e864996edf5396e05c16e3aa72bc18da
4
- data.tar.gz: 30ed55d17273d8ec327f9f83cf69573a33bcc1a77ec036e7267136da2aff17a1
3
+ metadata.gz: afacac1a6d557ea7ef39c86081fc7f3aafcb7e09c3a8243679e9d252ba47a2c7
4
+ data.tar.gz: 9e929da5ff5873ef3c044edebb4a96575cb47f4bfb9b2d36121082257ac03569
5
5
  SHA512:
6
- metadata.gz: f3b2c1f49dec3b91a85495ecbeeeb381d6948fdbcdd0bf10ed843be0b02d33c1a84545a902cd220051e52f272ad0bb4d651d4e5c7043f2d97612cb48f3cabdae
7
- data.tar.gz: 440383a6909e68f20d726c5fce67d6b8f195e772be6702161e4421c04cf1720f451ba0c23637b906732e2a0a9895612901cbc2b5c9198a30070393d392d59ce7
6
+ metadata.gz: 58b77e64736847a4d5d6fedb3c67f7b76e6af6056e844926356269c052b8bfe5f29af0c1f76e916f2e26d1ddb5c5628d3d324f53c890ceeff55f289959409b8c
7
+ data.tar.gz: 92e5f351f941d99103339f80fb05450e1393cb5929f584cd7d080759450f9cd31422a71d51ba847664b1217b88c761f1f132f346f280106580c8c806ba1c6bd9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solargraph_test_coverage (0.2.1)
4
+ solargraph_test_coverage (0.2.3)
5
5
  solargraph (~> 0.40, > 0.40)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -39,6 +39,7 @@ test_coverage:
39
39
  - test_missing
40
40
  exclude_paths:
41
41
  - 'app/controller'
42
+ - 'concerns'
42
43
  ```
43
44
 
44
45
 
@@ -3,9 +3,7 @@
3
3
  module SolargraphTestCoverage
4
4
  # Some helper functions for the diagnostics
5
5
  module Helpers
6
- # Determines if a file should be excluded from running diagnostics
7
6
  # @return [Boolean]
8
- #
9
7
  def exclude_file?(source_filename)
10
8
  return true if source_filename.start_with? Helpers.test_path
11
9
 
@@ -14,9 +12,7 @@ module SolargraphTestCoverage
14
12
  false
15
13
  end
16
14
 
17
- # Attempts to find the corresponding unit test file
18
15
  # @return [String]
19
- #
20
16
  def test_file(source)
21
17
  relative_filepath = source.location.filename.sub(Dir.pwd, '').split('/').reject(&:empty?)
22
18
  relative_filepath[0] = Config.test_dir
@@ -25,11 +21,7 @@ module SolargraphTestCoverage
25
21
  .sub('.rb', Config.test_file_suffix)
26
22
  end
27
23
 
28
- # Runs test file in a child process with specified testing framework
29
- # Returns coverage results for current working file
30
- #
31
24
  # @return [Hash]
32
- #
33
25
  def run_test(source)
34
26
  ForkProcess.run do
35
27
  Coverage.start(lines: true, branches: true)
@@ -47,32 +39,24 @@ module SolargraphTestCoverage
47
39
  # @return [Array]
48
40
  #
49
41
  def uncovered_lines(results)
50
- results.fetch(:lines)
51
- .each_with_index
52
- .select { |c, _| c&.zero? }
53
- .map { |_, i| i }
54
- .compact
42
+ return [] unless results[:lines]
43
+
44
+ results[:lines].each_with_index
45
+ .select { |c, _| c&.zero? }
46
+ .map { |_, i| i }
47
+ .compact
55
48
  end
56
49
 
57
- # Builds a new Branch object for each branch tested from results hash
58
- # Then removes branches which have test coverage
59
- #
60
50
  # @return [Array]
61
- #
62
51
  def uncovered_branches(results)
63
52
  Branch.build_from(results).reject(&:covered?)
64
53
  end
65
54
 
66
- # Builds a range for warnings/errors
67
55
  # @return [Hash]
68
- #
69
56
  def range(start_line, start_column, end_line, end_column)
70
57
  Solargraph::Range.from_to(start_line, start_column, end_line, end_column).to_hash
71
58
  end
72
59
 
73
- # requires the specified testing framework
74
- # @return [Boolean]
75
- #
76
60
  def self.require_testing_framework!
77
61
  case Config.test_framework
78
62
  when 'rspec'
@@ -117,9 +101,7 @@ module SolargraphTestCoverage
117
101
  false
118
102
  end
119
103
 
120
- # Returns absolute path for test folder
121
104
  # @return [String]
122
- #
123
105
  def self.test_path
124
106
  File.join(Dir.pwd, Config.test_dir)
125
107
  end
@@ -18,10 +18,14 @@ module SolargraphTestCoverage
18
18
  end
19
19
 
20
20
  def run!
21
- @result = test_framework_runner.run([@test_file])
21
+ @result = test_framework_runner.run(test_options)
22
22
  self
23
23
  end
24
24
 
25
+ def test_options
26
+ raise NotImplementedError
27
+ end
28
+
25
29
  def passed?
26
30
  raise NotImplementedError
27
31
  end
@@ -33,6 +37,10 @@ module SolargraphTestCoverage
33
37
 
34
38
  # Test Runner Subclass for RSpec
35
39
  class RSpecRunner < TestRunner
40
+ def test_options
41
+ [@test_file, '-o', '/dev/null']
42
+ end
43
+
36
44
  def passed?
37
45
  @result&.zero?
38
46
  end
@@ -44,6 +52,10 @@ module SolargraphTestCoverage
44
52
 
45
53
  # Test Runner Subclass for Minitest
46
54
  class MinitestRunner < TestRunner
55
+ def test_options
56
+ [@test_file]
57
+ end
58
+
47
59
  def passed?
48
60
  @result
49
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolargraphTestCoverage
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph_test_coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Kolkey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-01 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solargraph