test-prof 0.12.1 → 0.12.2

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: 89c1d2f72a772c731bcb32ee68a21129e82a003a40a194f6a503a31e5b445954
4
- data.tar.gz: 6ed48924861ec8523a083ba853bf5de43579df0624f95e003ca6d417c9b4e076
3
+ metadata.gz: 796e133e85e58fec13b94d1dd51c3c9c934e122d04470115ef15788916a55d0b
4
+ data.tar.gz: a8519944d9f36a9a74371b6a9fc19e69ecfbd1155679f178a3d6b6a62425dff3
5
5
  SHA512:
6
- metadata.gz: 7c62484546cda02e28ce819790cb3479004a970dc1c88849eb7ff3e55114b71710774f0dbc2ce7d4874036a5513f10585c3c4d805db05a75c93acb69a36436cb
7
- data.tar.gz: 4b6d8438fff041a84975c52428f50a03d9f4519a08a2884a35ae45bb43df4c11fa7f375a041477928a1009610dd0dc96d1e702ba6728eb4a2db8a6e147c3119b
6
+ metadata.gz: ca5c8984a8ca9c4b2051be517bb462f8f0b9ba8ac582dd9cb74abeee81a98869400cbdf4e54e446de27215674bf0c90fe3b4dbeefdba620a1c5c67ff4a0ea0ce
7
+ data.tar.gz: 4591aadd9f5616d939f7e9fcf91e4b8f635f921722bbed4225b8094cd78f7e557efbf3c58e45a0ebac18acf02f5744697e87a46524081124ebf15c0232dd2e08
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master (unrealeased)
4
4
 
5
+ ## 0.12.2 (2020-09-03)
6
+
7
+ - Execute Minitest `before_all` in the context of the current test object. ([@palkan][])
8
+
5
9
  ## 0.12.1 (2020-09-01)
6
10
 
7
11
  - Minor improvements.
@@ -8,20 +8,21 @@ module TestProf
8
8
  # store instance variables
9
9
  module Minitest # :nodoc: all
10
10
  class Executor
11
- attr_reader :active
11
+ attr_reader :active, :block, :captured_ivars
12
12
 
13
13
  alias active? active
14
14
 
15
15
  def initialize(&block)
16
16
  @block = block
17
+ @captured_ivars = []
17
18
  end
18
19
 
19
- def activate!(test_class)
20
- return if active?
20
+ def activate!(test_object)
21
+ return restore_ivars(test_object) if active?
21
22
  @active = true
22
- @examples_left = test_class.runnable_methods.size
23
+ @examples_left = test_object.class.runnable_methods.size
23
24
  BeforeAll.begin_transaction do
24
- capture!
25
+ capture!(test_object)
25
26
  end
26
27
  end
27
28
 
@@ -33,16 +34,21 @@ module TestProf
33
34
  BeforeAll.rollback_transaction
34
35
  end
35
36
 
36
- def capture!
37
- instance_eval(&@block)
37
+ def capture!(test_object)
38
+ before_ivars = test_object.instance_variables
39
+
40
+ test_object.instance_eval(&block)
41
+
42
+ (test_object.instance_variables - before_ivars).each do |ivar|
43
+ captured_ivars << [ivar, test_object.instance_variable_get(ivar)]
44
+ end
38
45
  end
39
46
 
40
- def restore_to(test_object)
41
- instance_variables.each do |ivar|
42
- next if ivar == :@block
47
+ def restore_ivars(test_object)
48
+ captured_ivars.each do |(ivar, val)|
43
49
  test_object.instance_variable_set(
44
50
  ivar,
45
- instance_variable_get(ivar)
51
+ val
46
52
  )
47
53
  end
48
54
  end
@@ -62,8 +68,7 @@ module TestProf
62
68
 
63
69
  prepend(Module.new do
64
70
  def setup
65
- self.class.before_all_executor.activate!(self.class)
66
- self.class.before_all_executor.restore_to(self)
71
+ self.class.before_all_executor.activate!(self)
67
72
  super
68
73
  end
69
74
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.12.1"
4
+ VERSION = "0.12.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler