minitest-focus 1.2.1 → 1.3.0

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: c42c6ba3ea527eeb7756c50f08f6f123acdfbbe5f00ee68e7543fec395512554
4
- data.tar.gz: aa656bdcf5ae92d25558e9822387491a1fcca43f89297d060a52716eea6fd4e5
3
+ metadata.gz: d34869b02e75ef676d3e431756fc9da15e2ff8ca21f22103f00ac5ebe69f3d2c
4
+ data.tar.gz: 6baf632e87f65bc46c46e4acfda4d48bb1871a3b240f132bdd2b85221c119302
5
5
  SHA512:
6
- metadata.gz: 45532069fcd74b655e5fa65721f3e2f3793b513c8da19c8b8ff7eaeca593b36f1293d6cc345ddaf21ecae2b8ecabdd6988caec6b21b3b89e4b784809e6c0fbcb
7
- data.tar.gz: 5fc346666e60b5eba021293f05110c4332bc81a41b68ee6a09cdcb492925b8585b03fcf97dd1a6c8ffa79a2fd1bab853ebb77ee7218b4c0945667fe5c7319dfa
6
+ metadata.gz: d988af4b0b1959a4caf4200d484713bbbc9e809282b2f72aee822e8bb89dd9fe20fde2c6e3fbe01be4bc39f5d9cc1573349d1f5bef5a98ec4a043a88266f7b26
7
+ data.tar.gz: d661a7db8d5e6906957b8481d7f59a9f0882b97f44f2d52af0937acdbfd208167e2fbf5015dd0515794e7cf4f324d735b8145486d877c75ae38aac6fdfa48eb4
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ === 1.3.0 / 2021-05-22
2
+
3
+ * 1 major enhancement:
4
+
5
+ * Removed minitest4 support.
6
+
7
+ * 2 minor enhancements:
8
+
9
+ * Added support for `focus def test_method`.
10
+ * Improved documentation for both test- and spec-style.
11
+
1
12
  === 1.2.1 / 2020-06-14
2
13
 
3
14
  * 1 bug fix:
data/Manifest.txt CHANGED
@@ -4,7 +4,5 @@ Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
6
  lib/minitest/focus.rb
7
- lib/minitest/focus4.rb
8
- lib/minitest/focus5.rb
9
7
  lib/minitest/focus_plugin.rb
10
8
  test/minitest/test_focus.rb
data/README.txt CHANGED
@@ -23,17 +23,26 @@ Inspired by https://github.com/seattlerb/minitest/issues/213
23
23
  require "minitest/focus"
24
24
 
25
25
  class MyTest < MiniTest::Unit::TestCase
26
- def test_unrelated; ...; end
26
+ def test_unrelated; ...; end # will NOT run
27
+
28
+ focus def test_method2; ...; end # will run (direct--preferred)
27
29
 
28
30
  focus
29
- def test_method; ...; end # only this one will run
31
+ def test_method; ...; end # will run (indirect)
32
+
33
+ def test_method_edgecase; ...; end # will NOT run
34
+ end
35
+
36
+ # or, with spec-style:
30
37
 
31
- def test_method_edgecase; ...; end
38
+ describe "MyTest2" do
39
+ focus; it "does something" do pass end
40
+ focus it("does something else") { pass } # block precedence needs {}
32
41
  end
33
42
 
34
43
  == REQUIREMENTS:
35
44
 
36
- * minitest 4.3.4+
45
+ * minitest 5+
37
46
 
38
47
  == INSTALL:
39
48
 
