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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d64454e8c58e2b7f40bb5472cf74f235b2e491c2b68aaf1fce3f5ee93c81b54a
4
- data.tar.gz: ef4f788ddac8b52519fa17b12fb5ea81ed775aa6cf2dca62d9c1e27afbfbef67
3
+ metadata.gz: c28666bc10b8c566588537fd66c1dbb6da80fceec2d7daed97ebdfce7812feb2
4
+ data.tar.gz: 06fd411376ef9b383be790d9295c235f01b5c701a16e57bcf2122154572574d0
5
5
  SHA512:
6
- metadata.gz: f870dc3314015951864733fc07e81019d9cff2ab5fd29134e34b6fdf2ba2cd75a77e053b132a087b29870e6c35f7b1564c007953ddab71218d1984e8d3ead92d
7
- data.tar.gz: 1d61cef6041938674909b6741df6b47acb8b47b123d0a6630efc311cc13f1a5475c2ecac0faf191711a50d4011eed8044cd2be49202ca2598ec908b1a318c9ee
6
+ metadata.gz: d43388b3b1747bd21b08e175b799fb74347153d1a7492e9ebfc6a8fe44cf1512b5879c5b935924a43bb56ffff5eb5ee0bc808429ad9e23871317da1beb41005f
7
+ data.tar.gz: 59333bea58922000db4ae9e65b97bed6231d3c23ebf4b2095c1c510b9dc5c640a96a9673b849cdcc46aa9e2d59905ea03464366b14593fbdd36e31ba3a6d90af
@@ -10,6 +10,7 @@ module FactoryBot
10
10
  require "factory_bot/preload/extension"
11
11
 
12
12
  ActiveSupport.on_load(:after_initialize) do
13
+ ::FactoryBot::Preload::Helpers.load_models
13
14
  ::FactoryBot::SyntaxRunner.include ::FactoryBot::Preload::Helpers
14
15
  end
15
16
 
@@ -3,17 +3,15 @@ module FactoryBot
3
3
  module Helpers
4
4
  include ::FactoryBot::Syntax::Methods
5
5
 
6
- def self.extended(base)
7
- included(base)
8
- end
6
+ def self.load_models
7
+ return unless defined?(Rails)
9
8
 
10
- def self.included(_base)
11
- if defined?(Rails)
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)
@@ -3,7 +3,7 @@ module FactoryBot
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
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.0
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-12 00:00:00.000000000 Z
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.1
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