minitest-tagz 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8743f494fc917d96a638d22e0d98cfaa5e94a3ae
4
- data.tar.gz: 1cdd782cfd5edc53da8e3a25c1817e6d05a6023f
3
+ metadata.gz: 79b82c59731bb66b312c83e52de074ba6e9c09ab
4
+ data.tar.gz: 08d75b5c1fdebde4f370e700356dfd215e92936c
5
5
  SHA512:
6
- metadata.gz: 712ba39c5104fe7e02d80eb45026fc414a149853d3e86687a87a5670e301116b92e5e128aa1c24e993a458b9e383cfc8fb64085840ba06aaee176f78bde7ea66
7
- data.tar.gz: 95a77a32b2cf90933512784b451e26471cf32b6e15071aec741bf5c23ed1cf1d8ac34f65194fb098056a89d8825f42963f82b3b7cc9758938e60112e52eae267
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 )
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Tagz
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
data/lib/minitest/tagz.rb CHANGED
@@ -9,25 +9,26 @@ module Minitest
9
9
  "#{owner} >> #{test_name}"
10
10
  end
11
11
 
12
- def patch
13
- ::Minitest::Test.singleton_class.class_eval do
14
- attr_reader :tag_map
15
-
16
- old_runnable_methods = instance_method(:runnable_methods)
17
- define_method :runnable_methods do
18
- if Tagz.chosen_tags && Tagz.chosen_tags.any?
19
- all_runnables = old_runnable_methods.bind(self).call
20
- all_runnables.select do |r|
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 = Minitest::Spec.method(:describe)
137
- Minitest::Spec.class_eval do
138
- define_singleton_method(:describe) do |*args, &block|
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.unbind.bind(self).call(*args, &block)
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
- Minitest::Spec.define_singleton_method(:describe, @old_describe)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-tagz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah