diff --git a/Gemfile b/Gemfile index bc93ee36..9616c18d 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,7 @@ end group :test, :development do gem 'rspec-rails', '~> 3.3' - gem 'factory_girl_rails','~> 4.2' + gem 'factory_bot_rails', '~> 4.8' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index f9e2a83c..efe9289b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,10 +103,10 @@ GEM actionmailer (>= 3.0.4) activesupport (>= 3.0.4) execjs (2.7.0) - factory_girl (4.9.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) + factory_bot_rails (4.8.2) + factory_bot (~> 4.8.2) railties (>= 3.0.0) faraday (0.12.2) multipart-post (>= 1.2, < 3) @@ -337,7 +337,7 @@ DEPENDENCIES dotenv-rails draper (~> 3.0.0.pre1) exception_notification (~> 4.0.1) - factory_girl_rails (~> 4.2) + factory_bot_rails (~> 4.8) foreman haml-rails jbuilder (~> 2.5) diff --git a/spec/decorators/activity_decorator_spec.rb b/spec/decorators/activity_decorator_spec.rb index 5ec67c91..974c34c8 100644 --- a/spec/decorators/activity_decorator_spec.rb +++ b/spec/decorators/activity_decorator_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe ActivityDecorator do - let (:activity) { FactoryGirl.build_stubbed(:activity, limit_of_participants: 20) } + let (:activity) { build_stubbed(:activity, limit_of_participants: 20) } let (:decorator) { ActivityDecorator.new(activity) } describe "#spots_left" do diff --git a/spec/factories/activities.rb b/spec/factories/activities.rb index 3730448d..4da8d21a 100644 --- a/spec/factories/activities.rb +++ b/spec/factories/activities.rb @@ -1,13 +1,13 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :activity do name "Party!" start_time "2013/12/12 18:00" end_time "2013/12/13 03:00" anytime false location "Ballroom" - creator { FactoryGirl.create(:user) } + creator { FactoryBot.create(:user) } event { Event.new("Some Conference", Time.parse("2013/12/10 18:00"), Time.parse("2013/12/18 18:00")) } end end diff --git a/spec/factories/authentications.rb b/spec/factories/authentications.rb index 023ada09..7cac1bb5 100644 --- a/spec/factories/authentications.rb +++ b/spec/factories/authentications.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :authentication do uid { generate(:uid) } provider "Provider" diff --git a/spec/factories/participations.rb b/spec/factories/participations.rb index a4c17b74..481b5871 100644 --- a/spec/factories/participations.rb +++ b/spec/factories/participations.rb @@ -1,8 +1,8 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :participation do - participant{ FactoryGirl.create(:user) } + participant{ FactoryBot.create(:user) } activity end end diff --git a/spec/factories/sequences.rb b/spec/factories/sequences.rb index 6e19e88a..087e8d9a 100644 --- a/spec/factories/sequences.rb +++ b/spec/factories/sequences.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:email) { |n| "person#{n}@example.com" } sequence(:uid) { |n| "uid#{n}" } end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 8f488ca6..6199dd2d 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,6 +1,6 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl +# Read about factories at https://github.com/thoughtbot/factory_bot -FactoryGirl.define do +FactoryBot.define do factory :user do email { generate(:email) } password "qweqweqwe" diff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rb index 5f74004f..d12a4703 100644 --- a/spec/models/activity_spec.rb +++ b/spec/models/activity_spec.rb @@ -248,14 +248,14 @@ it { is_expected.not_to accept_values_for(:image_url, "http://com.co ge.gif", "ssh://com.com/image.gif", "blah")} context "invalid time frame (wrong order)" do - subject { FactoryGirl.build(:activity, start_time: 10.days.ago.to_time, anytime: false) } + subject { build(:activity, start_time: 10.days.ago.to_time, anytime: false) } it { is_expected.not_to accept_values_for(:end_time, 15.days.ago.to_time) } end context "invalid time frame (out of scope)" do let(:event) { Event.new("A name", 2.days.ago.to_time, 2.days.from_now.to_time ) } - subject { FactoryGirl.build(:activity, event: event, start_time: 10.days.ago.to_time, anytime: false) } + subject { build(:activity, event: event, start_time: 10.days.ago.to_time, anytime: false) } it { is_expected.to accept_values_for(:start_time, 1.days.ago.to_time) } it { is_expected.not_to accept_values_for(:start_time, 15.days.ago.to_time) } diff --git a/spec/models/participation_spec.rb b/spec/models/participation_spec.rb index 27b1c197..c054764c 100644 --- a/spec/models/participation_spec.rb +++ b/spec/models/participation_spec.rb @@ -4,7 +4,7 @@ describe "validations" do - specify { expect { FactoryGirl.create(:participation).dup.save! }.to raise_exception(ActiveRecord::RecordInvalid) } + specify { expect { create(:participation).dup.save! }.to raise_exception(ActiveRecord::RecordInvalid) } it { is_expected.to accept_values_for(:user_id, 1 ) } it { is_expected.not_to accept_values_for(:user_id, "", nil) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c5f6a87a..6126a915 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -67,7 +67,7 @@ describe "#no_oauth_connected?" do subject { user.no_oauth_connected? } - let(:user) { FactoryGirl.create(:user) } + let(:user) { create(:user) } context "account connected" do context "password set" do @@ -89,7 +89,7 @@ describe "#password_required?" do subject { user.password_required? } - let(:user) { FactoryGirl.create(:user) } + let(:user) { create(:user) } context "no account connected" do it { is_expected.to eq(true) } @@ -109,7 +109,7 @@ describe "#update_without_password" do subject { user.update_without_password(params) } - let(:user) { FactoryGirl.create(:user) } + let(:user) { create(:user) } context "no password provided" do let(:params) { {name: "Zbigniew" } } @@ -131,7 +131,7 @@ describe "#apply_omniauth" do subject { user.apply_omniauth(params) } - let(:user) { FactoryGirl.create(:user, name: nil) } + let(:user) { create(:user, name: nil) } context "no data provided" do let(:params) { {} } diff --git a/spec/other/factories_spec.rb b/spec/other/factories_spec.rb index 246f61e1..10236ccd 100644 --- a/spec/other/factories_spec.rb +++ b/spec/other/factories_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -RSpec.describe 'validate FactoryGirl factories' do - FactoryGirl.factories.each do |factory| +RSpec.describe 'validate FactoryBot factories' do + FactoryBot.factories.each do |factory| context "with factory for :#{factory.name}" do - subject { FactoryGirl.build(factory.name) } + subject { build(factory.name) } it { is_expected.to be_valid, subject.errors.full_messages.join(", ") } end end diff --git a/spec/policies/activity_policy_spec.rb b/spec/policies/activity_policy_spec.rb index 24e6cf20..87e85390 100644 --- a/spec/policies/activity_policy_spec.rb +++ b/spec/policies/activity_policy_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe ActivityPolicy do - let(:activity) { FactoryGirl.build(:activity) } + let(:activity) { build(:activity) } let(:activity_creator) { activity.creator } - let(:other_user) { FactoryGirl.build(:user) } + let(:other_user) { build(:user) } subject { described_class } diff --git a/spec/policies/authentication_policy_spec.rb b/spec/policies/authentication_policy_spec.rb index 1ef754ef..49c7b836 100644 --- a/spec/policies/authentication_policy_spec.rb +++ b/spec/policies/authentication_policy_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe AuthenticationPolicy do - let(:authentication) { FactoryGirl.build(:authentication) } + let(:authentication) { build(:authentication) } let(:authentication_user) { authentication.user } - let(:other_user) { FactoryGirl.build(:user) } + let(:other_user) { build(:user) } subject { described_class } diff --git a/spec/policies/participation_policy_spec.rb b/spec/policies/participation_policy_spec.rb index caa4cedb..7db34c51 100644 --- a/spec/policies/participation_policy_spec.rb +++ b/spec/policies/participation_policy_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' RSpec.describe ParticipationPolicy do - let(:participation) { FactoryGirl.build(:participation) } + let(:participation) { build(:participation) } let(:participant) { participation.participant } - let(:other_user) { FactoryGirl.build(:user) } + let(:other_user) { build(:user) } subject { described_class } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4f9de7c2..b3791f60 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -62,6 +62,7 @@ def self.connection # rspec-rails. config.infer_base_class_for_anonymous_controllers = false + config.include FactoryBot::Syntax::Methods config.include Devise::Test::ControllerHelpers, type: :controller config.include Warden::Test::Helpers config.before :suite do