minitest-tagz 1.0.0 → 1.0.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 +4 -4
- data/README.md +14 -0
- data/lib/minitest/tagz/version.rb +1 -1
- data/lib/minitest/tagz.rb +24 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b82c59731bb66b312c83e52de074ba6e9c09ab
|
4
|
+
data.tar.gz: 08d75b5c1fdebde4f370e700356dfd215e92936c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480bc3751e1bdf1e4c89fe32f3831373bf329ed2aecaa90df6568999836ad45f5edffbc7f6e2392fe44dba78239d8cb22954cb761db01d4c100b156d60aa2824
|
7
|
+
data.tar.gz: 441ec6724c581f2c5c3652b130a6a81fd972dde66163bacdf655dceae2a4e37226d8c2589e967142e723a440fcabe80f3638a00dcf929b59459af6c562983d08
|
data/README.md
CHANGED
@@ -89,6 +89,20 @@ class MySpec < Minitest::Spec
|
|
89
89
|
end
|
90
90
|
```
|
91
91
|
|
92
|
+
## Debugging
|
93
|
+
|
94
|
+
You can save a reference to the tagger and watch the internal state machine:
|
95
|
+
|
96
|
+
```rb
|
97
|
+
tagger = tag :focus
|
98
|
+
it 'should work' do
|
99
|
+
require 'rubygems'; require 'pry'; binding.pry
|
100
|
+
end
|
101
|
+
|
102
|
+
pry(main)> tagger
|
103
|
+
#=> #<Minitest::Tagz::Tagger:0x007fa296102008 @owner=#<Class:0x007fa2957317b8>, @patchers=[Minitest::Tagz::MinitestPatcher], @pending_tags=[:focus], @state="applying_tags">
|
104
|
+
```
|
105
|
+
|
92
106
|
## Contributing
|
93
107
|
|
94
108
|
1. Fork it ( https://github.com/backupify/minitest-tagz/fork )
|
data/lib/minitest/tagz.rb
CHANGED
@@ -9,25 +9,26 @@ module Minitest
|
|
9
9
|
"#{owner} >> #{test_name}"
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
next false unless MinitestRunnerStrategy.tag_map[MinitestRunnerStrategy.serialize(self, r)]
|
22
|
-
(Tagz.chosen_tags - MinitestRunnerStrategy.tag_map[MinitestRunnerStrategy.serialize(self, r)]).empty?
|
23
|
-
end
|
24
|
-
else
|
25
|
-
old_runnable_methods.bind(self).call
|
12
|
+
module Patch
|
13
|
+
def runnable_methods
|
14
|
+
all_runnables = super
|
15
|
+
if Tagz.chosen_tags && Tagz.chosen_tags.any?
|
16
|
+
all_runnables.select do |r|
|
17
|
+
serialized = MinitestRunnerStrategy.serialize(self, r)
|
18
|
+
tags_on_runnable = MinitestRunnerStrategy.tag_map[serialized]
|
19
|
+
next false unless tags_on_runnable
|
20
|
+
(Tagz.chosen_tags - tags_on_runnable).empty?
|
26
21
|
end
|
22
|
+
else
|
23
|
+
all_runnables
|
27
24
|
end
|
28
25
|
end
|
29
26
|
end
|
30
27
|
|
28
|
+
def patch
|
29
|
+
::Minitest::Test.singleton_class.prepend(Patch)
|
30
|
+
end
|
31
|
+
|
31
32
|
def tag_map
|
32
33
|
@tag_map ||= {}
|
33
34
|
end
|
@@ -133,18 +134,21 @@ module Minitest
|
|
133
134
|
end
|
134
135
|
|
135
136
|
def patch_minitest_spec(state_machine)
|
136
|
-
@old_describe = old_describe =
|
137
|
-
|
138
|
-
|
137
|
+
@old_describe = old_describe = Kernel.instance_method(:describe)
|
138
|
+
Kernel.module_eval do
|
139
|
+
define_method(:describe) do |*args, &block|
|
139
140
|
state_machine.handle_initial_test_definition do
|
140
|
-
old_describe.
|
141
|
+
old_describe.bind(self).call(*args, &block)
|
141
142
|
end
|
142
143
|
end
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
146
147
|
def unpatch_minitest_spec
|
147
|
-
|
148
|
+
old_describe = @old_describe
|
149
|
+
Kernel.module_eval do
|
150
|
+
define_method(:describe, old_describe)
|
151
|
+
end
|
148
152
|
end
|
149
153
|
end
|
150
154
|
end
|
@@ -156,7 +160,7 @@ module Minitest
|
|
156
160
|
# want to run tests with tags in this set
|
157
161
|
# @param [Enumerable<Symbol>] tags - a list of tags you want to test
|
158
162
|
def choose_tags(*tags)
|
159
|
-
@chosen_tags = tags
|
163
|
+
@chosen_tags = tags.map(&:to_sym)
|
160
164
|
end
|
161
165
|
|
162
166
|
def declare_tag_assignment(owner, pending_tags)
|