在RSPEC中编写与Resque相关规格的最佳方法是什么?
-
28-09-2019 - |
题
在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
从Resque自己的测试助手那里借来的大量借用,这可以正常工作,但很烦人 zsh: killed rake
当整个规格套件通过Rake运行时。
解决方案
这是Resque关于如何最好地在规格中运行Redis流程的建议:
其他提示
您可以使用resque_spec宝石 http://github.com/leshill/resque_spec 。一堆匹配器来测试雷斯特。
不隶属于 StackOverflow