Skip to content

Commit

Permalink
chore(): replace factory girl with factory bot
Browse files Browse the repository at this point in the history
  • Loading branch information
ldlsegovia committed Mar 12, 2018
1 parent 7c2a4b1 commit df9a4a2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

### 1.5.0

##### Changed

* Replace FactoryGirl with FactoryBot.

### 1.4.0

##### Added
Expand Down
23 changes: 9 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
human_attributes (0.4.0)
factory_girl_rails (~> 4.6)
factory_bot
rails (~> 4.2, >= 4.2.0)

GEM
Expand Down Expand Up @@ -62,15 +62,12 @@ GEM
enumerize (1.1.1)
activesupport (>= 3.2)
erubis (2.7.0)
factory_girl (4.8.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
ffi (1.9.18)
formatador (0.2.5)
globalid (0.3.7)
activesupport (>= 4.1.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
guard (2.14.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
Expand All @@ -94,12 +91,10 @@ GEM
loofah (2.0.3)
nokogiri (>= 1.5.9)
lumberjack (1.0.11)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0)
mini_portile2 (2.1.0)
minitest (5.10.1)
nenv (0.3.0)
Expand Down Expand Up @@ -178,7 +173,7 @@ GEM
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
Expand Down Expand Up @@ -206,4 +201,4 @@ DEPENDENCIES
sqlite3

BUNDLED WITH
1.14.6
1.16.1
2 changes: 1 addition & 1 deletion human_attributes.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.test_files = Dir["spec/**/*"]

s.add_dependency "rails", "~> 4.2", ">= 4.2.0"
s.add_dependency "factory_girl_rails", "~> 4.6"
s.add_dependency "factory_bot"
s.add_development_dependency "enumerize", "~> 1", ">= 1.1.1"
s.add_development_dependency "draper", "~> 2.1.0"
s.add_development_dependency "pry"
Expand Down
2 changes: 1 addition & 1 deletion lib/human_attributes/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Engine < ::Rails::Engine

config.generators do |g|
g.test_framework :rspec, fixture: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
g.fixture_replacement :factory_bot, dir: "spec/factories"
end

initializer "initialize" do
Expand Down
6 changes: 4 additions & 2 deletions lib/tasks/human_attributes_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
require "factory_girl_rails"
require "factory_bot"

namespace :human_attrs do
desc "Show generated human attributes for ActiveRecord models"
task :show, [:model] => [:environment] do |_t, args|
FactoryBot.reload
model_name = args[:model].tableize.singularize
model = args[:model].classify.constantize

instance = begin
FactoryGirl.build(model_name)
FactoryBot.build(model_name)
rescue
nil
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/spec/factories/purchases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# updated_at :datetime not null
#

FactoryGirl.define do
FactoryBot.define do
factory :purchase do
paid true
commission 1000.99
Expand Down
8 changes: 4 additions & 4 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
require "pry"
require "spec_helper"
require "rspec/rails"
require "factory_girl_rails"
require "factory_bot"

ActiveRecord::Migration.maintain_test_schema!

Expand All @@ -39,10 +39,10 @@
config.filter_run :focus
config.run_all_when_everything_filtered = true

FactoryGirl.definition_file_paths = ["#{::Rails.root}/spec/factories"]
FactoryGirl.find_definitions
FactoryBot.definition_file_paths = ["#{::Rails.root}/spec/factories"]
FactoryBot.find_definitions

config.include FactoryGirl::Syntax::Methods
config.include FactoryBot::Syntax::Methods
config.include ActionDispatch::TestProcess
config.include TestHelpers
end

0 comments on commit df9a4a2

Please sign in to comment.