factory_girl => factory_bot (#1172)
This commit is contained in:
parent
955ebdd747
commit
bd7bf20810
15 changed files with 22 additions and 22 deletions
2
Gemfile
2
Gemfile
|
@ -38,7 +38,7 @@ gem 'uglifier'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'brakeman', require: false
|
gem 'brakeman', require: false
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_bot_rails'
|
||||||
gem 'json-schema'
|
gem 'json-schema'
|
||||||
gem 'rspec-rails'
|
gem 'rspec-rails'
|
||||||
gem 'shoulda-matchers'
|
gem 'shoulda-matchers'
|
||||||
|
|
|
@ -105,10 +105,10 @@ GEM
|
||||||
actionmailer (>= 4.0, < 6)
|
actionmailer (>= 4.0, < 6)
|
||||||
activesupport (>= 4.0, < 6)
|
activesupport (>= 4.0, < 6)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
factory_girl (4.8.0)
|
factory_bot (4.8.2)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
factory_girl_rails (4.8.0)
|
factory_bot_rails (4.8.2)
|
||||||
factory_girl (~> 4.8.0)
|
factory_bot (~> 4.8.2)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
faker (1.8.4)
|
faker (1.8.4)
|
||||||
i18n (~> 0.5)
|
i18n (~> 0.5)
|
||||||
|
@ -311,7 +311,7 @@ DEPENDENCIES
|
||||||
doorkeeper
|
doorkeeper
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
exception_notification
|
exception_notification
|
||||||
factory_girl_rails
|
factory_bot_rails
|
||||||
faker
|
faker
|
||||||
httparty
|
httparty
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
|
|
@ -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
|
`support`, is for helper functions. `rails_helper.rb` and `spec_helper.rb` are
|
||||||
also for helper functions.
|
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
|
use the `create` and `build` functions to quickly create the simplest possible
|
||||||
valid version of a given model. For instance:
|
valid version of a given model. For instance:
|
||||||
|
|
||||||
let(:map1) { create :map }
|
let(:map1) { create :map }
|
||||||
let(:ronald) { create :user, name: "Ronald" }
|
let(:alex) { create :user, name: "Alex" }
|
||||||
let(:map2) { create :map, user: ronald }
|
let(:map2) { create :map, user: alex }
|
||||||
|
|
||||||
As you can see, you can also customize the factories. You can read the full
|
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.
|
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!
|
Happy testing!
|
||||||
|
|
||||||
[factory-girl]: https://github.com/thoughtbot/factory_girl
|
[factory-bot]: https://github.com/thoughtbot/factory_bot
|
||||||
[rspec-docs]: http://rspec.info
|
[rspec-docs]: http://rspec.info
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :access_request do
|
factory :access_request do
|
||||||
map
|
map
|
||||||
user
|
user
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :mapping do
|
factory :mapping do
|
||||||
xloc 0
|
xloc 0
|
||||||
yloc 0
|
yloc 0
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :map do
|
factory :map do
|
||||||
sequence(:name) { |n| "Cool Map ##{n}" }
|
sequence(:name) { |n| "Cool Map ##{n}" }
|
||||||
permission :commons
|
permission :commons
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :message do
|
factory :message do
|
||||||
association :resource, factory: :map
|
association :resource, factory: :map
|
||||||
user
|
user
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :metacode do
|
factory :metacode do
|
||||||
sequence(:name) { |n| "Cool Metacode ##{n}" }
|
sequence(:name) { |n| "Cool Metacode ##{n}" }
|
||||||
manual_icon 'https://images.com/image.png'
|
manual_icon 'https://images.com/image.png'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :star do
|
factory :star do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :synapse do
|
factory :synapse do
|
||||||
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
||||||
category :'from-to'
|
category :'from-to'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :token do
|
factory :token do
|
||||||
user
|
user
|
||||||
description ''
|
description ''
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :topic do
|
factory :topic do
|
||||||
user
|
user
|
||||||
association :updated_by, factory: :user
|
association :updated_by, factory: :user
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryBot.define do
|
||||||
factory :user_map do
|
factory :user_map do
|
||||||
map
|
map
|
||||||
user
|
user
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# have actual codes, you'll need to specify one simple_user and then you
|
# 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.
|
# 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
|
factory :code_user, class: User do
|
||||||
sequence(:name) { |n| "Cool User ##{n}" }
|
sequence(:name) { |n| "Cool User ##{n}" }
|
||||||
sequence(:email) { |n| "cooluser#{n}@cooldomain.com" }
|
sequence(:email) { |n| "cooluser#{n}@cooldomain.com" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# 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|
|
RSpec.configure do |config|
|
||||||
config.include FactoryGirl::Syntax::Methods
|
config.include FactoryBot::Syntax::Methods
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue