Fix FactoryGirl deprecation warning by upgrading to FactoryBot 5

This commit is contained in:
Tom Naessens 2019-05-30 21:08:46 +12:00
parent 051cd9a265
commit ac64fed6a8
11 changed files with 24 additions and 24 deletions

View file

@ -64,7 +64,7 @@ group :development, :test do
gem 'byebug' gem 'byebug'
# Yay tests # Yay tests
gem 'rspec-rails' gem 'rspec-rails'
gem 'factory_girl_rails' gem 'factory_bot_rails'
gem 'faker' gem 'faker'
gem 'listen' gem 'listen'
end end

View file

@ -112,11 +112,11 @@ GEM
erubi (1.7.1) erubi (1.7.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.7.0) execjs (2.7.0)
factory_girl (4.9.0) factory_bot (5.0.2)
activesupport (>= 3.0.0) activesupport (>= 4.2.0)
factory_girl_rails (4.9.0) factory_bot_rails (5.0.2)
factory_girl (~> 4.9.0) factory_bot (~> 5.0.2)
railties (>= 3.0.0) railties (>= 4.2.0)
faker (1.8.7) faker (1.8.7)
i18n (>= 0.7) i18n (>= 0.7)
faraday (0.12.2) faraday (0.12.2)
@ -359,7 +359,7 @@ DEPENDENCIES
coveralls coveralls
devise devise
ed25519 ed25519
factory_girl_rails factory_bot_rails
faker faker
friendly_id (~> 5.1.0) friendly_id (~> 5.1.0)
haml-rails haml-rails

View file

@ -1,16 +1,16 @@
unless Rails.env.production? unless Rails.env.production?
require 'factory_girl' require 'factory_bot'
require 'faker' require 'faker'
task :sow => :environment do task :sow => :environment do
users = FactoryGirl.create_list(:user, 20) users = FactoryBot.create_list(:user, 20)
100.times do 100.times do
sample_users = users.sample(2) sample_users = users.sample(2)
FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1] FactoryBot.create :transaction, debtor: sample_users[0], creditor: sample_users[1]
end end
clients = FactoryGirl.create_list(:client, 5) clients = FactoryBot.create_list(:client, 5)
100.times do 100.times do
debtor, creditor = users.sample(2) debtor, creditor = users.sample(2)
FactoryGirl.create :client_transaction, issuer: clients.sample, debtor: debtor, creditor: creditor FactoryBot.create :client_transaction, issuer: clients.sample, debtor: debtor, creditor: creditor
end end
end end
end end

View file

@ -1,6 +1,6 @@
FactoryGirl.define do FactoryBot.define do
factory :android_device_registration_token do factory :android_device_registration_token do
token "MyString" token { Faker::Lorem.word }
user nil association :user
end end
end end

View file

@ -9,7 +9,7 @@
# updated_at :datetime not null # updated_at :datetime not null
# #
FactoryGirl.define do FactoryBot.define do
factory :client do factory :client do
name { Faker::Lorem.word } name { Faker::Lorem.word }
end end

View file

@ -10,7 +10,7 @@
# updated_at :datetime not null # updated_at :datetime not null
# #
FactoryGirl.define do FactoryBot.define do
factory :notification do factory :notification do
end end

View file

@ -14,7 +14,7 @@
# updated_at :datetime not null # updated_at :datetime not null
# #
FactoryGirl.define do FactoryBot.define do
factory :request do factory :request do
end end

View file

@ -1,4 +1,4 @@
FactoryGirl.define do FactoryBot.define do
factory :role do factory :role do
end end

View file

@ -14,7 +14,7 @@
# id_at_client :integer # id_at_client :integer
# #
FactoryGirl.define do FactoryBot.define do
factory :transaction do factory :transaction do
association :debtor, factory: :user association :debtor, factory: :user
association :creditor, factory: :user association :creditor, factory: :user

View file

@ -10,12 +10,12 @@
# updated_at :datetime not null # updated_at :datetime not null
# #
FactoryGirl.define do FactoryBot.define do
factory :user do factory :user do
name { Faker::Internet.user_name } name { Faker::Internet.user_name }
factory :penning do factory :penning do
penning true penning { true }
end end
end end
end end

View file

@ -22,7 +22,7 @@ Coveralls.wear!('rails')
# users commonly want. # users commonly want.
# #
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'factory_girl' require 'factory_bot'
require 'devise' require 'devise'
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |f| Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |f|
@ -30,7 +30,7 @@ Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |f|
end end
RSpec.configure do |config| RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryBot::Syntax::Methods
config.include Devise::TestHelpers, type: :controller config.include Devise::TestHelpers, type: :controller
# rspec-expectations config goes here. You can use an alternate # rspec-expectations config goes here. You can use an alternate