Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Created November 26, 2014 09:27
Show Gist options
  • Save jbmyid/72d7c3b8c415660883f7 to your computer and use it in GitHub Desktop.
Save jbmyid/72d7c3b8c415660883f7 to your computer and use it in GitHub Desktop.
Set rspec for rescue
# rails_helper.rb
# Redis and Resque config
REDIS_PID = "#{Rails.root}/tmp/pids/redis-test.pid"
REDIS_CACHE_PATH = "#{Rails.root}/tmp/cache/"
config.before(:suite) do
redis_options = {
"daemonize" => 'yes',
"pidfile" => REDIS_PID,
"port" => 9736,
"timeout" => 300,
"save 900" => 1,
"save 300" => 1,
"save 60" => 10000,
"dbfilename" => "dump-test.rdb",
"dir" => REDIS_CACHE_PATH,
"loglevel" => "debug",
"logfile" => "stdout",
"databases" => 16
}.map { |k, v| "#{k} #{v}" }.join("\n")
`echo '#{redis_options}' | redis-server -`
end
config.after(:suite) do
%x{
kill -TERM $(cat #{REDIS_PID})
rm -f #{REDIS_CACHE_PATH}dump.rdb
}
end
# and in resque.rb in initializer folder
Resque.redis = {host: "localhost", port: 9736, db: 0} if Rails.env='test'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment