Hi Uros This is generally considered “less than ideal” as it encourages shared state making your tests dependant on each other (e.g. if one of your tests deletes this seed data your other specs will fail regardless) if your data is “static” consider making it hard coded instead, or refactor your tests to not “always” need this data.
However if really want to do this consider switching to transactional tests (or cleaning), unfortunately this is not possible in integration testing environments with a real server ala puma or webrick due to thread / process separation. Transactional setup here will rollback any changes made by your individual tests allowing you to do setup in a `before(:suite)`. You can also exclude certain tables from database cleaners truncation if that helps? Cheers Jon Rowe --------------------------- [email protected] jonrowe.co.uk On 20 August 2018 at 15:22, Uros Certic wrote: > Anyone knows if there is a way to use database_cleaner and clean test > database after each test but keep only certain records? > I have some records that are reused in almost all tests and they need to be > persisted. > Currently i'm setting them with factorybot in before(:all) block but it takes > a lot of time and it would be good if they can be persisted and not removed > with database cleaner > > > > > > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/dejalu-192-f407a59a-2dba-4c68-ac71-06cf5c8bb9eb%40jonrowe.co.uk. For more options, visit https://groups.google.com/d/optout.