@@ -1,7 +1,59 @@
1
- begin
2
- require "minitest/test"
3
- require "minitest/focus5.rb"
4
- rescue LoadError
5
- require "minitest/unit"
6
- require "minitest/focus4.rb"
1
+ class Minitest::Test # :nodoc:
2
+ class Focus # :nodoc:
3
+ VERSION = "1.3.0" # :nodoc:
4
+ end
5
+
6
+ @@filtered_names = [] # :nodoc:
7
+
8
+ def self.add_to_filter name
9
+ @@filtered_names << "#{self}##{name}"
10
+ end
11
+
12
+ def self.filtered_names
13
+ @@filtered_names
14
+ end
15
+
16
+ ##
17
+ # Focus on the next test defined. Cumulative. Equivalent to
18
+ # running with command line arg: -n /test_name|.../
19
+ #
20
+ # class MyTest < Minitest::Test
21
+ #
22
+ # # direct approach
23
+ # focus def test_method1 # will run
24
+ # ...
25
+ # end
26
+ #
27
+ # # indirect approach
28
+ # focus
29
+ # def test_method2 # will run
30
+ # ...
31
+ # end
32
+ #
33
+ # def test_method3 # will NOT run
34
+ # ...
35
+ # end
36
+ # end
37
+
38
+ def self.focus name = nil
39
+ if name then
40
+ add_to_filter name
41
+ else
42
+ set_focus_trap
43
+ end
44
+ end
45
+
46
+ ##
47
+ # Sets a one-off method_added callback to set focus on the method
48
+ # defined next.
49
+
50
+ def self.set_focus_trap
51
+ meta = class << self; self; end
52
+
53
+ meta.send :define_method, :method_added do |name|
54
+ add_to_filter name
55
+
56
+ meta.send :remove_method, :method_added
57
+ end
58
+ end
7
59
  end
@@ -11,6 +11,8 @@ module Minitest
11
11
  ARGV.delete_at index
12
12
  end
13
13
 
14
- options[:filter] = "/^(#{Regexp.union(Minitest::Test.filtered_names).source})$/"
14
+ re = "/^(#{Regexp.union(Minitest::Test.filtered_names).source})$/"
15
+
16
+ options[:filter] = re
15
17
  end
16
18
  end
@@ -1,17 +1,19 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest/focus"
3
3
 
4
- test_cls = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
5
-
6
- class MyTest1 < test_cls
4
+ class MyTest1 < Minitest::Test
7
5
  def test_fail; flunk; end
8
6
  focus; def test_method; pass; end
7
+ focus def test_method2; pass; end
8
+ focus \
9
+ def test_method3; pass; end
9
10
  def test_method_edgecase; flunk; end
10
11
  end
11
12
 
12
13
  describe "MyTest2" do
13
14
  it "is ignored" do flunk end
14
15
  focus; it "does something" do pass end
16
+ focus it("does something else") { pass } # stupid block precedence needs {}
15
17
  it "bombs" do flunk end
16
18
  focus; it "has non-word ['chars'" do pass end # Will raise invalid RegExp unless correctly escaped
17
19
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-focus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE5MTIxMzAwMDIwNFoXDTIwMTIxMjAwMDIwNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIwMTIyMjIwMzgzMFoXDTIxMTIyMjIwMzgzMFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCkkcHqAa6IKLYGl93rn78J3L+LnqyxaA059n4IGMHWN5bv9KBQnIjOrpLadtYZ
26
- vhWkunWDKdfVapBEq5+T4HzqnsEXC3aCv6JEKJY6Zw7iSzl0M8hozuzRr+w46wvT
27
- fV2yTN6QTVxqbMsJJyjosks4ZdQYov2zdvQpt1HsLi+Qmckmg8SPZsd+T8uiiBCf
28
- b+1ORSM5eEfBQenPXy83LZcoQz8i6zVB4aAfTGGdhxjoMGUEmSZ6xpkOzmnGa9QK
29
- m5x9IDiApM+vCELNwDXXGNFEnQBBK+wAe4Pek8o1V1TTOxL1kGPewVOitX1p3xoN
30
- h7iEjga8iM1LbZUfiISZ+WrB
25
+ AQAE3XRm1YZcCVjAJy5yMZvTOFrS7B2SYErc+0QwmKYbHztTTDY2m5Bii+jhpuxh
26
+ H+ETcU1z8TUKLpsBUP4kUpIRowkVN1p/jKapV8T3Rbwq+VuYFe+GMKsf8wGZSecG
27
+ oMQ8DzzauZfbvhe2kDg7G9BBPU0wLQlY25rDcCy9bLnD7R0UK3ONqpwvsI5I7x5X
28
+ ZIMXR0a9/DG+55mawwdGzCQobDKiSNLK89KK7OcNTALKU0DfgdTkktdgKchzKHqZ
29
+ d/AHw/kcnU6iuMUoJEcGiJd4gVCTn1l3cDcIvxakGslCA88Jubw0Sqatan0TnC9g
30
+ KToW560QIey7SPfHWduzFJnV
31
31
  -----END CERTIFICATE-----
