minitest-subjective 0.1.0.pre.alpha → 0.1.0.pre.alpha.2

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: f5760ba45aa4159efb193a53b8c0a2da6d983881793d60d64a9c0dd25b55a40e
4
- data.tar.gz: 3b0fa96c440e22577be2321a9ee6c4ec46d69de0d3bb989e3ca0e104bcfda6c8
3
+ metadata.gz: b767652d0792b6d1d274de3aa57b4dd011f0729511f7372c0f82980a89ef6e8d
4
+ data.tar.gz: 0dca826f85a19cbdb35a1acf168a6613cc703834e9db40b8fa3850b284b198fc
5
5
  SHA512:
6
- metadata.gz: d826c7e3dd1687ff376c8fa29c9ac00e2ede3c11aa8e364219fe79ca9bbedce0e636a53c986e502e76a6756bba4eb3c78375692fd839d0d64976c4173a325b58
7
- data.tar.gz: 71a008c282cac260f3f70bf981e970040b8d6860c26a8a0f38df07be5aa90e76f52f643d3a63d1a18b2bada19da76f585fc69782fbccd04557eda02e231b5676
6
+ metadata.gz: adc4bcbabd441c044266ce93d9729b00f8519eea0c5a875e37ba538fbe324faa2846d329912542a2b020227106fe9b3db9b373f1a50a0bbceb758cbf0a8753f1
7
+ data.tar.gz: 75019411a22e3e363416321cafa1c9dc25839018e5e45acd3f6765d1109fba40314f1646932e83ff13f583cd4c8d49dee2041a555b4f7c2905ecfc5007d86418
@@ -14,9 +14,9 @@ module Minitest
14
14
 
15
15
  def subject_name
16
16
  return class_name unless test?
17
- return [class_name_nesting, demodulized_class_name.delete_suffix('Test')].join('::') if rails_test?
17
+ return [*class_name_nesting, demodulized_class_name.delete_suffix('Test')].join('::') if rails_test?
18
18
 
19
- [class_name_nesting, demodulized_class_name.delete_prefix('Test')].join('::')
19
+ [*class_name_nesting, demodulized_class_name.delete_prefix('Test')].join('::')
20
20
  end
21
21
 
22
22
  def test? = rails_test? || minitest_test?
@@ -26,7 +26,7 @@ module Minitest
26
26
  end
27
27
 
28
28
  def rails_test?
29
- demodulized_class_name.end_with?('Test') && defined?(::ActiveSupport) && klass < ActiveSupport::TestCase
29
+ demodulized_class_name.end_with?('Test') && klass < Minitest::Test
30
30
  end
31
31
 
32
32
  def integration_test? = rails_test? && defined?(::ActionDispatch) && klass < ActionDispatch::IntegrationTest
@@ -41,7 +41,7 @@ module Minitest
41
41
  def load_subject = safe_constantize(subject_name)
42
42
 
43
43
  def class_name_nesting
44
- class_name.split('::')[0..-2].join('::')
44
+ class_name.split('::')[0..-2].join('::').then { |nesting| nesting unless nesting.empty? }
45
45
  end
46
46
 
47
47
  def demodulized_class_name
@@ -6,7 +6,7 @@ module Minitest
6
6
  class LineStatistics
7
7
  LineHits = Struct.new(:line, :hits, :branches) do
8
8
  def self.from_pair(line, hits, branches: nil)
9
- new(line:, hits:, branches:)
9
+ new(line:, hits:, branches: branches&.filter { |range| range.cover?(line) })
10
10
  end
11
11
 
12
12
  def +(other)
@@ -24,13 +24,13 @@ module Minitest
24
24
  def +(other)
25
25
  return self unless other
26
26
 
27
- self.class.new(method_hits.zip(other.method_hits).collect { |current, new| current + new })
27
+ self.class.new(method_hits.collect { _1 + other.find_by(klass: _1.klass, name: _1.name, range: _1.range) })
28
28
  end
29
29
 
30
30
  def -(other)
31
31
  return self unless other
32
32
 
33
- self.class.new(method_hits.zip(other.method_hits).collect { |current, new| current - new })
33
+ self.class.new(method_hits.collect { _1 - other.find_by(klass: _1.klass, name: _1.name, range: _1.range) })
34
34
  end
