test-prof 1.1.0 → 1.2.1

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: 9e19d20bbf0af4e016f9dabfe56e8074cce79d750a359555a2855b982298aa8b
4
- data.tar.gz: 609607e479fabd363a6ee27e20b2f55845c9a5682fdec6352b5411b7c20e5ed5
3
+ metadata.gz: c7db3f483d344fd783b2438241a2c1498789367740412a66b1586b1ba9a745e0
4
+ data.tar.gz: a5c652b48e625d0872add68708a544ea9f929af83cd4e802dffdc277d01c2d5f
5
5
  SHA512:
6
- metadata.gz: a17fe83206dd28c8b632acc3cfeb79c1acdf8344fbb199f1a688f1e61ef9f11097f0de0cc04ba1d153d108c2e966622062ea4e9917c2e8083c921de7b5bba9b6
7
- data.tar.gz: cdaf249b8072a916dad83d690d32d9264ff40c46c542f26374fd217324af99a04be61560753d37ee44a0298f05b71d1ef0616e62bf020035414c4ed28d51fab3
6
+ metadata.gz: ddb20836e08c4488e878b3dc91950f52a812251197b1e1ab697ec3f874d2c9a6ba891fe29bcf8124685ceafa58fa2fe953e873d9f5eff535bf60f55d786d52d6
7
+ data.tar.gz: f54e9e90d3924a344ae97fe3fed45f976e7e91f8513a6a7190153dadeb215b00fa2c3920ea2903e5553c00e8968964b8119117423d1a2f49d9e0d4232f76f4b9
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.2.1 (2023-03-22)
6
+
7
+ - Fix regression with `before_all(setup_fixtures: true)` and `rspec-rails` v6.0+. ([@palkan][])
8
+
9
+ - Upgrade to RubyProf 1.4+. ([@palkan][])
10
+
11
+ ## 1.2.0 (2023-02-07)
12
+
13
+ - Add support for multiple databases to `before_all` / `let_it_be` with Active Record. ([@rutgerw][])
14
+
5
15
  ## 1.1.0 (2022-12-06)
6
16
 
7
17
  - LetItBe: freeze records during initialization with `freeze: true`. ([@palkan][])
@@ -279,7 +289,7 @@ end
279
289
  - Add threshold and custom event support to FactoryDoctor. ([@palkan][])
280
290
 
281
291
  ```sh
282
- $ FDOC=1 FDOC_EVENT="sql.rom" FDOC_THRESHOLD=0.1 rspec
292
+ FDOC=1 FDOC_EVENT="sql.rom" FDOC_THRESHOLD=0.1 rspec
283
293
  ```
284
294
 
285
295
  - Add Fabrication support to FactoryDoctor. ([@palkan][])
@@ -328,16 +338,6 @@ end
328
338
  See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md) for versions <0.9.0.
329
339
 
330
340
  [@palkan]: https://github.com/palkan
331
- [@marshall-lee]: https://github.com/marshall-lee
332
- [@danielwestendorf]: https://github.com/danielwestendorf
333
- [@shkrt]: https://github.com/Shkrt
334
- [@idolgirev]: https://github.com/IDolgirev
335
- [@desoleary]: https://github.com/desoleary
336
- [@rabotyaga]: https://github.com/rabotyaga
337
- [@vasfed]: https://github.com/Vasfed
338
- [@szemek]: https://github.com/szemek
339
- [@mkldon]: https://github.com/mkldon
340
- [@dmagro]: https://github.com/dmagro
341
341
  [@danielwaterworth]: https://github.com/danielwaterworth
342
342
  [@envek]: https://github.com/Envek
343
343
  [@tyleriguchi]: https://github.com/tyleriguchi
@@ -347,9 +347,12 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
347
347
  [@stefkin]: https://github.com/stefkin
348
348
  [@jaimerson]: https://github.com/jaimerson
349
349
  [@alexvko]: https://github.com/alexvko
350
- [@grillermo]: https://github.com/grillermo
351
350
  [@cou929]: https://github.com/cou929
352
351
  [@ruslanshakirov]: https://github.com/ruslanshakirov
353
352
  [@ygelfand]: https://github.com/ygelfand
354
353
  [@cbliard]: https://github.com/cbliard
355
354
  [@maxshend]: https://github.com/maxshend
355
+ [@rutgerw]: https://github.com/rutgerw
356
+ [@markedmondson]: https://github.com/markedmondson
357
+ [@cbarton]: https://github.com/cbarton
358
+ [@peret]: https://github.com/peret
@@ -102,19 +102,6 @@ module TestProf
102
102
  yield config
103
103
  end
104
104
 
105
- # Backward compatibility
106
- def reporting_enabled=(val)
107
- warn "AnyFixture.reporting_enabled is deprecated and will be removed in 1.1. Use AnyFixture.config.reporting_enabled instead"
108
- config.reporting_enabled = val
109
- end
110
-
111
- def reporting_enabled
112
- warn "AnyFixture.reporting_enabled is deprecated and will be removed in 1.1. Use AnyFixture.config.reporting_enabled instead"
113
- config.reporting_enabled
114
- end
115
-
116
- alias_method :reporting_enabled?, :reporting_enabled
117
-
118
105
  # Register a block of code as a fixture,
