fixtury 0.1.0.beta2 → 0.1.0.rc1

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: ac77ba24e99d487806a96c58c7b5dd9c1c29e785976b41813622afb71a39448d
4
- data.tar.gz: f5ecbc8dd03ba11b7634014ebab0d565c743d038b45b439971f14d7a062f1984
3
+ metadata.gz: 57860e63181271b5c3f036cf9f10fa8a7cbab90fa5c2f3fb0e01cacc2a026c06
4
+ data.tar.gz: 1304df2a1825633dd3c31ac34a070839aca8d4aaf0b4f09738e2d24115f57602
5
5
  SHA512:
6
- metadata.gz: 51cd55345dd84189bfcdb84142a97352873f7dbc2ed35672b26e5c06a42b5f09b42ffb8664a2f1a95eb48c7c73762d5090bb88819f175fab79e56e46e45abf42
7
- data.tar.gz: 1766220dca1b16385d59d3c4de48ea8e378fa3faa994da7f65e986fb596d37795a3b3c8215ba8485eddbd9c3d77cae65e339633a362d0bda7c7c1cb480b4c455
6
+ metadata.gz: 93aa1dd2df814ec78ee09fbfa630d3c886e848913dad7acd31a060bfa7415fdf0ac620572d16fcc9a22944bee54bda38efbe2e21654a9309dd42f05f7bbb477b
7
+ data.tar.gz: 53d99202d931458e3bdacaf494bedd70f0ef57591cf9ff67fcc81862a9b625505bf5f7786085f926b4aca4939fe4a9e0d0767bf14d89f5e029de5978dc347357
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fixtury (0.1.0.alpha2)
4
+ fixtury (0.1.0.beta2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
 
@@ -67,7 +67,7 @@ module Fixtury
67
67
  ensure_no_conflict!(name: name, definitions: true, namespaces: false)
68
68
 
69
69
  child = find_or_create_child_schema(name: name)
70
- child.instance_eval(&block)
70
+ child.instance_eval(&block) if block_given?
71
71
  child
72
72
  end
73
73
 
@@ -53,7 +53,7 @@ module Fixtury
53
53
  return unless ttl
54
54
 
55
55
  references.delete_if do |name, ref|
56
- is_expired = ref_expired?(ref)
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 && ref_expired?(ref)
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 ref_expired?(ref)
158
- return false unless ttl
157
+ def ref_invalid?(ref)
158
+ return true if ttl && ref.created_at < (Time.now.to_i - ttl)
159
159
 
160
- ref.created_at < (Time.now.to_i - ttl)
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 Hooks
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fixtury
4
4
 
5
- VERSION = "0.1.0.beta2"
5
+ VERSION = "0.1.0.rc1"
6
6
 
7
7
  end
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.beta2
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-08 00:00:00.000000000 Z
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: []