test-prof 1.4.0 → 1.4.2

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: 6636a3c69af7cd067079bd1e91ef72d38b650a372a13e6363c3de9e510a8970b
4
- data.tar.gz: 2f1a503a8adcf4af85cad6b98ab4682394c5222b1f5290cc6aaeec97da77ef06
3
+ metadata.gz: db12b48471cc8814d90d2388415798a742a5b5d69f61862bc88c12ac118e80c2
4
+ data.tar.gz: 9c930443a46e765d13b4528725d795aef8e4a2ab9b9c2c7a3939e2cb458ebd03
5
5
  SHA512:
6
- metadata.gz: 68701c8c91b20f810ff93f3e3360d4f8f7b3210a2014f3a4463542b0e31b657ab3093da4eaf4b2bf9cee59d1e99ded9ef51d83e7a27855f05113f681219f7888
7
- data.tar.gz: 438a4297ebff65d6f9d5aec752775a638f5c6255c63d439f278eda596825595c2b6d74cc609057c42712247a98eefb07c42dcd1133d4d1ae5162898a2af5068c
6
+ metadata.gz: 6fe1ff6102261d0b8c3c9e88e982255996b01ec6a34a9bc0d812a5021e8dd193aba57feca87d467c99f93973e98ed4cc4e94c94e8e1ab2e7b61dce806eeebedc
7
+ data.tar.gz: db01e089936817767666c9d8d8fc11c0e2765bbb254be6e1baa5fac3ab26de7ad6d2b937dca7c6f0bef72fb60045caef2e909bf196978ebe94aef0c7f54da1c4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.4.2 (2024-09-03) 🗓️
6
+
7
+ - Ignore default scopes in `ActiveRecord::Base#refind`. ([@palkan][])
8
+
9
+ ## 1.4.1 (2024-08-23)
10
+
11
+ - Skips loading the ActiveRecord adapter for runs where RSpec --dry-run mode is enabled. ([@devinburnette][])
12
+
5
13
  ## 1.4.0 (2024-08-12)
6
14
 
7
15
  - AnyFixture: Disable fixtures cache within _clean fixture_ context. Automatically _refind_ records when using `#fixture`. ([@palkan][])
@@ -434,3 +442,4 @@ See [changelog](https://github.com/test-prof/test-prof/blob/v0.8.0/CHANGELOG.md)
434
442
  [@lioneldebauge]: https://github.com/lioneldebauge
435
443
  [@lHydra]: https://github.com/lHydra
436
444
  [@john-h-k]: https://github.com/john-h-k
445
+ [@devinburnette]: https://github.com/devinburnette
@@ -14,8 +14,26 @@ module TestProf
14
14
  end
15
15
  end
16
16
 
17
+ # Used in dry-run mode
18
+ class NoopAdapter
19
+ class << self
20
+ def begin_transaction(...)
21
+ end
22
+
23
+ def rollback_transaction(...)
24
+ end
25
+
26
+ def setup_fixtures(...)
27
+ end
28
+ end
29
+ end
30
+
17
31
  class << self
18
- attr_accessor :adapter
32
+ attr_writer :adapter
33
+
34
+ def adapter
35
+ @adapter ||= default_adapter
36
+ end
19
37
 
20
38
  def begin_transaction(scope = nil, metadata = [])
21
39
  raise AdapterMissing if adapter.nil?
@@ -47,6 +65,17 @@ module TestProf
47
65
  def configure
48
66
  yield config
49
67
  end
68
+
69
+ private
70
+
71
+ def default_adapter
72
+ return NoopAdapter if TestProf.dry_run?
73
+
74
+ if defined?(::ActiveRecord::Base)
75
+ require "test_prof/before_all/adapters/active_record"
76
+ Adapters::ActiveRecord
77
+ end
78
+ end
50
79
  end
51
80
 
52
81
  class HookEntry # :nodoc:
@@ -138,12 +167,6 @@ module TestProf
138
167
  end
139
168
  end
140
169
 
141
- if defined?(::ActiveRecord::Base)
142
- require "test_prof/before_all/adapters/active_record"
143
-
144
- TestProf::BeforeAll.adapter = TestProf::BeforeAll::Adapters::ActiveRecord
145
- end
146
-
147
170
  if defined?(::Isolator)
148
171
  require "test_prof/before_all/isolator"
149
172
  end
@@ -64,7 +64,7 @@ module RuboCop
64
64
  return super unless its?(example.send_node)
65
65
 
66
66
  # First parameter to `its` is not metadata.
67
- example.send_node.arguments[1..-1]
67
+ example.send_node.arguments[1..]
68
68
  end
69
69
 
70
70
  def its?(node)
@@ -123,7 +123,7 @@ module RuboCop
123
123
  def on_block(node)
124
124
  example_group_with_several_examples(node) do |all_examples|
125
125
  example_clusters(all_examples).each do |_, examples|
126
- examples[1..-1].each do |example|
126
+ examples[1..].each do |example|
127
127
  add_offense(example,
128
128
  location: :expression,
129
129
  message: message_for(example, examples[0]))
@@ -141,7 +141,7 @@ module RuboCop
141
141
  range = range_for_replace(examples)
142
142
  replacement = aggregated_example(examples, metadata)
143
143
  corrector.replace(range, replacement)
144
- examples[1..-1].map { |example| drop_example(corrector, example) }
144
+ examples[1..].map { |example| drop_example(corrector, example) }
145
145
  end
146
146
  end
147
147
  end
@@ -75,6 +75,10 @@ module TestProf
75
75
  defined?(::Spring::Application) && (disabled.nil? || disabled.empty? || disabled == "0")
76
76
  end
77
77
 
78
+ def dry_run?
79
+ rspec? && ::RSpec.configuration.dry_run?
80
+ end
81
+
78
82
  # Returns the current process time
79
83
  def now
80
84
  Process.clock_gettime_for_test_prof(Process::CLOCK_MONOTONIC)
@@ -12,7 +12,7 @@ module TestProf
12
12
  #
13
13
  # We need it to make sure that the state is clean.
14
14
  def refind
15
- self.class.find(send(self.class.primary_key))
15
+ self.class.unscoped.find(send(self.class.primary_key))
16
16
  end
17
17
  end
18
18
  end
@@ -12,7 +12,7 @@ module TestProf
12
12
  head = ((limit - 3) / 2)
13
13
  tail = head + 3 - limit
14
14
 
15
- "#{self[0..(head - 1)]}...#{self[tail..-1]}"
15
+ "#{self[0..(head - 1)]}...#{self[tail..]}"
16
16
  end
17
17
  end
18
18
  end
@@ -3,7 +3,7 @@
3
3
  module TestProf # :nodoc: all
4
4
  FACTORY_GIRL_NAMES = {"factory_bot" => "::FactoryBot", "factory_girl" => "::FactoryGirl"}.freeze
5
5
 
6
- TestProf.require("active_support/inflector")
6
+ TestProf.require("active_support")
7
7
 
8
8
  FACTORY_GIRL_NAMES.find do |name, cname|
9
9
  TestProf.require(name) do
@@ -143,7 +143,7 @@ module TestProf
143
143
  elsif expr.first == :@const
144
144
  expr[1]
145
145
  elsif expr.first == :const_path_ref
146
- expr[1..-1].map(&method(:parse_const)).join("::")
146
+ expr[1..].map(&method(:parse_const)).join("::")
147
147
  end
148
148
  end
149
149
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "1.4.0"
4
+ VERSION = "1.4.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: 1.4.0
4
+ version: 1.4.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: 2024-08-12 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler