I'm testing a Rails model which has file attachments using Dragonfly. This means I'm creating a lot of files in public/system/dragonfly/test
every time I run my specs.
I'm looking for a way to have Dragonfly cleanup after itself or, ideally, to not create files at all during testing. I could simply delete public/system/dragonfly/test
after every run (or even every example) but I'm sure there will be a more robust way to do this.
I'm using Rails 4.1 with RSpec 3.1 and Dragonfly 0.9.15.
After spending some more time searching around, I discovered Dragonfly's memory data store, effectively preventing files from being created in the first place. However, this required an update to Dragonfly 1.0.7.
Here's my support file which sets Dragonfly's default app to use the memory data store:
# spec/support/dragonfly.rb
RSpec.configure do |config|
config.before(:suite) do
Dragonfly.app.use_datastore(:memory)
end
end