diff --git a/Gemfile b/Gemfile index 077c481b..39b340fd 100644 --- a/Gemfile +++ b/Gemfile @@ -38,7 +38,7 @@ gem 'uglifier' group :test do gem 'brakeman', require: false - gem 'factory_girl_rails' + gem 'factory_bot_rails' gem 'json-schema' gem 'rspec-rails' gem 'shoulda-matchers' diff --git a/Gemfile.lock b/Gemfile.lock index b083fb00..117863c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,10 +105,10 @@ GEM actionmailer (>= 4.0, < 6) activesupport (>= 4.0, < 6) execjs (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) + factory_bot_rails (4.8.2) + factory_bot (~> 4.8.2) railties (>= 3.0.0) faker (1.8.4) i18n (~> 0.5) @@ -311,7 +311,7 @@ DEPENDENCIES doorkeeper dotenv-rails exception_notification - factory_girl_rails + factory_bot_rails faker httparty jquery-rails diff --git a/doc/RspecTesting.md b/doc/RspecTesting.md index d17dc0dd..a71dd266 100644 --- a/doc/RspecTesting.md +++ b/doc/RspecTesting.md @@ -26,13 +26,13 @@ At the time of writing, there are four directories in the spec folder. One, `support`, is for helper functions. `rails_helper.rb` and `spec_helper.rb` are also for helper functions. -`factories` is for a gem called [factory-girl][factory-girl]. This gem lets you +`factories` is for a gem called [factory-bot][factory_bot]. This gem lets you use the `create` and `build` functions to quickly create the simplest possible valid version of a given model. For instance: let(:map1) { create :map } - let(:ronald) { create :user, name: "Ronald" } - let(:map2) { create :map, user: ronald } + let(:alex) { create :user, name: "Alex" } + let(:map2) { create :map, user: alex } As you can see, you can also customize the factories. You can read the full documentation at the link above or check the existing specs to see how it works. @@ -53,5 +53,5 @@ the added code works. This will help in a few ways: Happy testing! -[factory-girl]: https://github.com/thoughtbot/factory_girl +[factory-bot]: https://github.com/thoughtbot/factory_bot [rspec-docs]: http://rspec.info diff --git a/spec/factories/access_requests.rb b/spec/factories/access_requests.rb index c85d4a53..5a3bd5dd 100644 --- a/spec/factories/access_requests.rb +++ b/spec/factories/access_requests.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :access_request do map user diff --git a/spec/factories/mappings.rb b/spec/factories/mappings.rb index 13746de1..210ab291 100644 --- a/spec/factories/mappings.rb +++ b/spec/factories/mappings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :mapping do xloc 0 yloc 0 diff --git a/spec/factories/maps.rb b/spec/factories/maps.rb index 557a400f..12863e30 100644 --- a/spec/factories/maps.rb +++ b/spec/factories/maps.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :map do sequence(:name) { |n| "Cool Map ##{n}" } permission :commons diff --git a/spec/factories/message.rb b/spec/factories/message.rb index 280b2c8f..30b14d41 100644 --- a/spec/factories/message.rb +++ b/spec/factories/message.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :message do association :resource, factory: :map user diff --git a/spec/factories/metacodes.rb b/spec/factories/metacodes.rb index 4e5a0d52..98188003 100644 --- a/spec/factories/metacodes.rb +++ b/spec/factories/metacodes.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :metacode do sequence(:name) { |n| "Cool Metacode ##{n}" } manual_icon 'https://images.com/image.png' diff --git a/spec/factories/stars.rb b/spec/factories/stars.rb index 9be99242..7ac39d34 100644 --- a/spec/factories/stars.rb +++ b/spec/factories/stars.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :star do end end diff --git a/spec/factories/synapses.rb b/spec/factories/synapses.rb index 2d8ec60f..5ab5ee90 100644 --- a/spec/factories/synapses.rb +++ b/spec/factories/synapses.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :synapse do sequence(:desc) { |n| "Cool synapse ##{n}" } category :'from-to' diff --git a/spec/factories/tokens.rb b/spec/factories/tokens.rb index 26541fca..84f1f86c 100644 --- a/spec/factories/tokens.rb +++ b/spec/factories/tokens.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :token do user description '' diff --git a/spec/factories/topics.rb b/spec/factories/topics.rb index 1def8f19..eada14f2 100644 --- a/spec/factories/topics.rb +++ b/spec/factories/topics.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :topic do user association :updated_by, factory: :user diff --git a/spec/factories/user_maps.rb b/spec/factories/user_maps.rb index db4d5b0e..0323890f 100644 --- a/spec/factories/user_maps.rb +++ b/spec/factories/user_maps.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -FactoryGirl.define do +FactoryBot.define do factory :user_map do map user diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 20762285..469bcf7e 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -10,7 +10,7 @@ # have actual codes, you'll need to specify one simple_user and then you # can specify other :code_user users based on the pre-existing user's code. -FactoryGirl.define do +FactoryBot.define do factory :code_user, class: User do sequence(:name) { |n| "Cool User ##{n}" } sequence(:email) { |n| "cooluser#{n}@cooldomain.com" } diff --git a/spec/support/factory_girl.rb b/spec/support/factory_girl.rb index 8a7958c9..2e507ebb 100644 --- a/spec/support/factory_girl.rb +++ b/spec/support/factory_girl.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# lets you type create(:user) instead of FactoryGirl.create(:user) +# lets you type create(:user) instead of FactoryBot.create(:user) RSpec.configure do |config| - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods end