FactoryBotでユーザーを生成する際、
FactoryBot.create(:user)
やFactoryBot.build(:user)
のように書くと思いますが
この「FactoryBot」部分を省略する方法があるので、メモです。
specフォルダの中にあるrails_helper.rb
に追記します。
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods ##こちらを追記
end
これで、create(:user)
やbuild(:user)
と書くだけでユーザーの生成ができるようになります!
以上です!