From fffcd8db2cde5abd2a6ab8f689a11060f49ac66d Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 28 Apr 2019 01:25:13 +0300 Subject: [PATCH] FactoryGirl -> FactoryBot --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ config/application.rb | 2 +- spec/factories/call_for_participations.rb | 2 +- spec/factories/conferences.rb | 18 +++++++++--------- spec/factories/event_types.rb | 8 ++++---- spec/factories/events.rb | 4 ++-- spec/factories/halls.rb | 2 +- spec/factories/participations.rb | 4 ++-- spec/factories/personal_profile.rb | 18 +++++++++--------- spec/factories/propositions.rb | 2 +- spec/factories/slots.rb | 2 +- spec/factories/tracks.rb | 6 +++--- spec/factories/users.rb | 10 +++++----- spec/factories/volunteerships.rb | 7 +++---- spec/support/factory_bot.rb | 4 ++++ spec/support/factory_girl.rb | 4 ---- 17 files changed, 53 insertions(+), 54 deletions(-) create mode 100644 spec/support/factory_bot.rb delete mode 100644 spec/support/factory_girl.rb diff --git a/Gemfile b/Gemfile index cad20e0..f99b268 100644 --- a/Gemfile +++ b/Gemfile @@ -79,7 +79,7 @@ end group :development, :test do gem 'rspec-rails' - gem 'factory_girl_rails' + gem 'factory_bot_rails' gem 'faker' gem 'capybara' gem 'selenium-webdriver' diff --git a/Gemfile.lock b/Gemfile.lock index 65b55ca..643bac8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,11 +122,11 @@ GEM erubi (1.8.0) 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.9.3) i18n (>= 0.7) faraday (0.15.4) @@ -415,7 +415,7 @@ DEPENDENCIES delorean devise devise-i18n - factory_girl_rails + factory_bot_rails faker faraday font-awesome-sass (~> 4.6.2) diff --git a/config/application.rb b/config/application.rb index 90aca35..e128510 100644 --- a/config/application.rb +++ b/config/application.rb @@ -30,7 +30,7 @@ module Clarion routing_specs: false, request_specs: false - g.fixture_replacement :factory_girl, dir: 'spec/factories' + g.fixture_replacement :factory_bot, dir: 'spec/factories' end end end diff --git a/spec/factories/call_for_participations.rb b/spec/factories/call_for_participations.rb index 479ac0f..645198e 100644 --- a/spec/factories/call_for_participations.rb +++ b/spec/factories/call_for_participations.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :call_for_participation do end end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index cff6017..3d5288b 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -1,22 +1,22 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do factory :conference do sequence(:title) { |n| "Conference-#{n}" } email - description 'MyText' - start_date '2014-07-29 21:29:13' - end_date '2014-07-31 21:29:13' - planned_cfp_end_date '2014-07-28' + description { 'MyText' } + start_date { '2014-07-29 21:29:13' } + end_date { '2014-07-31 21:29:13' } + planned_cfp_end_date { '2014-07-28' } factory :past_conference do - start_date Date.today - 10.days - end_date Date.today - 5.days + start_date { Date.today - 10.days } + end_date { Date.today - 5.days } end factory :future_conference do - start_date Date.today + 5.days - end_date Date.today + 10.days + start_date { Date.today + 5.days } + end_date { Date.today + 10.days } end end end diff --git a/spec/factories/event_types.rb b/spec/factories/event_types.rb index 6f5f857..b3f3ba2 100644 --- a/spec/factories/event_types.rb +++ b/spec/factories/event_types.rb @@ -1,9 +1,9 @@ -FactoryGirl.define do +FactoryBot.define do factory :event_type do name { |n| "Track #{n}" } - description 'MyText' + description { 'MyText' } conference - minimum_length '45' - maximum_length '60' + minimum_length { '45' } + maximum_length { '60' } end end diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 60837cb..58eacf6 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -1,11 +1,11 @@ -FactoryGirl.define do +FactoryBot.define do factory :event do title { |n| "Event #{n}" } length { 60 } abstract { 'foo' } description { 'foo' } conference - language :bg + language { :bg } after(:build) do |event, evaluator| evaluator.conference.tracks << create(:track) event.track = evaluator.conference.tracks.first diff --git a/spec/factories/halls.rb b/spec/factories/halls.rb index 0e97cd3..23d9905 100644 --- a/spec/factories/halls.rb +++ b/spec/factories/halls.rb @@ -1,6 +1,6 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do factory :hall do name { |n| "Hall#{n}" } conference diff --git a/spec/factories/participations.rb b/spec/factories/participations.rb index 2b1cd25..e945f7b 100644 --- a/spec/factories/participations.rb +++ b/spec/factories/participations.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :participation do association :participant, factory: :user event - approved false + approved { false } end end diff --git a/spec/factories/personal_profile.rb b/spec/factories/personal_profile.rb index 10b66e8..8084392 100644 --- a/spec/factories/personal_profile.rb +++ b/spec/factories/personal_profile.rb @@ -1,14 +1,14 @@ -FactoryGirl.define do +FactoryBot.define do factory :personal_profile do - first_name 'Foo' - last_name 'Bar' - organisation 'foo inc.' - public_email 'foo@example.com' + first_name { 'Foo' } + last_name { 'Bar' } + organisation { 'foo inc.' } + public_email { 'foo@example.com' } picture { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support', 'picture.jpg')) } - mobile_phone '+359883444555' - biography 'Just a bio' - github 'foobar' - twitter 'foobar' + mobile_phone { '+359883444555' } + biography { 'Just a bio' } + github { 'foobar' } + twitter { 'foobar' } user conference end diff --git a/spec/factories/propositions.rb b/spec/factories/propositions.rb index c2b69aa..7819511 100644 --- a/spec/factories/propositions.rb +++ b/spec/factories/propositions.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :proposition do association :proposer, factory: :user association :proposable, factory: :event diff --git a/spec/factories/slots.rb b/spec/factories/slots.rb index eed6450..98f8df1 100644 --- a/spec/factories/slots.rb +++ b/spec/factories/slots.rb @@ -1,6 +1,6 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do factory :slot do starts_at { Time.now } ends_at { Time.now + 45.minutes } diff --git a/spec/factories/tracks.rb b/spec/factories/tracks.rb index c6b79d5..f91cf4f 100644 --- a/spec/factories/tracks.rb +++ b/spec/factories/tracks.rb @@ -1,10 +1,10 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do factory :track do name { |n| "Track#{n}" } - color '#000000' - description 'Some description' + color { '#000000' } + description { 'Some description' } conference end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index f2d225c..32299b4 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,16 +1,16 @@ # Read about factories at https://github.com/thoughtbot/factory_girl -FactoryGirl.define do +FactoryBot.define do sequence(:email) { |n| "user-#{n}@example.org" } factory :user do - password 'password' - password_confirmation 'password' - confirmed_at Time.now - 15.minutes + password { 'password' } + password_confirmation { 'password' } + confirmed_at { Time.now - 15.minutes } email factory :administrator do - admin true + admin { true } end end end diff --git a/spec/factories/volunteerships.rb b/spec/factories/volunteerships.rb index 7ef6f12..ad35d6c 100644 --- a/spec/factories/volunteerships.rb +++ b/spec/factories/volunteerships.rb @@ -1,7 +1,6 @@ -FactoryGirl.define do +FactoryBot.define do factory :volunteership do - volunteer_team nil -volunteer nil + volunteer_team { nil } + volunteer { nil } end - end diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb new file mode 100644 index 0000000..a69fcee --- /dev/null +++ b/spec/support/factory_bot.rb @@ -0,0 +1,4 @@ +RSpec.configure do |config| + # Include the FactoryBot methods + config.include FactoryBot::Syntax::Methods +end diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb deleted file mode 100644 index b69f2f7..0000000 --- a/spec/support/factory_girl.rb +++ /dev/null @@ -1,4 +0,0 @@ -RSpec.configure do |config| - # Include the FactoryGirl methods - config.include FactoryGirl::Syntax::Methods -end