minitest-tagz 1.5.3 → 1.6.0

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
  SHA256:
3
- metadata.gz: 5ca8af3e5975bf72802bf77b3035cbb6dc12741c21193883bf77824784ae9131
4
- data.tar.gz: ffa715e56d089c17d3e00e5f5945af3e0aecc562ef6fcf0a93a4c4f538f14b0c
3
+ metadata.gz: 347d2a3aa8e7d5e66ee59e3372e69d78901ca244c6504cbbf2bdfe52e6e11b1e
4
+ data.tar.gz: e56b65e7fc29a800855af0e267faa14104c19b2d846f002469411740a3c47ef6
5
5
  SHA512:
6
- metadata.gz: 2152ffb3c3a9f2f4ac98dea7ffbf6c546c140d90675975ee0de93d27f8a432c33193ede136420f0af9f47a6e1df242e3d9cda77f34f3852905fb1607bfc398d7
7
- data.tar.gz: 5832cb6ea3d5213eb654093850fb70cc8df1669cd1eb170d98f76d26cc7cd3001431ef00c94fa7621982a32fc77bfcfd7b2a3508b3d040da0bea9e96a80d8ca9
6
+ metadata.gz: 6d7067bf81f5f82a8d9693779e6ab60c482e528082bad305103473e1ce81c7b9c11d0b0602f298fa441601d497294b19d08c2bf9854ef485c5ce6def3df86afc
7
+ data.tar.gz: 6ca7806d80a96c8dbfa2409e84e5161d74d51bad13faa10c4e4c696982b9ac34f6f268cc1941aacfbb4d5ec8ee61b2508ab3af0efe461b8da5c1e8dc300b54b5
@@ -1,6 +1,5 @@
1
1
  require 'minitest'
2
2
  require 'minitest/tagz/version'
3
- require 'state_machines'
4
3
 
5
4
  module Minitest
6
5
  module Tagz
@@ -100,21 +99,9 @@ module Minitest
100
99
  # It is essentially a state machine that works with the
101
100
  # patcher to patch and unpatch Minitest properly
102
101
  class Tagger
103
- state_machine :state, initial: :awaiting_tag_declaration do
104
- after_transition any => :awaiting_test_definition, do: :patch_test_definitions
105
- after_transition any => :finished, do: :unpatch_test_definitions
106
-
107
- event :tags_declared do
108
- transition :awaiting_tag_declaration => :awaiting_test_definition
109
- end
110
-
111
- event :initial_test_definition_encountered do
112
- transition :awaiting_test_definition => :applying_tags
113
- end
114
-
115
- event :finished_applying_tags do
116
- transition :applying_tags => :finished
117
- end
102
+ def tags_declared
103
+ patch_test_definitions
104
+ @awaiting_initial_test_definition = true
118
105
  end
119
106
 
120
107
  attr_reader :patchers, :owner, :pending_tags
@@ -135,10 +122,10 @@ module Minitest
135
122
  end
136
123
 
137
124
  def handle_initial_test_definition
138
- is_initial = awaiting_test_definition?
139
- initial_test_definition_encountered if is_initial
125
+ is_initial = @awaiting_initial_test_definition
126
+ @awaiting_initial_test_definition = false if is_initial
140
127
  res = yield
141
- finished_applying_tags if is_initial
128
+ unpatch_test_definitions if is_initial
142
129
  res
143
130
  end
144
131
  end
@@ -165,42 +152,51 @@ module Minitest
165
152
  end
166
153
 
167
154
  def patch_minitest_test(state_machine)
168
- @old_method_added = old_method_added = Minitest::Test.method(:method_added)
169
155
  Minitest::Test.class_eval do
