fv17の日記

Webエンジニアの備忘用ブログです。主にWeb界隈の技術に関して書いています。

FactoryBot

FactoryBot.create(:hoge) ではなく create(:hoge) と書く方法

やりたいこと Rspec において、FactoryBot.create(:hoge) の FactoryBot を毎度記述せずに create(:hoge) と書きたい。 結論 rails_helper.rb に下記を加えれば良い。 config.include FactoryBot::Syntax::Methods 参考 https://github.com/thoughtbot/facto…