test-prof 1.4.2 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -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/rspec_stamp.rb +7 -5
- 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: 3cfa0f1751f398092de8ffa46d5bff81bb9eadd7b90caaf9293c62c93c6b3e20
|
4
|
+
data.tar.gz: 3afcb831782f0e58881839f33af07a41b3b42d63ac8eb87c35b6fd0eb01537ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2de8fb8232f5ed623167846c37cce6224b297761324acdf6a17a47338e2a3904aa480b48fc9793a51f5595d3d839c3ff3bc9fbb262c7900ad3d7c819113947a0
|
7
|
+
data.tar.gz: dcec92d722f9e7cce9f1d371a2c6d363aa9a78a6cf1149a73d8b836a269ebf6bd14e50d86a8470cccc56a861b94646ad23494f43de6d9beb0cc6a5b478f77e93
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 1.4.4 (2025-01-03)
|
6
|
+
|
7
|
+
- Fix _stamping_ specs with single quotes with Rpsec Stamp. ([@elasticspoon][])
|
8
|
+
|
9
|
+
## 1.4.3 (2024-12-18)
|
10
|
+
|
11
|
+
- Fix handling new (lazy) connection pools in `before_all`. ([@palkan][])
|
12
|
+
|
13
|
+
- Updates Rubocop::Cop code to comply with most modern API. ([@aseroff][])
|
14
|
+
|
5
15
|
## 1.4.2 (2024-09-03) 🗓️
|
6
16
|
|
7
17
|
- Ignore default scopes in `ActiveRecord::Base#refind`. ([@palkan][])
|
@@ -443,3 +453,4 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
|
|
443
453
|
[@lHydra]: https://github.com/lHydra
|
444
454
|
[@john-h-k]: https://github.com/john-h-k
|
445
455
|
[@devinburnette]: https://github.com/devinburnette
|
456
|
+
[@elasticspoon]: https://github.com/elasticspoon
|
@@ -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
|
@@ -153,14 +153,16 @@ module TestProf
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
replacement =
|
157
|
-
|
158
|
-
|
156
|
+
replacement = proc do
|
157
|
+
$1 + "#{parsed.fname}#{need_parens ? "(" : " "}" \
|
158
|
+
"#{[desc, tags_str, htags_str].compact.join(", ")}" \
|
159
|
+
"#{need_parens ? ") " : " "}" + $3
|
160
|
+
end
|
159
161
|
|
160
162
|
if config.dry_run?
|
161
|
-
log :info, "Patched: #{example.sub(EXAMPLE_RXP, replacement)}"
|
163
|
+
log :info, "Patched: #{example.sub(EXAMPLE_RXP, &replacement)}"
|
162
164
|
else
|
163
|
-
example.sub!(EXAMPLE_RXP, replacement)
|
165
|
+
example.sub!(EXAMPLE_RXP, &replacement)
|
164
166
|
end
|
165
167
|
true
|
166
168
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|