35
35
 
36
36
  def find_by(**options)
@@ -3,7 +3,6 @@
3
3
  require 'minitest/subjective/file_result/branch_statistics'
4
4
  require 'minitest/subjective/file_result/line_statistics'
5
5
  require 'minitest/subjective/file_result/method_statistics'
6
- require 'minitest/subjective/formatter'
7
6
 
8
7
  module Minitest
9
8
  module Subjective
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'minitest/subjective/case_inquirer'
4
-
5
3
  module Minitest
6
4
  module Subjective
7
5
  class Reporter < Minitest::Reporter # :nodoc:
@@ -18,6 +16,7 @@ module Minitest
18
16
 
19
17
  def report
20
18
  results.each do |subject_name, result|
19
+ io.puts
21
20
  io.puts "Coverage for #{subject_name}:"
22
21
  io.puts coverage_headline_for(result)
23
22
  io.puts result.to_s unless result.covered?
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/subjective'
4
+
5
+ Minitest::Subjective.start_coverage
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minitest
4
4
  module Subjective
5
- VERSION = '0.1.0-alpha'
5
+ VERSION = '0.1.0-alpha.2'
6
6
  end
7
7
  end
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'subjective/version'
4
3
  require 'coverage'
5
4
  require 'forwardable'
6
5
  require 'minitest'
6
+
7
+ require 'minitest/subjective/version'
8
+ require 'minitest/subjective/case_inquirer'
7
9
  require 'minitest/subjective/file_result'
8
- require 'minitest/subjective_plugin'
10
+ require 'minitest/subjective/formatter'
11
+ require 'minitest/subjective/reporter'
12
+ require 'minitest/subjective/result_extensions'
13
+ require 'minitest/subjective/test_extensions'
9
14
 
10
15
  module Minitest # :nodoc:
11
16
  # = \Subjective
@@ -65,6 +70,6 @@ module Minitest # :nodoc:
65
70
  end
66
71
  end
67
72
  end
68
-
69
- load :subjective if respond_to?(:load)
70
73
  end
74
+
75
+ Minitest.load :subjective if Minitest.respond_to?(:load) && !Minitest.respond_to?(:plugin_subjective_init)
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'minitest/subjective/reporter'
4
- require 'minitest/subjective/result_extensions'
5
- require 'minitest/subjective/test_extensions'
6
-
7
3
  module Minitest # :nodoc:
8
4
  class << self
9
5
  private
@@ -13,6 +9,8 @@ module Minitest # :nodoc:
13
9
 
14
10
  ::Zeitwerk::Registry.loaders.each do |loader|
15
11
  loader.on_load do |cpath, _value, abspath|
12
+ next if Gem.path.any? { |path| abspath.start_with?("#{path}/") }
13
+
16
14
  Subjective.record_autoload_for(cpath, abspath)
17
15
  end
18
16
  end
@@ -28,10 +26,15 @@ module Minitest # :nodoc:
28
26
  def self.plugin_subjective_init(options)
29
27
  return unless options[:subjective] || ENV['MINITEST_SUBJECTIVE']
30
28
 
29
+ require 'minitest/subjective'
30
+
31
31
  add_zeitwerk_hooks
32
32
  Subjective.start_coverage
33
33
  Subjective::ResultExtensions.prepend_target
34
34
  Subjective::TestExtensions.prepend_target
35
+ Runnable.runnables
36
+ .reject { |runnable| [Minitest::Test, Minitest::Spec].include?(runnable) }
37
+ .each { |runnable| Subjective.record_load_for(runnable) }
35
38
  reporter << Subjective::Reporter.new
36
39
  end
37
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-subjective
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha
4
+ version: 0.1.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Malčić
@@ -59,6 +59,7 @@ files:
59
59
  - lib/minitest/subjective/formatter/colors.rb
60
60
  - lib/minitest/subjective/reporter.rb
61
61
  - lib/minitest/subjective/result_extensions.rb
62
+ - lib/minitest/subjective/setup.rb
62
63
  - lib/minitest/subjective/test_extensions.rb
63
64
  - lib/minitest/subjective/version.rb
64
65
  - lib/minitest/subjective_plugin.rb