32
- date: 2020-06-14 00:00:00.000000000 Z
32
+ date: 2021-05-22 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: minitest
@@ -107,8 +107,6 @@ files:
107
107
  - README.txt
108
108
  - Rakefile
109
109
  - lib/minitest/focus.rb
110
- - lib/minitest/focus4.rb
111
- - lib/minitest/focus5.rb
112
110
  - lib/minitest/focus_plugin.rb
113
111
  - test/minitest/test_focus.rb
114
112
  homepage: https://github.com/seattlerb/minitest-focus
@@ -116,7 +114,7 @@ licenses:
116
114
  - MIT
117
115
  metadata:
118
116
  homepage_uri: https://github.com/seattlerb/minitest-focus
119
- post_install_message:
117
+ post_install_message:
120
118
  rdoc_options:
121
119
  - "--main"
122
120
  - README.txt
@@ -133,8 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
131
  - !ruby/object:Gem::Version
134
132
  version: '0'
135
133
  requirements: []
136
- rubygems_version: 3.0.3
137
- signing_key:
134
+ rubygems_version: 3.2.16
135
+ signing_key:
138
136
  specification_version: 4
139
137
  summary: Allows you to focus on a few tests with ease without having to use command-line
140
138
  arguments
metadata.gz.sig CHANGED
Binary file
@@ -1,26 +0,0 @@
1
- class MiniTest::Unit::TestCase # :nodoc:
2
- ##
3
- # Focus on the next test defined. Cumulative. Equivalent to
4
- # running with command line arg: -n /test_name|.../
5
- #
6
- # class MyTest < MiniTest::Unit::TestCase
7
- # ...
8
- # focus
9
- # def test_pass; ... end # this one will run
10
- # ...
11
- # end
12
-
13
- def self.focus
14
- opts = MiniTest::Unit.runner.options
15
- meta = class << self; self; end
16
-
17
- opts[:names] ||= []
18
-
19
- meta.send :define_method, :method_added do |name|
20
- opts[:names] << name.to_s
21
- opts[:filter] = "/^(#{Regexp.union(opts[:names]).source})$/"
22
-
23
- meta.send :remove_method, :method_added
24
- end
25
- end
26
- end
@@ -1,36 +0,0 @@
1
- class Minitest::Test # :nodoc:
2
- class Focus # :nodoc:
3
- VERSION = "1.2.1" # :nodoc:
4
- end
5
-
6
- @@filtered_names = [] # :nodoc:
7
-
8
- def self.add_to_filter name
9
- @@filtered_names << "#{self}##{name}"
10
- end
11
-
12
- def self.filtered_names
13
- @@filtered_names
14
- end
15
-
16
- ##
17
- # Focus on the next test defined. Cumulative. Equivalent to
18
- # running with command line arg: -n /test_name|.../
19
- #
20
- # class MyTest < MiniTest::Unit::TestCase
21
- # ...
22
- # focus
23
- # def test_pass; ... end # this one will run
24
- # ...
25
- # end
26
-
27
- def self.focus
28
- meta = class << self; self; end
29
-
30
- meta.send :define_method, :method_added do |name|
31
- add_to_filter name
32
-
33
- meta.send :remove_method, :method_added
34
- end
35
- end
36
- end