resque/resque-scheduler

Test: Running test destroys my local Redis data

Opened this issue · 0 comments

This project uses Redis on localhost:6379 for testing now.
But I use it in the development of other Rails app as well.
I was wondering why the data disappeared for a while, but it was due to the following part:

setup do
Resque::Scheduler.quiet = true
Resque.data_store.redis.flushall
end

I checked what they are doing in Resque and they have Redis on localhost:9736 for testing.
https://github.com/resque/resque/blob/daf45bbbaf87411d27c0eb1df44ce463746cf5c8/test/test_helper.rb#L32-L33

# start our own redis when the tests start,
# kill it when they end

https://github.com/resque/resque/blob/daf45bbbaf87411d27c0eb1df44ce463746cf5c8/test/test_helper.rb#L73-L75

  puts "Starting redis for testing at localhost:9736..."
  `redis-server #{$dir}/redis-test.conf`
  Resque.redis = 'localhost:9736'

I think it is a good idea to take this same approach.