fixture_kit 0.1.0 → 0.1.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 +4 -4
- data/README.md +2 -2
- data/lib/fixture_kit/fixture_runner.rb +3 -3
- data/lib/fixture_kit/fixture_set.rb +1 -8
- data/lib/fixture_kit/transactional_harness.rb +29 -0
- data/lib/fixture_kit/version.rb +1 -1
- data/lib/fixture_kit.rb +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb41bba5897198dbdad616b7b1a44c02cb770b8150e9c005051e16a1935f8508
|
|
4
|
+
data.tar.gz: 8e5cb1af113f6fd2f56a0aac8727f2a2666a89fe1fe87b9499fc4c6951b94d02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c67e3477b6f2e4b8fb8f9d2ba480c2b37fd73fba173178662d7d20d6ce3c7737b483d1308faa7f5f9a60ce9f1a5b27076988b8bfdf48949ff5944b5d39d988a9
|
|
7
|
+
data.tar.gz: 054d623d8e2418720ff73c08a3699dd30471511060ed1581d977da215872e9eae902a0d84439499c816004ceebfbf624c2ac2e1bc91b3f0491231c9a191c3fbd
|
data/README.md
CHANGED
|
@@ -98,8 +98,8 @@ RSpec.describe Book do
|
|
|
98
98
|
expect(fixture.books.size).to eq(3)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
it "
|
|
102
|
-
expect(fixture
|
|
101
|
+
it "exposes records as methods" do
|
|
102
|
+
expect(fixture.owner.email).to eq("alice@example.com")
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
```
|
|
@@ -27,15 +27,15 @@ module FixtureKit
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Generate cache only (used for pregeneration in before(:suite))
|
|
30
|
-
# Wraps execution in
|
|
30
|
+
# Wraps execution in ActiveRecord::TestFixtures transactional lifecycle,
|
|
31
|
+
# so no data persists across configured writing pools.
|
|
31
32
|
# Always regenerates the cache, even if one exists
|
|
32
33
|
def generate_cache_only
|
|
33
34
|
# Clear any existing cache for this fixture
|
|
34
35
|
FixtureCache.clear(@fixture_name.to_s)
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
FixtureKit::TransactionalHarness.run do
|
|
37
38
|
execute_and_cache
|
|
38
|
-
raise ActiveRecord::Rollback
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
true
|
|
@@ -4,17 +4,10 @@ module FixtureKit
|
|
|
4
4
|
class FixtureSet
|
|
5
5
|
def initialize(exposed_records)
|
|
6
6
|
@records = exposed_records
|
|
7
|
+
@records.each_value { |value| value.freeze if value.is_a?(Array) }
|
|
7
8
|
define_accessors
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
def [](name)
|
|
11
|
-
@records[name.to_sym]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def to_h
|
|
15
|
-
@records.dup
|
|
16
|
-
end
|
|
17
|
-
|
|
18
11
|
private
|
|
19
12
|
|
|
20
13
|
def define_accessors
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_record/fixtures"
|
|
4
|
+
|
|
5
|
+
module FixtureKit
|
|
6
|
+
# Runs arbitrary code inside ActiveRecord::TestFixtures lifecycle without
|
|
7
|
+
# defining a real test example. This gives us Rails' transactional handling
|
|
8
|
+
# across all configured writing pools.
|
|
9
|
+
class TransactionalHarness
|
|
10
|
+
include ActiveRecord::TestFixtures
|
|
11
|
+
|
|
12
|
+
def self.run(&block)
|
|
13
|
+
new.run(&block)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# ActiveRecord::TestFixtures checks `name` to decide whether the current
|
|
17
|
+
# method is marked with `uses_transaction`.
|
|
18
|
+
def name
|
|
19
|
+
"fixture_kit_transactional_harness"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def run
|
|
23
|
+
setup_fixtures
|
|
24
|
+
yield
|
|
25
|
+
ensure
|
|
26
|
+
teardown_fixtures
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/fixture_kit/version.rb
CHANGED
data/lib/fixture_kit.rb
CHANGED
|
@@ -17,6 +17,7 @@ module FixtureKit
|
|
|
17
17
|
autoload :SqlCapture, File.expand_path("fixture_kit/sql_capture", __dir__)
|
|
18
18
|
autoload :FixtureCache, File.expand_path("fixture_kit/fixture_cache", __dir__)
|
|
19
19
|
autoload :FixtureRunner, File.expand_path("fixture_kit/fixture_runner", __dir__)
|
|
20
|
+
autoload :TransactionalHarness, File.expand_path("fixture_kit/transactional_harness", __dir__)
|
|
20
21
|
|
|
21
22
|
extend Singleton
|
|
22
23
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fixture_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ngan Pham
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: appraisal
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rake
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -130,6 +144,7 @@ files:
|
|
|
130
144
|
- lib/fixture_kit/rspec.rb
|
|
131
145
|
- lib/fixture_kit/singleton.rb
|
|
132
146
|
- lib/fixture_kit/sql_capture.rb
|
|
147
|
+
- lib/fixture_kit/transactional_harness.rb
|
|
133
148
|
- lib/fixture_kit/version.rb
|
|
134
149
|
homepage: https://github.com/Gusto/fixture_kit
|
|
135
150
|
licenses:
|