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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8026933c72e6773550464325733bf9c31c7fc601c00aabcc6fa18dd384439d6
4
- data.tar.gz: a96c566602765f01a949814362022d687e5b06e794d1c09ecbef8dd5fd254a34
3
+ metadata.gz: 28d8d17251e3c566a77365c589274b5f28f6cfac17c3b126a0047e6b696368ec
4
+ data.tar.gz: 8dab12b727161634b90ed49e56a025bfe72aade50c90509ee08ebfd4faac2d17
5
5
  SHA512:
6
- metadata.gz: 7b95b7af4242c7e90f29f913be405a4a50163c66b8d363b2187ca04e4f71ff59b9cfdf88acbf6c4754c226321f8663c6d54b02472fe9c49342a49b9f98a1e2b2
7
- data.tar.gz: 7b78291b5980f5dc3a854e31f15668ee6765a7173869d68b09a19d8e58cc06e60240c293fa7984afd7271c3d31e8977d5d1e0d96cf71bfd018ada973fe3cf75f
6
+ metadata.gz: fb5841b70b7ae8cac95e6f8cc6a1c32c47d71f356c3be0275dc463f1d6c1b5f88447e51807d48632bdb68b425e7bc9ead3293519085cc9416d45a027cf1c7abc
7
+ data.tar.gz: 662570f9d0adcea15b6198eed3deb5fb4aab0639d206941687ea9a230f121ab7d1c82da895ac7c39e6459262ad3c3562cbfcfcb6d3ba7839a90a6380549776ba
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # Fixtury
2
2
 
3
- The goal of this library is to provide an interface for accessing fixture data on-demand rather than having to manage all resources up front. By centralizing and wrapping the definitions of data generation, we can preload and optimize how we load data, yet allow deferred behaviors when desired.
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
- For example, if a developer is running a test locally, there's no reason to build all fixtures for your suite.
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
- class MyTest < ::Test
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.
@@ -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
@@ -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 = name.underscore
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 += ["#{namespace}/#{fixture_name}"]
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
- unless name.include?("/")
75
- local_name = "#{self.class.name.underscore}/#{name}"
76
- if self.fixtury_dependencies.include?(local_name)
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fixtury
4
4
 
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
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.3.0
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-20 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autotest