In our app's config/environments/development.rb we have
Rails.application.configure do
# ...
if ENV['REDIS_URL']
config.cache_store = :redis_store, ENV['REDIS_URL'], { expires_in: 90.minutes }
end
end
and in config/environments/test.rb this:
Rails.application.configure do
# ...
config.cache_store = :null_store
end
We use some background processes methods in the app, eg:
class UserMailer < ApplicationMailer
# stuff
end
# ...and elsewhere:
class ProfilesController < ApplicationController
# stuff
def amend_confirmation
# more stuff
UserMailer.increased_pledge(amendment).deliver_later
end
end
And when this gets hit in tests, if I don't actively have Redis running in the background (which seems awkward to arrange and potentially buggy to set up in our CI environment), I get the error
Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
For the time being I'm going to deal with this by just mocking/testing for the deliver_later message, but I suspect this isn't a great strategy for a feature test, since it obviously isn't what the user will be doing. Is there a better approach?