vendredi 9 décembre 2022

Can i use factorybot before whole rspec test?

I'm now using factory bot for my Rspec test. But my code calls factory bot's create method before each test like :

before(:each) do
  create(:user)
  ...
end

I have over 10 controllers, so it took lot's of time And i should copy that before block to each file when i make new Rspec test.

Can i make that code dry, such as "run factory bot's create method once before whole Rspec test starts"?

I think it is very efficient for save running test's time.

Aucun commentaire:

Enregistrer un commentaire