factory_bot-preload 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/factory_bot/preload.rb +1 -0
- data/lib/factory_bot/preload/helpers.rb +10 -8
- data/lib/factory_bot/preload/version.rb +1 -1
- metadata +5 -4
- data/lib/factory_bot/preload/engine.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c28666bc10b8c566588537fd66c1dbb6da80fceec2d7daed97ebdfce7812feb2
|
4
|
+
data.tar.gz: 06fd411376ef9b383be790d9295c235f01b5c701a16e57bcf2122154572574d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d43388b3b1747bd21b08e175b799fb74347153d1a7492e9ebfc6a8fe44cf1512b5879c5b935924a43bb56ffff5eb5ee0bc808429ad9e23871317da1beb41005f
|
7
|
+
data.tar.gz: 59333bea58922000db4ae9e65b97bed6231d3c23ebf4b2095c1c510b9dc5c640a96a9673b849cdcc46aa9e2d59905ea03464366b14593fbdd36e31ba3a6d90af
|
data/lib/factory_bot/preload.rb
CHANGED
@@ -3,17 +3,15 @@ module FactoryBot
|
|
3
3
|
module Helpers
|
4
4
|
include ::FactoryBot::Syntax::Methods
|
5
5
|
|
6
|
-
def self.
|
7
|
-
|
8
|
-
end
|
6
|
+
def self.load_models
|
7
|
+
return unless defined?(Rails)
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
Dir[Rails.application.root.join("app/models/**/*.rb")].each do |file|
|
13
|
-
require_dependency file
|
14
|
-
end
|
9
|
+
Dir[Rails.application.root.join("app/models/**/*.rb")].each do |file|
|
10
|
+
require_dependency file
|
15
11
|
end
|
12
|
+
end
|
16
13
|
|
14
|
+
def self.define_helper_methods
|
17
15
|
ActiveRecord::Base.descendants.each do |model|
|
18
16
|
method_name = model.name.underscore.tr("/", "_").pluralize
|
19
17
|
|
@@ -23,6 +21,10 @@ module FactoryBot
|
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
24
|
+
def self.included(_base)
|
25
|
+
FactoryBot::Preload::Helpers.define_helper_methods
|
26
|
+
end
|
27
|
+
|
26
28
|
def factory(name, model = nil, &block)
|
27
29
|
if block_given?
|
28
30
|
factory_set(name, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_bot-preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -152,7 +152,6 @@ files:
|
|
152
152
|
- factory_bot-preload.gemspec
|
153
153
|
- lib/factory_bot-preload.rb
|
154
154
|
- lib/factory_bot/preload.rb
|
155
|
-
- lib/factory_bot/preload/engine.rb
|
156
155
|
- lib/factory_bot/preload/extension.rb
|
157
156
|
- lib/factory_bot/preload/helpers.rb
|
158
157
|
- lib/factory_bot/preload/minitest.rb
|
@@ -165,6 +164,7 @@ files:
|
|
165
164
|
- spec/support/app/app/models/skill.rb
|
166
165
|
- spec/support/app/app/models/user.rb
|
167
166
|
- spec/support/app/db/schema.rb
|
167
|
+
- spec/support/app/tmp/.keep
|
168
168
|
- spec/support/factories.rb
|
169
169
|
- test/factory_bot/preload_test.rb
|
170
170
|
- test/test_helper.rb
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.0.
|
189
|
+
rubygems_version: 3.0.3
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Preload factories (Factory Bot) just like fixtures. It will be easy and,
|
@@ -199,6 +199,7 @@ test_files:
|
|
199
199
|
- spec/support/app/app/models/skill.rb
|
200
200
|
- spec/support/app/app/models/user.rb
|
201
201
|
- spec/support/app/db/schema.rb
|
202
|
+
- spec/support/app/tmp/.keep
|
202
203
|
- spec/support/factories.rb
|
203
204
|
- test/factory_bot/preload_test.rb
|
204
205
|
- test/test_helper.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rails/engine"
|
2
|
-
|
3
|
-
module FactoryBot
|
4
|
-
module Preload
|
5
|
-
class Engine < Rails::Engine
|
6
|
-
ActiveSupport.on_load(:after_initialize, yield: true) do
|
7
|
-
::FactoryBot::SyntaxRunner.send(:include, Helpers)
|
8
|
-
end
|
9
|
-
|
10
|
-
initializer "factory_bot-preload" do
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|