minitest-suite 0.0.2 → 0.0.3

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: f4c6431daa7d510ea5146c3b8b417c77847f7f3f5d5a64b331248b8e3299e8e5
4
- data.tar.gz: e8c90ad9b02cda9467c7eee661ce47d539e2b055be68219e09965b23890238ae
3
+ metadata.gz: 067d6ce4ba991131cffa2bfe98b302c9d65824a5157d2c431ed75fff7195ecb9
4
+ data.tar.gz: 58f8d85c0fdd73ac90988206c3b0a0207b11fb5cf71807a105131af44a46f0c0
5
5
  SHA512:
6
- metadata.gz: 9554fb2541a0be0b30c454841a667640194ee5c0f1ce9e53f1c4a5c5bc0ea0c37fb6d39e9ccc9803c8161aed0651b4833ce23c26f39c1ca6916cf7a101f220ed
7
- data.tar.gz: 419c7a9f46e85b059dffcefea7170527c274fdcf38533f0d41b197480284253390239ee9d7d076223bdb46f763281e70a25c9daa2e5331455b666726adf8ca12
6
+ metadata.gz: 001f6440cdf97d061a4166f4a94f632bbcd2d42db5caea3471e099c87509c72ff8e6988884742b03efd51da85af4139448f395d79733ed141c7a1ab44dc197e7
7
+ data.tar.gz: 4132976ada3d8bc9733499bcb96359abce8face1dd592b7eeb038cdd367006c4a3b79ee4634106d1f053e8c17fa0591d280731c3a67e5d41e4b4571852d26724
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.3
2
+
3
+ - Adds support for inheriting a suite from a parent type (e.g. a ModelTest that
4
+ sets `suite :model` will pass on that suite to its descendant tests unless
5
+ they override it with a different suite).
6
+
1
7
  # 0.0.2
2
8
 
3
9
  - Adds Minitest::Suite.order= for specifying initial suite order
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minitest-suite (0.0.2)
4
+ minitest-suite (0.0.3)
5
5
  minitest
6
6
 
7
7
  GEM
@@ -38,6 +38,7 @@ GEM
38
38
 
39
39
  PLATFORMS
40
40
  arm64-darwin-20
41
+ arm64-darwin-21
41
42
 
42
43
  DEPENDENCIES
43
44
  minitest-suite!
@@ -45,4 +46,4 @@ DEPENDENCIES
45
46
  standard
46
47
 
47
48
  BUNDLED WITH
48
- 2.2.15
49
+ 2.2.30
data/example/Gemfile CHANGED
@@ -3,3 +3,4 @@ source "https://rubygems.org"
3
3
  gem "rake"
4
4
  gem "minitest"
5
5
  gem "minitest-suite", path: ".."
6
+ gem "pry"
data/example/Gemfile.lock CHANGED
@@ -1,22 +1,29 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- minitest-suite (0.0.2)
4
+ minitest-suite (0.0.3)
5
5
  minitest
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ coderay (1.1.3)
11
+ method_source (1.0.0)
10
12
  minitest (5.14.4)
13
+ pry (0.14.1)
14
+ coderay (~> 1.1)
15
+ method_source (~> 1.0)
11
16
  rake (13.0.6)
12
17
 
13
18
  PLATFORMS
14
19
  arm64-darwin-20
20
+ arm64-darwin-21
15
21
 
16
22
  DEPENDENCIES
17
23
  minitest
18
24
  minitest-suite!
25
+ pry
19
26
  rake
20
27
 
21
28
  BUNDLED WITH