119
106
  # returns the result of the block execution
120
107
  def register(id)
@@ -6,17 +6,30 @@ module TestProf
6
6
  # ActiveRecord adapter for `before_all`
7
7
  module ActiveRecord
8
8
  class << self
9
+ def all_connections
10
+ @all_connections ||= if ::ActiveRecord::Base.respond_to? :connects_to
11
+ ::ActiveRecord::Base.connection_handler.connection_pool_list.map(&:connection)
12
+ else
13
+ Array.wrap(::ActiveRecord::Base.connection)
14
+ end
15
+ end
16
+
9
17
  def begin_transaction
10
- ::ActiveRecord::Base.connection.begin_transaction(joinable: false)
18
+ @all_connections = nil
19
+ all_connections.each do |connection|
20
+ connection.begin_transaction(joinable: false)
21
+ end
11
22
  end
12
23
 
13
24
  def rollback_transaction
14
- if ::ActiveRecord::Base.connection.open_transactions.zero?
15
- warn "!!! before_all transaction has been already rollbacked and " \
16
- "could work incorrectly"
17
- return
25
+ all_connections.each do |connection|
26
+ if connection.open_transactions.zero?
27
+ warn "!!! before_all transaction has been already rollbacked and " \
28
+ "could work incorrectly"
29
+ next
30
+ end
31
+ connection.rollback_transaction
18
32
  end
19
- ::ActiveRecord::Base.connection.rollback_transaction
20
33
  end
21
34
 
22
35
  def setup_fixtures(test_object)
@@ -12,6 +12,7 @@ module TestProf
12
12
  if within_before_all?
13
13
  before(:all) do
14
14
  @__inspect_output = "before_all hook"
15
+ ::RSpec.current_scope = :before_all if ::RSpec.respond_to?(:current_scope=)
15
16
  instance_eval(&block)
16
17
  end
17
18
  return
@@ -22,6 +23,7 @@ module TestProf
22
23
 
23
24
  before(:all) do
24
25
  @__inspect_output = "before_all hook"
26
+ ::RSpec.current_scope = :before_all if ::RSpec.respond_to?(:current_scope=)
25
27
  BeforeAll.setup_fixtures(self) if setup_fixtures
26
28
  BeforeAll.begin_transaction(context, current_metadata) do
27
29
  instance_eval(&block)
@@ -82,10 +82,12 @@ module TestProf
82
82
  "Available modifiers are: #{modifiers.keys.join(", ")}"
83
83
  end
84
84
  end
85
+
85
86
  # Use uniq prefix for instance variables to avoid collisions
86
87
  # We want to use the power of Ruby's unicode support)
87
88
  # And we love cats!)
88
- PREFIX = "@😸"
89
+ # Allow overriding the prefix (there are some intermittent issues on JRuby still)
90
+ PREFIX = ENV.fetch("LET_IT_BE_IVAR_PREFIX", "@😸")
89
91
 
90
92
  FROZEN_ERROR_HINT = "\nIf you are using `let_it_be`, you may want to pass `reload: true` or `refind: true` modifier to it."
91
93
 
@@ -118,11 +120,13 @@ module TestProf
118
120
  LetItBe.module_for(self).module_eval do
119
121
  define_method(identifier) do
120
122
  # Trying to detect the context
121
- # Based on https://github.com/rspec/rspec-rails/commit/7cb796db064f58da7790a92e73ab906ef50b1f34
122
- if /(before|after)\(:context\)/.match?(@__inspect_output) || @__inspect_output.include?("before_all")
123
+ # First, check for ::RSpec.current_scope (modern RSpec) and then read @__inspect_output
124
+ # (based on https://github.com/rspec/rspec-rails/commit/7cb796db064f58da7790a92e73ab906ef50b1f34)
125
+ if ::RSpec.respond_to?(:current_scope) && %i[before_all before_context_hook after_context_hook].include?(::RSpec.current_scope)
126
+ instance_variable_get(:"#{PREFIX}#{identifier}")
127
+ elsif /(before|after)\(:context\)/.match?(@__inspect_output) || @__inspect_output.include?("before_all")
123
128
  instance_variable_get(:"#{PREFIX}#{identifier}")
124
129
  else
125
- # Fallback to let definition
126
130
  super()
127
131
  end
128
132
  end
@@ -173,9 +173,7 @@ module TestProf
173
173
 
174
174
  return unless init_ruby_prof
175
175
 
176
- options = {
177
- merge_fibers: true
178
- }
176
+ options = {}
179
177
 
180
178
  options[:include_threads] = [Thread.current] unless
181
179
  config.include_threads?
@@ -214,7 +212,7 @@ module TestProf
214
212
  <<~MSG
215
213
  Please, install 'ruby-prof' first:
216
214
  # Gemfile
217
- gem 'ruby-prof', '>= 0.16.0', require: false
215
+ gem 'ruby-prof', '>= 1.4.0', require: false
218
216
  MSG
219
217
  ) { check_ruby_prof_version }
220
218
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.1"
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: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-06 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rspec-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '3.4'
47
+ version: '4.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.4'
54
+ version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isolator
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubygems_version: 3.3.11
240
+ rubygems_version: 3.4.8
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: Ruby applications tests profiling tools