LoginSignup
1
0

More than 1 year has passed since last update.

#Ruby / #Rails - FactoryBot でエイリアスを呼び出すみたいに、元の定義をコピー・継承して別名を作る

Last updated at Posted at 2019-07-10

#Ruby / # Rails-Copy and inherit the original definition to create an alias, just like calling an alias in FactoryBot

Factoryの中にFactoryを書くだけで良いらしい。こいつは使える!

factory :user do
  name { 'SomeName' }

  factory :alice do
      name { 'Alice' }
  end

  factory :bob do
      name { 'Bob' } 
  end
end
FactoryBot.create :user
FactoryBot.create :alice
FactoryBot.create :bob

FactoryGirlチートシート - Qiita

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
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
1
0