Hak*_*ari 8 ruby rspec ruby-on-rails resque redis
在没有剔除前者的情况下,在RSpec中编写与Resque相关的规范的最佳方法是什么?
我们目前使用以下帮助器:
@dir = File.dirname(File.expand_path(__FILE__))
def start_redis
`redis-server #{@dir}/redis-test.conf`
Resque.redis = "localhost:9736"
end
def stop_redis
`rm -f #{@dir}/dump.rdb`
pid = `ps -A -o pid,command | grep [r]edis-test`.split(" ")[0]
Process.kill("KILL", pid.to_i)
end
Rspec.configure do |config|
config.before(:suite) do
start_redis
end
config.after(:suite) do
stop_redis
end
config.before(:each) do
Resque.redis.flushall
end
end
Run Code Online (Sandbox Code Playgroud)
从Resque自己的测试帮助中大量借用,这种方法很好但是zsh: killed rake当整个规范套件通过rake运行时会发出烦人的声音.
Dia*_*rat 12
以下是resque关于如何在您的规范中最好地运行Redis进程的建议:
https://github.com/resque/resque/wiki/RSpec-and-Resque
| 归档时间: |
|
| 查看次数: |
7318 次 |
| 最近记录: |