170
- define_singleton_method(:method_added) do |name|
171
- if name[/^test_/]
172
- state_machine.handle_initial_test_definition do
173
- Tagz::RunnerStrategy.tag_map ||= {}
174
- Tagz::RunnerStrategy.tag_map[Tagz::RunnerStrategy.serialize(self, name)] ||= []
175
- Tagz::RunnerStrategy.tag_map[Tagz::RunnerStrategy.serialize(self, name)] += state_machine.pending_tags
176
- old_method_added.call(name)
156
+ self.singleton_class.class_eval do
157
+ alias :old_method_added :method_added
158
+
159
+ define_method(:method_added) do |name|
160
+ if name[/^test_/]
161
+ state_machine.handle_initial_test_definition do
162
+ Tagz::RunnerStrategy.tag_map ||= {}
163
+ Tagz::RunnerStrategy.tag_map[Tagz::RunnerStrategy.serialize(self, name)] ||= []
164
+ Tagz::RunnerStrategy.tag_map[Tagz::RunnerStrategy.serialize(self, name)] += state_machine.pending_tags
165
+ old_method_added(name)
166
+ end
167
+ else
168
+ old_method_added(name)
177
169
  end
178
- else
179
- old_method_added.call(name)
180
170
  end
181
171
  end
182
172
  end
183
173
  end
184
174
 
185
175
  def unpatch_minitest_test
186
- Minitest::Test.define_singleton_method(:method_added, @old_method_added)
176
+ Minitest::Test.class_eval do
177
+ self.singleton_class.class_eval do
178
+ undef_method :method_added
179
+ alias :method_added :old_method_added
180
+ end
181
+ end
187
182
  end
188
183
 
189
184
  def patch_minitest_spec(state_machine)
190
- @old_describe = old_describe = Kernel.instance_method(:describe)
191
185
  Kernel.module_eval do
186
+ alias :old_describe :describe
187
+
192
188
  define_method(:describe) do |*args, &block|
193
189
  state_machine.handle_initial_test_definition do
194
- old_describe.bind(self).call(*args, &block)
190
+ old_describe(*args, &block)
195
191
  end
196
192
  end
197
193
  end
198
194
  end
199
195
 
200
196
  def unpatch_minitest_spec
201
- old_describe = @old_describe
202
197
  Kernel.module_eval do
203
- define_method(:describe, old_describe)
198
+ undef_method :describe
199
+ alias :describe :old_describe
204
200
  end
205
201
  end
206
202
  end
@@ -208,7 +204,7 @@ module Minitest
208
204
 
209
205
  # Main extensions to Minitest
210
206
  class << self
211
- attr_accessor :chosen_tags, :run_all_if_no_match, :log_if_no_match
207
+ attr_accessor :run_all_if_no_match, :log_if_no_match
212
208
 
213
209
  alias :run_all_if_no_match? :run_all_if_no_match
214
210
  alias :log_if_no_match? :log_if_no_match
@@ -225,7 +221,7 @@ module Minitest
225
221
  end
226
222
 
227
223
  def chosen_tags
228
- @chosen_tags || []
224
+ @chosen_tags ||= []
229
225
  end
230
226
 
231
227
  def positive_tags
@@ -239,7 +235,6 @@ module Minitest
239
235
  def declare_tag_assignment(owner, pending_tags)
240
236
  tag_machine = TaggerFactory.create_tagger(owner, pending_tags)
241
237
  tag_machine.tags_declared
242
- # TODO add debugging tip about this
243
238
  tag_machine
244
239
  end
245
240
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module Tagz
3
- VERSION = "1.5.3"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "minitest", "~> 5"
23
- spec.add_dependency 'state_machines'
24
23
 
25
24
  spec.add_development_dependency "bundler"
26
25
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-tagz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-15 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5'
27
- - !ruby/object:Gem::Dependency
28
- name: state_machines
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
134
  version: '0'
149
135
  requirements: []
150
136
  rubyforge_project:
151
- rubygems_version: 2.7.6
137
+ rubygems_version: 2.7.3
152
138
  signing_key:
153
139
  specification_version: 4
154
140
  summary: yet another tags implementation for Minitest