Created
November 26, 2014 09:27
-
-
Save jbmyid/72d7c3b8c415660883f7 to your computer and use it in GitHub Desktop.
Set rspec for rescue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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