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'
# Yay tests
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'factory_bot_rails'
gem 'faker'
gem 'listen'
end

View file

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

View file

@ -1,16 +1,16 @@
unless Rails.env.production?
require 'factory_girl'
require 'factory_bot'
require 'faker'
task :sow => :environment do
users = FactoryGirl.create_list(:user, 20)
users = FactoryBot.create_list(:user, 20)
100.times do
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
clients = FactoryGirl.create_list(:client, 5)
clients = FactoryBot.create_list(:client, 5)
100.times do
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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -22,7 +22,7 @@ Coveralls.wear!('rails')
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'factory_girl'
require 'factory_bot'
require 'devise'
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
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include FactoryBot::Syntax::Methods
config.include Devise::TestHelpers, type: :controller
# rspec-expectations config goes here. You can use an alternate