My tests are written using fixtures and I am slowly refactoring them to use factories instead.
Once I've refactored a test class to not use fixtures I want to not load fixtures for that class. Is there a way to do this? Or am I stuck with either loading them for everything or nothing?
For context, here is how my fixtures are set up now:
class ActiveSupport::TestCase
Rake::Task["db:fixtures:load"].execute
...
end
Put fixtures in test/fixtures/users.yml
Then you are able to include them where you need, for example in spec_helper
# spec_helper.rb
fixtures :all # include all fixtures
fixtures :users # include only specific fixtures
Doc: fixtures method
P.S. it works well together with FactoryBot gem (ex. FactoryGirl)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With