fixtury 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -1
- data/.github/workflows/build.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +81 -20
- data/README.md +3 -1
- data/lib/fixtury/minitest_hooks.rb +6 -45
- data/lib/fixtury/reference.rb +1 -1
- data/lib/fixtury/store.rb +1 -1
- data/lib/fixtury/version.rb +1 -1
- data/lib/fixtury.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03e33235b7dd547261eea486aee6d6ed0351157a11d1c76757d49b27c93b1b39
|
4
|
+
data.tar.gz: 8bd05c9be267d73b48b55fd7f20a4f6164ea22b41ba3ec889a8fd63026240e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a4e6331284da0e92b6af11567dd8d8e35ac079ddb8029a2c10ddc42538bce1157964dd923dda9a42819aedfc765d7095711863714d2490ed05759090ee0bc4
|
7
|
+
data.tar.gz: fa19480c1a11de53003580bf1a328561c00b11922c2aaeb34925961e8ab2a173a0185cbbd9db4ff60735ea2d013da16c914ae7e4e4f7df706d86289f15fa69a2
|
data/.github/dependabot.yml
CHANGED
@@ -21,4 +21,15 @@ updates:
|
|
21
21
|
open-pull-requests-limit: 20
|
22
22
|
insecure-external-code-execution: deny
|
23
23
|
commit-message:
|
24
|
-
prefix: "[bundler] "
|
24
|
+
prefix: "[bundler] "
|
25
|
+
groups:
|
26
|
+
monthly:
|
27
|
+
patterns:
|
28
|
+
- "*"
|
29
|
+
ignore:
|
30
|
+
- dependency-name: "activesupport"
|
31
|
+
update-types: ["version-update:semver-major"]
|
32
|
+
- dependency-name: "activemodel"
|
33
|
+
update-types: ["version-update:semver-major"]
|
34
|
+
- dependency-name: "activerecord"
|
35
|
+
update-types: ["version-update:semver-major"]
|
data/.github/workflows/build.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.6
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,80 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fixtury (
|
4
|
+
fixtury (2.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activemodel (7.
|
10
|
-
activesupport (= 7.
|
11
|
-
activerecord (7.
|
12
|
-
activemodel (= 7.
|
13
|
-
activesupport (= 7.
|
9
|
+
activemodel (7.2.2.1)
|
10
|
+
activesupport (= 7.2.2.1)
|
11
|
+
activerecord (7.2.2.1)
|
12
|
+
activemodel (= 7.2.2.1)
|
13
|
+
activesupport (= 7.2.2.1)
|
14
14
|
timeout (>= 0.4.0)
|
15
|
-
activesupport (7.
|
15
|
+
activesupport (7.2.2.1)
|
16
16
|
base64
|
17
|
+
benchmark (>= 0.3)
|
17
18
|
bigdecimal
|
18
|
-
concurrent-ruby (~> 1.0, >= 1.
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
19
20
|
connection_pool (>= 2.2.5)
|
20
21
|
drb
|
21
22
|
i18n (>= 1.6, < 2)
|
23
|
+
logger (>= 1.4.2)
|
22
24
|
minitest (>= 5.1)
|
23
|
-
|
24
|
-
tzinfo (~> 2.0)
|
25
|
+
securerandom (>= 0.3)
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
25
27
|
base64 (0.2.0)
|
26
|
-
|
28
|
+
benchmark (0.4.0)
|
29
|
+
bigdecimal (3.1.9)
|
27
30
|
byebug (11.1.3)
|
28
|
-
concurrent-ruby (1.
|
31
|
+
concurrent-ruby (1.3.4)
|
29
32
|
connection_pool (2.4.1)
|
30
33
|
drb (2.2.1)
|
31
34
|
globalid (1.2.1)
|
32
35
|
activesupport (>= 6.1)
|
33
|
-
i18n (1.14.
|
36
|
+
i18n (1.14.6)
|
34
37
|
concurrent-ruby (~> 1.0)
|
38
|
+
logger (1.6.4)
|
35
39
|
m (1.6.2)
|
36
40
|
method_source (>= 0.6.7)
|
37
41
|
rake (>= 0.9.2.2)
|
38
42
|
method_source (1.1.0)
|
39
|
-
mini_portile2 (2.8.
|
40
|
-
minitest (5.
|
41
|
-
mocha (2.
|
43
|
+
mini_portile2 (2.8.8)
|
44
|
+
minitest (5.25.4)
|
45
|
+
mocha (2.7.1)
|
42
46
|
ruby2_keywords (>= 0.0.5)
|
43
|
-
mutex_m (0.2.0)
|
44
47
|
rake (13.2.1)
|
45
48
|
ruby2_keywords (0.0.5)
|
46
|
-
|
49
|
+
securerandom (0.4.1)
|
50
|
+
sqlite3 (2.5.0)
|
47
51
|
mini_portile2 (~> 2.8.0)
|
48
|
-
|
52
|
+
sqlite3 (2.5.0-aarch64-linux-gnu)
|
53
|
+
sqlite3 (2.5.0-aarch64-linux-musl)
|
54
|
+
sqlite3 (2.5.0-arm-linux-gnu)
|
55
|
+
sqlite3 (2.5.0-arm-linux-musl)
|
56
|
+
sqlite3 (2.5.0-arm64-darwin)
|
57
|
+
sqlite3 (2.5.0-x86-linux-gnu)
|
58
|
+
sqlite3 (2.5.0-x86-linux-musl)
|
59
|
+
sqlite3 (2.5.0-x86_64-darwin)
|
60
|
+
sqlite3 (2.5.0-x86_64-linux-gnu)
|
61
|
+
sqlite3 (2.5.0-x86_64-linux-musl)
|
62
|
+
timeout (0.4.3)
|
49
63
|
tzinfo (2.0.6)
|
50
64
|
concurrent-ruby (~> 1.0)
|
51
65
|
|
52
66
|
PLATFORMS
|
67
|
+
aarch64-linux-gnu
|
68
|
+
aarch64-linux-musl
|
69
|
+
arm-linux-gnu
|
70
|
+
arm-linux-musl
|
71
|
+
arm64-darwin
|
53
72
|
ruby
|
73
|
+
x86-linux-gnu
|
74
|
+
x86-linux-musl
|
75
|
+
x86_64-darwin
|
76
|
+
x86_64-linux-gnu
|
77
|
+
x86_64-linux-musl
|
54
78
|
|
55
79
|
DEPENDENCIES
|
56
80
|
activerecord
|
@@ -64,5 +88,42 @@ DEPENDENCIES
|
|
64
88
|
rake
|
65
89
|
sqlite3
|
66
90
|
|
91
|
+
CHECKSUMS
|
92
|
+
activemodel (7.2.2.1) sha256=8398861f9ee2c4671a8357ab39e9b38a045fd656f6685a3dd5890c2419dbfdaf
|
93
|
+
activerecord (7.2.2.1) sha256=79a31f71c32d5138717c2104e0ff105f5d82922247c85bdca144f2720e67fab9
|
94
|
+
activesupport (7.2.2.1) sha256=842bcbf8a92977f80fb4750661a237cf5dd4fdd442066b3c35e88afb488647f5
|
95
|
+
base64 (0.2.0) sha256=0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507
|
96
|
+
benchmark (0.4.0) sha256=0f12f8c495545e3710c3e4f0480f63f06b4c842cc94cec7f33a956f5180e874a
|
97
|
+
bigdecimal (3.1.9) sha256=2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc
|
98
|
+
byebug (11.1.3) sha256=2485944d2bb21283c593d562f9ae1019bf80002143cc3a255aaffd4e9cf4a35b
|
99
|
+
concurrent-ruby (1.3.4) sha256=d4aa926339b0a86b5b5054a0a8c580163e6f5dcbdfd0f4bb916b1a2570731c32
|
100
|
+
connection_pool (2.4.1) sha256=0f40cf997091f1f04ff66da67eabd61a9fe0d4928b9a3645228532512fab62f4
|
101
|
+
drb (2.2.1) sha256=e9d472bf785f558b96b25358bae115646da0dbfd45107ad858b0bc0d935cb340
|
102
|
+
fixtury (2.0.0)
|
103
|
+
globalid (1.2.1) sha256=70bf76711871f843dbba72beb8613229a49429d1866828476f9c9d6ccc327ce9
|
104
|
+
i18n (1.14.6) sha256=dc229a74f5d181f09942dd60ab5d6e667f7392c4ee826f35096db36d1fe3614c
|
105
|
+
logger (1.6.4) sha256=b627b91c922231050932e7bf8ee886fe54790ba2238a468ead52ba21911f2ee7
|
106
|
+
m (1.6.2) sha256=2fb85aff050b6b699e6dbca47b45d426e2136ccdfabb64437e9630230d29108e
|
107
|
+
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
|
108
|
+
mini_portile2 (2.8.8) sha256=8e47136cdac04ce81750bb6c09733b37895bf06962554e4b4056d78168d70a75
|
109
|
+
minitest (5.25.4) sha256=9cf2cae25ac4dfc90c988ebc3b917f53c054978b673273da1bd20bcb0778f947
|
110
|
+
mocha (2.7.1) sha256=8f7d538d5d3ebc75fc788b3d92fbab913a93a78462d2a3ce99d1bdde7af7f851
|
111
|
+
rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d
|
112
|
+
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
|
113
|
+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
114
|
+
sqlite3 (2.5.0) sha256=87fa0036e6369c3f3cfeca749865c2b2b63649d3b17b223d1939a8eed4841a6b
|
115
|
+
sqlite3 (2.5.0-aarch64-linux-gnu) sha256=302085c3b932c027bc8de9f45fb5d0a3dc502357908dcc8f9bc8a92e4e9c7ab1
|
116
|
+
sqlite3 (2.5.0-aarch64-linux-musl) sha256=f6c8d25a6c7175bed154da82bc4c1ea3ef48580aeca17400b2e730c026821857
|
117
|
+
sqlite3 (2.5.0-arm-linux-gnu) sha256=5f22b4c72c38570593f9fe351751cb269568594525e0e3e0776187a3f1a55f32
|
118
|
+
sqlite3 (2.5.0-arm-linux-musl) sha256=b8e672106f341e9e4c85cdbc218710521c92082eec0ba61c180fb27a9c7780c6
|
119
|
+
sqlite3 (2.5.0-arm64-darwin) sha256=65370ddbc7bd7e65a03c18f8bf0e9be0f4f3cf50f758f8c1d3181aece5515ecf
|
120
|
+
sqlite3 (2.5.0-x86-linux-gnu) sha256=90488e9278ff23b9b22387a01354d5350b94d346fa9ab09256f154d0ca90dec6
|
121
|
+
sqlite3 (2.5.0-x86-linux-musl) sha256=09dd65d3752fb9d5cd93df841cbc357d2d117118f96f8b4122cd9cb38e020295
|
122
|
+
sqlite3 (2.5.0-x86_64-darwin) sha256=e3c6d2fa04db9d0773455cb6c79835f230c363424b69c34dd718e1aff8609d35
|
123
|
+
sqlite3 (2.5.0-x86_64-linux-gnu) sha256=c62c8d625da7e2ce93d694f02cd9c9d537638f56b09f2e8f28bea2d030b3923b
|
124
|
+
sqlite3 (2.5.0-x86_64-linux-musl) sha256=09fd262943eeb89465f6633e748b702b046de24cdab14b197302d0f4a0e250cb
|
125
|
+
timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e
|
126
|
+
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
127
|
+
|
67
128
|
BUNDLED WITH
|
68
|
-
2.
|
129
|
+
2.6.2
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ class MyTest < ::Minitest::Test
|
|
21
21
|
end
|
22
22
|
```
|
23
23
|
|
24
|
-
Loading this file would ensure `users/fresh` is loaded into the fixture set before the suite is run. In the context of Minitest::Test, the Fixtury::MinitestHooks file will ensure the
|
24
|
+
Loading this file would ensure `users/fresh` is loaded into the fixture set before the suite is run. In the context of Minitest::Test, the Fixtury::MinitestHooks file will ensure the fixtures are present prior to your suite running.
|
25
25
|
|
26
26
|
## Configuration
|
27
27
|
|
@@ -109,3 +109,5 @@ end
|
|
109
109
|
|
110
110
|
When installed with the railtie, a MutationObserver module is prepended into ActiveRecord::Base. It observes record mutations and ensures a record is not mutated outside of the declared isolation level. If you're not using ActiveRecord check out Fixtury::MutationObserver to see how you could hook into other frameworks.
|
111
111
|
|
112
|
+
In your test suite when utilizing the Fixtury::MinitestHooks records will be loaded before ActiveRecord's transactional fixtures transaction is opened. This means the you can define all your fixtures in your tests, they will be prebuilt and, as long as the fixtury references are preserved, all your fixtures are cached across runs. The fixtures in each file are loaded on demand which means only the fixtures necessary for the test to run are prebuilt (and cached for reuse). Standard transactional fixture rollback occurs after each test run so any mutation to fixtures will not be persisted.
|
113
|
+
|
@@ -7,8 +7,7 @@ module Fixtury
|
|
7
7
|
# MinitestHooks is a module designed to hook into a Minitest test case, and
|
8
8
|
# provide a way to load fixtures into the test case. It is designed to be
|
9
9
|
# prepended into the test case class, and will automatically load fixtures
|
10
|
-
# before the test case is setup
|
11
|
-
# case is torn down.
|
10
|
+
# before the test case is setup.
|
12
11
|
#
|
13
12
|
# The module also provides a way to define fixture dependencies, and will
|
14
13
|
# automatically load those dependencies before the test case is setup.
|
@@ -44,14 +43,15 @@ module Fixtury
|
|
44
43
|
#
|
45
44
|
# end
|
46
45
|
#
|
46
|
+
# Use `as: false` if you do not want an accessor created.
|
47
|
+
#
|
47
48
|
# A Set object named fixtury_dependencies is made available on the test class.
|
48
49
|
# This allows you to load all Minitest runnables and analyze what fixtures are
|
49
50
|
# needed. This is very helpful in CI pipelines when you want to prepare all fixtures
|
50
51
|
# ahead of time to share between multiple processes.
|
51
52
|
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# are present, those settings will be respected. If neither are present, a transaction will be used.
|
53
|
+
# It is the responsibility of the suite to manage the snapshot or rollback of the database. Generally
|
54
|
+
# something like ActiveRecord's use_transactional_fixtures will work just fine.
|
55
55
|
module MinitestHooks
|
56
56
|
|
57
57
|
def self.prepended(klass)
|
@@ -67,8 +67,7 @@ module Fixtury
|
|
67
67
|
module ClassMethods
|
68
68
|
|
69
69
|
# Declare fixtury dependencies for this test case. This will automatically
|
70
|
-
# load the fixtures before the test case is setup
|
71
|
-
# after the test case is torn down.
|
70
|
+
# load the fixtures before the test case is setup.
|
72
71
|
#
|
73
72
|
# @param searches [Array<String>] A list of fixture names to load. These should be resolvable paths relative to Fixtury.schema (root).
|
74
73
|
# @param opts [Hash] A list of options to customize the behavior of the fixtures.
|
@@ -115,12 +114,6 @@ module Fixtury
|
|
115
114
|
super
|
116
115
|
end
|
117
116
|
|
118
|
-
# Minitest after_teardown hook. This will rollback any changes made to the fixtures after the test.
|
119
|
-
def after_teardown(...)
|
120
|
-
super
|
121
|
-
fixtury_teardown if fixtury_dependencies.any?
|
122
|
-
end
|
123
|
-
|
124
117
|
# Access a fixture via a search term. This will access the fixture from the Fixtury store.
|
125
118
|
# If the fixture was not declared as a dependency, an error will be raised.
|
126
119
|
#
|
@@ -138,34 +131,10 @@ module Fixtury
|
|
138
131
|
Fixtury.store.get(dfn.pathname)
|
139
132
|
end
|
140
133
|
|
141
|
-
# Retrieve all database connections that are currently registered with a writing role.
|
142
|
-
#
|
143
|
-
# @return [Array<ActiveRecord::ConnectionAdapters::AbstractAdapter>] The list of database connections.
|
144
|
-
def fixtury_database_connections
|
145
|
-
return [] unless defined?(ActiveRecord::Base)
|
146
|
-
|
147
|
-
pools = ActiveRecord::Base.connection_handler.connection_pool_list(:writing)
|
148
|
-
pools.map { |pool| pool.respond_to?(:lease_connection) ? pool.lease_connection : pool.connection }
|
149
|
-
end
|
150
|
-
|
151
134
|
# Load all dependenct fixtures and begin a transaction for each database connection.
|
152
135
|
def fixtury_setup
|
153
136
|
Fixtury.store.clear_stale_references!
|
154
137
|
fixtury_load_all_fixtures!
|
155
|
-
return unless fixtury_use_transactions?
|
156
|
-
|
157
|
-
fixtury_database_connections.each do |conn|
|
158
|
-
conn.begin_transaction joinable: false
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# Rollback any changes made to the fixtures
|
163
|
-
def fixtury_teardown
|
164
|
-
return unless fixtury_use_transactions?
|
165
|
-
|
166
|
-
fixtury_database_connections.each do |conn|
|
167
|
-
conn.rollback_transaction if conn.open_transactions.positive?
|
168
|
-
end
|
169
138
|
end
|
170
139
|
|
171
140
|
# Load all fixture dependencies that have not previously been loaded into the store.
|
@@ -180,13 +149,5 @@ module Fixtury
|
|
180
149
|
end
|
181
150
|
end
|
182
151
|
|
183
|
-
# Adhere to common Rails test transaction settings.
|
184
|
-
def fixtury_use_transactions?
|
185
|
-
return use_transactional_tests if respond_to?(:use_transactional_tests)
|
186
|
-
return use_transactional_fixtures if respond_to?(:use_transactional_fixtures)
|
187
|
-
|
188
|
-
true
|
189
|
-
end
|
190
|
-
|
191
152
|
end
|
192
153
|
end
|
data/lib/fixtury/reference.rb
CHANGED
data/lib/fixtury/store.rb
CHANGED
@@ -236,7 +236,7 @@ module Fixtury
|
|
236
236
|
# @param ref [Fixtury::Reference] The reference to check.
|
237
237
|
# @return [TrueClass, FalseClass] `true` if the reference is stale, `false` otherwise.
|
238
238
|
def reference_stale?(ref)
|
239
|
-
return true if ttl && ref.created_at < (
|
239
|
+
return true if ttl && ref.created_at < (Fixtury.now.to_i - ttl)
|
240
240
|
|
241
241
|
!locator.recognizable_key?(ref.locator_key)
|
242
242
|
end
|
data/lib/fixtury/version.rb
CHANGED
data/lib/fixtury.rb
CHANGED
@@ -61,6 +61,12 @@ module Fixtury
|
|
61
61
|
@hooks ||= ::Fixtury::Hooks.new
|
62
62
|
end
|
63
63
|
|
64
|
+
def self.now
|
65
|
+
hooks.call(:time_access) do
|
66
|
+
::Time.now
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
64
70
|
# The default top level schema. Fixtury::Schema instances can be completely self-contained but most
|
65
71
|
# usage would be through this shared definition.
|
66
72
|
def self.schema
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixtury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
|
-
rubygems_version: 3.5.
|
201
|
+
rubygems_version: 3.5.23
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: Treat fixtures like factories and factories like fixtures
|