fixtury 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/fixtury.rb +3 -0
- data/lib/fixtury/test_hooks.rb +9 -7
- data/lib/fixtury/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d8d17251e3c566a77365c589274b5f28f6cfac17c3b126a0047e6b696368ec
|
4
|
+
data.tar.gz: 8dab12b727161634b90ed49e56a025bfe72aade50c90509ee08ebfd4faac2d17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5841b70b7ae8cac95e6f8cc6a1c32c47d71f356c3be0275dc463f1d6c1b5f88447e51807d48632bdb68b425e7bc9ead3293519085cc9416d45a027cf1c7abc
|
7
|
+
data.tar.gz: 662570f9d0adcea15b6198eed3deb5fb4aab0639d206941687ea9a230f121ab7d1c82da895ac7c39e6459262ad3c3562cbfcfcb6d3ba7839a90a6380549776ba
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# Fixtury
|
2
2
|
|
3
|
-
|
3
|
+
Fixtury aims to provide an interface for creating, managing, and accessing test data in a simple and efficient way. It has no opinion on how you generate the data, it simply provides efficient ways to access it.
|
4
4
|
|
5
|
-
|
5
|
+
Often, fixture frameworks require you to either heavily maintain static fixtures or generate all your fixtures at runtime. Fixtury attempts to find a middle ground that enables a faster and more effecient development process.
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
For example, if a developer is running a test locally in their development environment there's no reason to build all fixtures for your suite of 30k tests. Instead, if we're able to track the fixture dependencies of the tests that are running we can build (and cache) the data relevant for the specific tests that are run.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
class MyTest < ::ActiveSupport::TestCase
|
11
|
+
include ::Fixtury::TestHooks
|
9
12
|
|
10
13
|
fixtury "users.fresh"
|
11
14
|
let(:user) { fixtury("users.fresh") }
|
@@ -15,7 +18,6 @@ class MyTest < ::Test
|
|
15
18
|
end
|
16
19
|
|
17
20
|
end
|
18
|
-
|
19
21
|
```
|
20
22
|
|
21
23
|
Loading this file would ensure `users.fresh` is loaded into the fixture set before the suite is run. In the context of ActiveSupport::TestCase, the Fixtury::Hooks file will ensure the database records are present prior to your suite running. Setting `use_transactional_fixtures` ensures all records are rolled back prior to running another test.
|
data/lib/fixtury.rb
CHANGED
@@ -10,11 +10,14 @@ require "fixtury/store"
|
|
10
10
|
|
11
11
|
module Fixtury
|
12
12
|
|
13
|
+
# Shortcut for opening the top level schema.
|
13
14
|
def self.define(&block)
|
14
15
|
schema.define(&block)
|
15
16
|
schema
|
16
17
|
end
|
17
18
|
|
19
|
+
# The default top level schema. Fixtury::Schema instances can be completely self-contained but most
|
20
|
+
# usage would be through this shared definition.
|
18
21
|
def self.schema
|
19
22
|
@top_level_schema ||= ::Fixtury::Schema.new(parent: nil, name: "")
|
20
23
|
end
|
data/lib/fixtury/test_hooks.rb
CHANGED
@@ -22,7 +22,7 @@ module Fixtury
|
|
22
22
|
if block_given?
|
23
23
|
raise ArgumentError, "A fixture cannot be defined in an anonymous class" if name.nil?
|
24
24
|
|
25
|
-
namespace =
|
25
|
+
namespace = fixtury_namespace
|
26
26
|
|
27
27
|
ns = ::Fixtury.schema
|
28
28
|
|
@@ -32,7 +32,7 @@ module Fixtury
|
|
32
32
|
|
33
33
|
names.each do |fixture_name|
|
34
34
|
ns.fixture(fixture_name, &definition)
|
35
|
-
self.fixtury_dependencies += ["
|
35
|
+
self.fixtury_dependencies += ["/#{namespace}/#{fixture_name}"]
|
36
36
|
end
|
37
37
|
|
38
38
|
# otherwise, just record the dependency
|
@@ -64,6 +64,10 @@ module Fixtury
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def fixtury_namespace
|
68
|
+
name.underscore
|
69
|
+
end
|
70
|
+
|
67
71
|
end
|
68
72
|
|
69
73
|
def fixtury(name)
|
@@ -71,11 +75,9 @@ module Fixtury
|
|
71
75
|
|
72
76
|
name = name.to_s
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
return fixtury_store.get(local_name, execution_context: self)
|
78
|
-
end
|
78
|
+
local_alias = "/#{self.class.fixtury_namespace}/#{name}"
|
79
|
+
if self.fixtury_dependencies.include?(local_alias)
|
80
|
+
return fixtury_store.get(local_alias, execution_context: self)
|
79
81
|
end
|
80
82
|
|
81
83
|
unless self.fixtury_dependencies.include?(name)
|
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.3.
|
4
|
+
version: 0.3.1
|
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-10-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: autotest
|