fixtury 0.1.0.beta2 → 0.1.0.rc1
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/Gemfile.lock +1 -1
- data/lib/fixtury/locator.rb +6 -0
- data/lib/fixtury/schema.rb +1 -1
- data/lib/fixtury/store.rb +5 -5
- data/lib/fixtury/{hooks.rb → test_hooks.rb} +29 -2
- data/lib/fixtury/version.rb +1 -1
- 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: 57860e63181271b5c3f036cf9f10fa8a7cbab90fa5c2f3fb0e01cacc2a026c06
|
4
|
+
data.tar.gz: 1304df2a1825633dd3c31ac34a070839aca8d4aaf0b4f09738e2d24115f57602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93aa1dd2df814ec78ee09fbfa630d3c886e848913dad7acd31a060bfa7415fdf0ac620572d16fcc9a22944bee54bda38efbe2e21654a9309dd42f05f7bbb477b
|
7
|
+
data.tar.gz: 53d99202d931458e3bdacaf494bedd70f0ef57591cf9ff67fcc81862a9b625505bf5f7786085f926b4aca4939fe4a9e0d0767bf14d89f5e029de5978dc347357
|
data/Gemfile.lock
CHANGED
data/lib/fixtury/locator.rb
CHANGED
@@ -24,6 +24,12 @@ module Fixtury
|
|
24
24
|
@backend = backend
|
25
25
|
end
|
26
26
|
|
27
|
+
def recognize?(ref)
|
28
|
+
raise ArgumentError, "Unable to recognize a nil ref" if ref.nil?
|
29
|
+
|
30
|
+
backend.recognized_reference?(ref)
|
31
|
+
end
|
32
|
+
|
27
33
|
def load(ref)
|
28
34
|
raise ArgumentError, "Unable to load a nil ref" if ref.nil?
|
29
35
|
|
data/lib/fixtury/schema.rb
CHANGED
data/lib/fixtury/store.rb
CHANGED
@@ -53,7 +53,7 @@ module Fixtury
|
|
53
53
|
return unless ttl
|
54
54
|
|
55
55
|
references.delete_if do |name, ref|
|
56
|
-
is_expired =
|
56
|
+
is_expired = ref_invalid?(ref)
|
57
57
|
log { "expiring #{name}" } if is_expired
|
58
58
|
is_expired
|
59
59
|
end
|
@@ -108,7 +108,7 @@ module Fixtury
|
|
108
108
|
raise ::Fixtury::Errors::CircularDependencyError, full_name
|
109
109
|
end
|
110
110
|
|
111
|
-
if ref && auto_refresh_expired &&
|
111
|
+
if ref && auto_refresh_expired && ref_invalid?(ref)
|
112
112
|
log { "refreshing #{full_name}" }
|
113
113
|
clear_ref(full_name)
|
114
114
|
ref = nil
|
@@ -154,10 +154,10 @@ module Fixtury
|
|
154
154
|
references.delete(name)
|
155
155
|
end
|
156
156
|
|
157
|
-
def
|
158
|
-
return
|
157
|
+
def ref_invalid?(ref)
|
158
|
+
return true if ttl && ref.created_at < (Time.now.to_i - ttl)
|
159
159
|
|
160
|
-
|
160
|
+
!locator.recognize?(ref.value)
|
161
161
|
end
|
162
162
|
|
163
163
|
def log(local_verbose = false, &block)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "fixtury/store"
|
4
4
|
|
5
5
|
module Fixtury
|
6
|
-
module
|
6
|
+
module TestHooks
|
7
7
|
|
8
8
|
extend ::ActiveSupport::Concern
|
9
9
|
|
@@ -18,12 +18,39 @@ module Fixtury
|
|
18
18
|
self.fixtury_dependencies += names.flatten.compact.map(&:to_s)
|
19
19
|
end
|
20
20
|
|
21
|
+
def define_fixture(name, &block)
|
22
|
+
fixture_name = name
|
23
|
+
namespace_names = self.name.underscore.split("/")
|
24
|
+
|
25
|
+
ns = ::Fixtury.schema
|
26
|
+
|
27
|
+
namespace_names.each do |ns_name|
|
28
|
+
ns = ns.namespace(ns_name){}
|
29
|
+
end
|
30
|
+
|
31
|
+
ns.fixture(fixture_name, &block)
|
32
|
+
|
33
|
+
fixtury("#{namespace_names.join("/")}/#{fixture_name}")
|
34
|
+
end
|
35
|
+
|
21
36
|
end
|
22
37
|
|
23
38
|
def fixtury(name)
|
24
|
-
raise ArgumentError unless self.fixtury_dependencies.include?(name.to_s)
|
25
39
|
return nil unless ::Fixtury::Store.instance
|
26
40
|
|
41
|
+
name = name.to_s
|
42
|
+
|
43
|
+
unless name.include?("/")
|
44
|
+
local_name = "#{self.class.name.underscore}/#{name}"
|
45
|
+
if self.fixtury_dependencies.include?(local_name)
|
46
|
+
return ::Fixtury::Store.instance.get(local_name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
unless self.fixtury_dependencies.include?(name)
|
51
|
+
raise ArgumentError, "Unrecognized fixtury dependency `#{name}` for #{self.class}"
|
52
|
+
end
|
53
|
+
|
27
54
|
::Fixtury::Store.instance.get(name)
|
28
55
|
end
|
29
56
|
|
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: 0.1.0.
|
4
|
+
version: 0.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autotest
|
@@ -161,7 +161,6 @@ files:
|
|
161
161
|
- lib/fixtury/errors/schema_frozen_error.rb
|
162
162
|
- lib/fixtury/errors/unrecognizable_locator_error.rb
|
163
163
|
- lib/fixtury/execution_context.rb
|
164
|
-
- lib/fixtury/hooks.rb
|
165
164
|
- lib/fixtury/locator.rb
|
166
165
|
- lib/fixtury/locator_backend/common.rb
|
167
166
|
- lib/fixtury/locator_backend/globalid.rb
|
@@ -172,6 +171,7 @@ files:
|
|
172
171
|
- lib/fixtury/schema.rb
|
173
172
|
- lib/fixtury/store.rb
|
174
173
|
- lib/fixtury/tasks.rake
|
174
|
+
- lib/fixtury/test_hooks.rb
|
175
175
|
- lib/fixtury/version.rb
|
176
176
|
homepage: https://github.com/guideline-tech/fixtury
|
177
177
|
licenses: []
|