0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

seedでもFactoryBoutして幸せになった話

Posted at

Overview

この記事では、seedファイルでFactoryBotファイルを使うことできっと幸せになれるよ!っていうお話をします。
僕はテストや検証時のデータ管理を1箇所でできるようになったので、それでだいぶ幸せになりました。

Motivation

こういう人には刺さるんじゃないかっていう人たち

  • FactoryBotを使ってテストデータを作ってる人
  • 普段seedsファイルで User.create!(...)って書いてる人
  • seedsとfactoryの2箇所でテスト環境・開発環境のデータをそれぞれ管理してる人

Get Started!!

db/seeds.rb

+ require 'factory_bot_rails'

+ FactoryBot.create(:user, email: "alice@example.com")
- User.create(email: "alice@example.com", password: password)

これの何が良いって、FactoryBotのファイルで本番環境以外のデータを共通管理できるところだよね。
なぜもっと早く気づかなんだ。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?