test-prof 1.4.2 → 1.4.3
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/CHANGELOG.md +6 -0
- data/lib/test_prof/any_fixture/dump.rb +1 -1
- data/lib/test_prof/before_all/adapters/active_record.rb +21 -0
- data/lib/test_prof/cops/rspec/aggregate_examples/its.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/line_range_helpers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/metadata_helpers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples/node_matchers.rb +1 -1
- data/lib/test_prof/cops/rspec/aggregate_examples.rb +12 -18
- data/lib/test_prof/factory_doctor.rb +1 -2
- data/lib/test_prof/recipes/minitest/before_all.rb +1 -1
- data/lib/test_prof/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97628c14c29719b463c2937602d31e201bafcf3f910b94fb11ee28bd8f23aaf5
|
4
|
+
data.tar.gz: 4f924233ae1dfeb81bcca92624c741980c8d7c07a5a02d88909a08685a1980d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 865839f6c518c531be8c41701beb5714fadbbd1824cb96af8509e7a6b601973551a1bbdd0019000df001c82916c12d1232ee9caefeeb1be2eef384056f57da8a
|
7
|
+
data.tar.gz: 775d73f88529efdf0c3ad9d93354b0ca18c58640a2fc958d9615773b16f53776d8006d93a1c3094fd02f57bd2d1a412edd35e955369ed477f3102e6a443a1556
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.4.3 (2024-12-18)
|
6
|
+
|
7
|
+
- Fix handling new (lazy) connection pools in `before_all`. ([@palkan][])
|
8
|
+
|
9
|
+
- Updates Rubocop::Cop code to comply with most modern API. ([@aseroff][])
|
10
|
+
|
5
11
|
## 1.4.2 (2024-09-03) 🗓️
|
6
12
|
|
7
13
|
- Ignore default scopes in `ActiveRecord::Base#refind`. ([@palkan][])
|
@@ -10,6 +10,7 @@ module TestProf
|
|
10
10
|
class << self
|
11
11
|
if ::ActiveRecord::Base.connection.pool.respond_to?(:pin_connection!)
|
12
12
|
def begin_transaction
|
13
|
+
subscribe!
|
13
14
|
::ActiveRecord::Base.connection_handler.connection_pool_list(:writing).each do |pool|
|
14
15
|
pool.pin_connection!(true)
|
15
16
|
end
|
@@ -19,6 +20,26 @@ module TestProf
|
|
19
20
|
::ActiveRecord::Base.connection_handler.connection_pool_list(:writing).each do |pool|
|
20
21
|
pool.unpin_connection!
|
21
22
|
end
|
23
|
+
unsubscribe!
|
24
|
+
end
|
25
|
+
|
26
|
+
def subscribe!
|
27
|
+
Thread.current[:before_all_connection_subscriber] = ActiveSupport::Notifications.subscribe("!connection.active_record") do |_, _, _, _, payload|
|
28
|
+
connection_name = payload[:connection_name] if payload.key?(:connection_name)
|
29
|
+
shard = payload[:shard] if payload.key?(:shard)
|
30
|
+
next unless connection_name
|
31
|
+
|
32
|
+
pool = ::ActiveRecord::Base.connection_handler.retrieve_connection_pool(connection_name, shard: shard)
|
33
|
+
next unless pool && pool.role == :writing
|
34
|
+
|
35
|
+
pool.pin_connection!(true)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def unsubscribe!
|
40
|
+
return unless Thread.current[:before_all_connection_subscriber]
|
41
|
+
ActiveSupport::Notifications.unsubscribe(Thread.current[:before_all_connection_subscriber])
|
42
|
+
Thread.current[:before_all_connection_subscriber] = nil
|
22
43
|
end
|
23
44
|
else
|
24
45
|
def all_connections
|
@@ -5,7 +5,7 @@ require "test_prof/cops/rspec/language"
|
|
5
5
|
module RuboCop
|
6
6
|
module Cop
|
7
7
|
module RSpec
|
8
|
-
class AggregateExamples < ::RuboCop::Cop::
|
8
|
+
class AggregateExamples < ::RuboCop::Cop::Base
|
9
9
|
# When aggregated, the expectations will fail when not supposed to or
|
10
10
|
# have a risk of not failing when expected to. One example is
|
11
11
|
# `validate_presence_of :comment` as it leaves an empty comment after
|
@@ -108,7 +108,8 @@ module RuboCop
|
|
108
108
|
# expect(number).to be_odd
|
109
109
|
# end
|
110
110
|
#
|
111
|
-
class AggregateExamples < ::RuboCop::Cop::
|
111
|
+
class AggregateExamples < ::RuboCop::Cop::Base
|
112
|
+
extend AutoCorrector
|
112
113
|
include LineRangeHelpers
|
113
114
|
include MetadataHelpers
|
114
115
|
include NodeMatchers
|
@@ -123,29 +124,22 @@ module RuboCop
|
|
123
124
|
def on_block(node)
|
124
125
|
example_group_with_several_examples(node) do |all_examples|
|
125
126
|
example_clusters(all_examples).each do |_, examples|
|
126
|
-
examples
|
127
|
+
examples.drop(1).each do |example|
|
127
128
|
add_offense(example,
|
128
|
-
|
129
|
-
|
129
|
+
message: message_for(example, examples[0])) do |corrector|
|
130
|
+
clusters = example_clusters_for_autocorrect(example)
|
131
|
+
clusters.each do |metadata, examples|
|
132
|
+
range = range_for_replace(examples)
|
133
|
+
replacement = aggregated_example(examples, metadata)
|
134
|
+
corrector.replace(range, replacement)
|
135
|
+
examples.drop(1).map { |example| drop_example(corrector, example) }
|
136
|
+
end
|
137
|
+
end
|
130
138
|
end
|
131
139
|
end
|
132
140
|
end
|
133
141
|
end
|
134
142
|
|
135
|
-
def autocorrect(example_node)
|
136
|
-
clusters = example_clusters_for_autocorrect(example_node)
|
137
|
-
return if clusters.empty?
|
138
|
-
|
139
|
-
lambda do |corrector|
|
140
|
-
clusters.each do |metadata, examples|
|
141
|
-
range = range_for_replace(examples)
|
142
|
-
replacement = aggregated_example(examples, metadata)
|
143
|
-
corrector.replace(range, replacement)
|
144
|
-
examples[1..].map { |example| drop_example(corrector, example) }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
143
|
private
|
150
144
|
|
151
145
|
# Clusters of examples in the same example group, on the same nesting
|
@@ -104,7 +104,7 @@ module TestProf
|
|
104
104
|
if base.respond_to?(:parallelize_teardown)
|
105
105
|
base.parallelize_teardown do
|
106
106
|
last_klass = ::Minitest.previous_klass
|
107
|
-
if last_klass&.respond_to?(:parallelized) && last_klass
|
107
|
+
if last_klass&.respond_to?(:parallelized) && last_klass.parallelized
|
108
108
|
last_klass.before_all_executor&.deactivate!
|
109
109
|
end
|
110
110
|
end
|
data/lib/test_prof/version.rb
CHANGED
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: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|