22
- 2.2.15
29
+ 2.2.30
@@ -0,0 +1,109 @@
1
+ module Exe
2
+ def self.cution(exe)
3
+ @executions ||= []
4
+ @executions << exe
5
+ end
6
+
7
+ def self.cutions
8
+ @executions || []
9
+ end
10
+ end
11
+
12
+ at_exit do
13
+ expected = Minitest::Suite.order
14
+ expected_index = 0
15
+
16
+ Exe.cutions.each.with_index do |suite, actual_index|
17
+ finished_suites = expected_index == 0 ? [] : expected[0..(expected_index - 1)]
18
+
19
+ if finished_suites.include?(suite)
20
+ raise <<~MSG
21
+ Ensuring order #{expected.inspect} but #{suite.inspect} test was just run
22
+ out of order. Actual execution order:
23
+
24
+ #{Exe.cutions.map(&:inspect).join("\n")}
25
+ MSG
26
+ elsif suite == expected[expected_index]
27
+ # cool
28
+ else
29
+ expected_index += 1
30
+ end
31
+ end
32
+ end
33
+
34
+ require "minitest/suite"
35
+ require "minitest/autorun"
36
+
37
+ Minitest::Suite.order = [:model, :weird, :controller]
38
+
39
+ class ModelTest < Minitest::Test
40
+ suite :model
41
+ end
42
+
43
+ class SomeModel < ModelTest
44
+ def test_it
45
+ Exe.cution :model
46
+ end
47
+ end
48
+
49
+ class OtherModel < ModelTest
50
+ def test_it
51
+ Exe.cution :model
52
+ end
53
+ end
54
+
55
+ class DeepModelTest < ModelTest
56
+ end
57
+
58
+ class OtherOtherModel < DeepModelTest
59
+ def test_it
60
+ Exe.cution :model
61
+ end
62
+ end
63
+
64
+ class WeirdModel < ModelTest
65
+ suite :weird
66
+
67
+ def test_it
68
+ Exe.cution :weird
69
+ end
70
+ end
71
+
72
+ class Controller < Minitest::Test
73
+ suite :controller
74
+ end
75
+
76
+ class DeepController < Controller
77
+ end
78
+
79
+ class OneController < Controller
80
+ def test_it
81
+ Exe.cution :controller
82
+ end
83
+ end
84
+
85
+ class TwoController < Controller
86
+ def test_it
87
+ Exe.cution :controller
88
+ end
89
+ end
90
+
91
+ class ThreeController < DeepController
92
+ def test_it
93
+ Exe.cution :controller
94
+ end
95
+ end
96
+
97
+ class WeirdController < Controller
98
+ suite :weird
99
+
100
+ def test_it
101
+ Exe.cution :weird
102
+ end
103
+ end
104
+
105
+ class NoSuite < Minitest::Test
106
+ def test_it
107
+ Exe.cution :no_suite
108
+ end
109
+ end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Suite
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -55,10 +55,23 @@ module Minitest
55
55
  end
56
56
  end
57
57
 
58
+ def self.registration_for(test_class)
59
+ first_registered_ancestor = test_class.ancestors.find { |ancestor|
60
+ registrations.any? { |r| r.test == ancestor }
61
+ }
62
+ if first_registered_ancestor
63
+ Registration.new(
64
+ test: test_class,
65
+ suite: registrations.find { |r| r.test == first_registered_ancestor }.suite
66
+ )
67
+ end
68
+ end
69
+
58
70
  class PartialArrayProxy < Array
59
71
  def shuffle
60
- filtered = Suite.registrations.select { |r| include?(r.test) }
72
+ filtered = map { |test_class| Suite.registration_for(test_class) }.compact
61
73
  suites = Suite.order | (filtered.map(&:suite).uniq + [:__unsuitened]).shuffle
74
+
62
75
  suites.flat_map { |suite|
63
76
  if suite == :__unsuitened
64
77
  (self - filtered.map(&:test)).shuffle
data/script/test CHANGED
@@ -23,3 +23,5 @@ ORDER="suite1" bundle exec ruby test/suite_fixed_order_test.rb
23
23
  ORDER="suite2,suite3" bundle exec ruby test/suite_fixed_order_test.rb
24
24
  ORDER="suite3,suite2,suite1" bundle exec ruby test/suite_fixed_order_test.rb
25
25
 
26
+ bundle exec ruby test/inherited_type_test.rb
27
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-01 00:00:00.000000000 Z
11
+ date: 2021-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -44,6 +44,7 @@ files:
44
44
  - example/Gemfile
45
45
  - example/Gemfile.lock
46
46
  - example/Rakefile
47
+ - example/test/inherited_type_test.rb
47
48
  - example/test/suite_filter_test.rb
48
49
  - example/test/suite_fixed_order_test.rb
49
50
  - example/test/suite_shuffle_test.rb
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.2.22
76
77
  signing_key:
77
78
  specification_version: 4
78
79
  summary: Re-order your Minitest suite into logical sub-suites/groups