fixtury 1.0.0.beta6 → 1.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 +24 -0
- data/.github/workflows/build.yml +23 -0
- data/Gemfile.lock +7 -7
- data/lib/fixtury/definition_executor.rb +29 -6
- data/lib/fixtury/minitest_hooks.rb +2 -1
- data/lib/fixtury/reference.rb +4 -3
- data/lib/fixtury/store.rb +4 -2
- data/lib/fixtury/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dad3194d36ce43bfc6331ae5f8ed37abbf7509496f8b6d6344313f9512f22f8
|
4
|
+
data.tar.gz: d0c0324b038362cda1f2f12ad100fef087edb931c2aeb417d6ea04e0292aa4fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7a86120bf86a3cddc62c1d36294683fe2cd280d7aa8fa2e05af1d4b81f5c9fe99e7f5086b5028173c3d580c15b50665591f8377d153a098030ca317bfab839c
|
7
|
+
data.tar.gz: d8a18793cee0e6f4172e3d64826fd218c028e0b3ad1a9c33496877e5c5841cefd4741adf55bdf7ea119074822e0ea0f7c87134f565147ab71ffd82b09f2cf667
|
@@ -0,0 +1,24 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: "github-actions"
|
4
|
+
directory: "/"
|
5
|
+
open-pull-requests-limit: 20
|
6
|
+
schedule:
|
7
|
+
interval: "daily"
|
8
|
+
time: "09:00"
|
9
|
+
timezone: "America/New_York"
|
10
|
+
commit-message:
|
11
|
+
prefix: "[github-actions] "
|
12
|
+
- package-ecosystem: "bundler"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
16
|
+
time: "08:30"
|
17
|
+
timezone: "America/New_York"
|
18
|
+
allow:
|
19
|
+
- dependency-type: "all"
|
20
|
+
versioning-strategy: increase
|
21
|
+
open-pull-requests-limit: 20
|
22
|
+
insecure-external-code-execution: deny
|
23
|
+
commit-message:
|
24
|
+
prefix: "[bundler] "
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: build
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby-version: [3.2.2]
|
14
|
+
experimental: [false]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v4
|
17
|
+
with:
|
18
|
+
show-progress: 'false'
|
19
|
+
- uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
22
|
+
bundler-cache: true # runs `bundle install` and caches installed gems automatically
|
23
|
+
- run: bundle exec rake
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fixtury (1.0.0
|
4
|
+
fixtury (1.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
mutex_m
|
24
24
|
tzinfo (~> 2.0)
|
25
25
|
base64 (0.2.0)
|
26
|
-
bigdecimal (3.1.
|
26
|
+
bigdecimal (3.1.7)
|
27
27
|
byebug (11.1.3)
|
28
28
|
concurrent-ruby (1.2.3)
|
29
29
|
connection_pool (2.4.1)
|
@@ -35,13 +35,13 @@ GEM
|
|
35
35
|
m (1.6.2)
|
36
36
|
method_source (>= 0.6.7)
|
37
37
|
rake (>= 0.9.2.2)
|
38
|
-
method_source (1.
|
39
|
-
mini_portile2 (2.8.
|
40
|
-
minitest (5.22.
|
41
|
-
mocha (2.
|
38
|
+
method_source (1.1.0)
|
39
|
+
mini_portile2 (2.8.6)
|
40
|
+
minitest (5.22.3)
|
41
|
+
mocha (2.2.0)
|
42
42
|
ruby2_keywords (>= 0.0.5)
|
43
43
|
mutex_m (0.2.0)
|
44
|
-
rake (13.1
|
44
|
+
rake (13.2.1)
|
45
45
|
ruby2_keywords (0.0.5)
|
46
46
|
sqlite3 (1.7.2)
|
47
47
|
mini_portile2 (~> 2.8.0)
|
@@ -1,20 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "benchmark"
|
4
|
+
|
3
5
|
module Fixtury
|
4
6
|
# A container that manages the execution of a definition in the context of a store.
|
5
7
|
class DefinitionExecutor
|
6
8
|
|
7
|
-
|
9
|
+
class Output
|
10
|
+
|
11
|
+
attr_accessor :value, :metadata
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@value = nil
|
15
|
+
@metadata = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :output, :definition, :store
|
8
21
|
|
9
22
|
def initialize(store: nil, definition:)
|
10
23
|
@store = store
|
11
24
|
@definition = definition
|
12
|
-
@
|
25
|
+
@output = Output.new
|
13
26
|
end
|
14
27
|
|
15
28
|
def call
|
16
29
|
run_definition
|
17
|
-
|
30
|
+
output
|
18
31
|
end
|
19
32
|
|
20
33
|
private
|
@@ -25,13 +38,13 @@ module Fixtury
|
|
25
38
|
def run_definition
|
26
39
|
callable = definition.callable
|
27
40
|
|
28
|
-
|
41
|
+
if callable.arity.positive?
|
29
42
|
deps = build_dependency_store
|
30
|
-
|
43
|
+
around_execution do
|
31
44
|
instance_exec(deps, &callable)
|
32
45
|
end
|
33
46
|
else
|
34
|
-
|
47
|
+
around_execution do
|
35
48
|
instance_eval(&callable)
|
36
49
|
end
|
37
50
|
end
|
@@ -41,6 +54,16 @@ module Fixtury
|
|
41
54
|
raise Errors::DefinitionExecutionError.new(definition.pathname, e)
|
42
55
|
end
|
43
56
|
|
57
|
+
def around_execution(&block)
|
58
|
+
measure_timing do
|
59
|
+
@output.value = ::Fixtury.hooks.call(:execution, self, &block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def measure_timing(&block)
|
64
|
+
@output.metadata[:duration] = Benchmark.realtime(&block)
|
65
|
+
end
|
66
|
+
|
44
67
|
def build_dependency_store
|
45
68
|
DependencyStore.new(definition: definition, store: store)
|
46
69
|
end
|
@@ -144,7 +144,8 @@ module Fixtury
|
|
144
144
|
def fixtury_database_connections
|
145
145
|
return [] unless defined?(ActiveRecord::Base)
|
146
146
|
|
147
|
-
ActiveRecord::Base.connection_handler.connection_pool_list(:writing)
|
147
|
+
pools = ActiveRecord::Base.connection_handler.connection_pool_list(:writing)
|
148
|
+
pools.map { |pool| pool.respond_to?(:lease_connection) ? pool.lease_connection : pool.connection }
|
148
149
|
end
|
149
150
|
|
150
151
|
# Load all dependenct fixtures and begin a transaction for each database connection.
|
data/lib/fixtury/reference.rb
CHANGED
@@ -15,13 +15,14 @@ module Fixtury
|
|
15
15
|
new(name, HOLDER_KEY)
|
16
16
|
end
|
17
17
|
|
18
|
-
attr_reader :name, :locator_key, :created_at, :
|
18
|
+
attr_reader :name, :locator_key, :created_at, :metadata
|
19
|
+
alias options metadata # backwards compatibility
|
19
20
|
|
20
|
-
def initialize(name, locator_key, **
|
21
|
+
def initialize(name, locator_key, **metadata)
|
21
22
|
@name = name
|
22
23
|
@locator_key = locator_key
|
23
24
|
@created_at = Time.now.to_i
|
24
|
-
@
|
25
|
+
@metadata = metadata
|
25
26
|
end
|
26
27
|
|
27
28
|
def holder?
|
data/lib/fixtury/store.rb
CHANGED
@@ -159,7 +159,8 @@ module Fixtury
|
|
159
159
|
|
160
160
|
begin
|
161
161
|
executor = ::Fixtury::DefinitionExecutor.new(store: self, definition: dfn)
|
162
|
-
|
162
|
+
output = executor.call
|
163
|
+
value = output.value
|
163
164
|
rescue StandardError
|
164
165
|
clear_reference(pathname)
|
165
166
|
raise
|
@@ -167,8 +168,9 @@ module Fixtury
|
|
167
168
|
|
168
169
|
log("store #{pathname}", level: LOG_LEVEL_DEBUG)
|
169
170
|
|
170
|
-
locator_key = locator.dump(value, context: pathname)
|
171
|
+
locator_key = locator.dump(output.value, context: pathname)
|
171
172
|
reference_opts = {}
|
173
|
+
reference_opts.merge!(output.metadata)
|
172
174
|
reference_opts[:isolation_key] = isokey unless isokey == pathname
|
173
175
|
references[pathname] = ::Fixtury::Reference.new(
|
174
176
|
pathname,
|
data/lib/fixtury/version.rb
CHANGED
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: 1.0.0
|
4
|
+
version: 1.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: 2024-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -143,6 +143,8 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
+
- ".github/dependabot.yml"
|
147
|
+
- ".github/workflows/build.yml"
|
146
148
|
- ".gitignore"
|
147
149
|
- ".ruby-version"
|
148
150
|
- ".travis.yml"
|
@@ -196,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
198
|
- !ruby/object:Gem::Version
|
197
199
|
version: '0'
|
198
200
|
requirements: []
|
199
|
-
rubygems_version: 3.5.
|
201
|
+
rubygems_version: 3.5.15
|
200
202
|
signing_key:
|
201
203
|
specification_version: 4
|
202
204
|
summary: Treat fixtures like factories and factories like fixtures
|