Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 88aa5b8

Browse files
committedAug 18, 2021
DS-4969 Update data_works gem for Rails 5.2.6; Upgrade FactoryGirl to FactoryBot
1 parent afc5090 commit 88aa5b8

9 files changed

+33
-29
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.bundle
44
.config
55
.yardoc
6+
.ruby-gemset
67
Gemfile.lock
78
Guardfile
89
InstalledFiles

‎.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-2.6.5

‎README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DataWorks
22

3-
DataWorks makes it easier to work with FactoryGirl in the context of a complex
3+
DataWorks makes it easier to work with FactoryBot in the context of a complex
44
data model.
55

66
DataWorks has these benefits:
@@ -155,8 +155,8 @@ parent models.
155155
DataWorks solves this problem by following one simple rule: **by default, reuse
156156
objects that already exist.**
157157

158-
When using FactoryGirl, a factory only concerns itself with its particular
159-
neighborhood of the data model. Since FactoryGirl factories do not know
158+
When using FactoryBot, a factory only concerns itself with its particular
159+
neighborhood of the data model. Since FactoryBot factories do not know
160160
the big picture, their default is not to reuse existing objects but create
161161
new ones. This results in the proliferation of unwanted objects.
162162

@@ -166,9 +166,9 @@ reuse objects that already exist unless explicitly told otherwise.
166166

167167
### Implementation
168168

169-
DataWorks exists as a layer on top of FactoryGirl. DataWorks assumes that
170-
you have FactoryGirl factories for each model and that they create valid
171-
objects. DataWorks always uses a create strategy with FactoryGirl.
169+
DataWorks exists as a layer on top of FactoryBot. DataWorks assumes that
170+
you have FactoryBot factories for each model and that they create valid
171+
objects. DataWorks always uses a create strategy with FactoryBot.
172172

173173
### Benefits
174174

@@ -458,8 +458,8 @@ end
458458
```
459459

460460
`config.necessary_parents` is where you tell DataWorks which other factories
461-
must be created when you create a particular factory. Because FactoryGirl
462-
causes a proliferation of extra objects, DataWorks does not allow FactoryGirl
461+
must be created when you create a particular factory. Because FactoryBot
462+
causes a proliferation of extra objects, DataWorks does not allow FactoryBot
463463
to create necessary associated objects. Instead, DataWorks will create the
464464
necessary parent objects and pass them down into the factory, ensuring that
465465
too many parent objects do not get created.

‎data_works.gemspec

+15-13
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,29 @@ Gem::Specification.new do |s|
99
s.authors = ["Wyatt Greene", "Anne Geiersbach", "Dennis Chan", "Luke Inglis"]
1010
s.email = ["dev@dmgroupk12.com"]
1111
s.summary = %q{Reducing the complexity of testing complex data models }
12-
s.description = %q{DataWorks makes it easier to work with FactoryGirl in the context of a complex data model.}
12+
s.description = %q{DataWorks makes it easier to work with FactoryBot in the context of a complex data model.}
1313
s.homepage = 'https://github.com/dmcouncil/data_works'
1414
s.licenses = ["MIT", "Copyright (c) 2018 District Management Group"]
1515

1616
s.files = `git ls-files`.split("\n")
1717
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
1818
s.require_paths = ["lib"]
1919

20-
s.add_dependency "activerecord", "~> 4.1"
21-
s.add_dependency "activesupport", "~> 4.1"
22-
s.add_dependency 'factory_girl', '>= 3.0'
20+
# Most of the below must match the rails app
21+
22+
s.add_dependency 'activerecord', '5.2.6'
23+
s.add_dependency 'activesupport', '5.2.6'
24+
s.add_dependency 'factory_bot'
2325
s.add_dependency 'graphviz', '~> 0.1.0'
2426
s.add_dependency 'launchy', '~> 2.4'
2527

26-
s.add_development_dependency "bundler", "~> 1.9"
27-
s.add_development_dependency "rake"
28-
s.add_development_dependency "database_cleaner", "~> 1.4.0"
29-
s.add_development_dependency "rspec"
30-
s.add_development_dependency "sqlite3"
31-
s.add_development_dependency "pry"
32-
s.add_development_dependency "guard"
33-
s.add_development_dependency "guard-rspec"
34-
s.add_development_dependency "active_hash", "~> 1.5.0"
28+
s.add_development_dependency 'bundler'
29+
s.add_development_dependency 'rake'
30+
s.add_development_dependency 'database_cleaner'
31+
s.add_development_dependency 'rspec'
32+
s.add_development_dependency 'sqlite3'
33+
s.add_development_dependency 'pry'
34+
s.add_development_dependency 'guard'
35+
s.add_development_dependency 'guard-rspec'
36+
s.add_development_dependency 'active_hash'
3537
end

‎lib/data_works/grafter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(works, model_name, model_attrs)
1111

1212
def create_model_and_its_necessary_parents
1313
created_parents = @parent_creator.create_necessary_parents(parents_we_already_have)
14-
FactoryGirl.create(@model_name, @model_attrs.merge(created_parents))
14+
FactoryBot.create(@model_name, @model_attrs.merge(created_parents))
1515
end
1616

1717
private

‎lib/data_works/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module DataWorks
2-
VERSION = "0.1.2"
2+
VERSION = "0.1.3"
33
end
44

‎spec/factories/factories.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require_relative '../lib/data_faker'
22

3-
FactoryGirl.define do
3+
FactoryBot.define do
44
factory :pet do
55
name { fake_string }
66
kind { animal_types.sample }
77
birth_year { (1914..2014).to_a.sample }
88

99
trait :bird do
10-
kind 'Bird'
10+
kind { 'Bird' }
1111
end
1212

1313
factory :pet_bird, traits: [:bird]
@@ -47,11 +47,11 @@
4747
name { "#{%w(Fluffy Rubber Squeeky).sample} #{%w(Ball Stick Shoe Book).sample}" }
4848

4949
trait :hooman do
50-
kind 'Robot Vacuum' # you know the one
50+
kind { 'Robot Vacuum' } # you know the one
5151
end
5252

5353
trait :bell do
54-
kind 'Bell'
54+
kind { 'Bell' }
5555
end
5656

5757
factory :hooman_toy, traits: [:hooman]

‎spec/helper/data_works_spec_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ class TheDataWorks < DataWorks::Base
4242
end
4343

4444
RSpec.configure do |config|
45-
config.include FactoryGirl::Syntax::Methods
45+
config.include FactoryBot::Syntax::Methods
4646
end

‎spec/spec_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
22
require 'active_support/all'
33
require 'active_support/testing/time_helpers'
4-
require 'factory_girl'
4+
require 'factory_bot'
55
require 'database_cleaner'
66
require 'active_hash'
77
require 'sqlite3'

0 commit comments

Comments
 (0)
Please sign in to comment.