[英]What's the best way to write Resque-related specs in RSpec?
What's the best way to write Resque-related specs in RSpec without stubbing the former ? 在没有剔除前者的情况下,在RSpec中编写与Resque相关的规范的最佳方法是什么?
We currently use the following helper: 我们目前使用以下帮助器:
@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
Heavily borrowing from Resque's own test helper, this works fine but spews out an annoying zsh: killed rake
when the entire spec suite is run through rake. 从Resque自己的测试帮助中大量借用,这可以正常工作,但是当整个规范套件通过rake运行时,会发出一个恼人的
zsh: killed rake
kill rake。
Here's resque's recommendation for how best to run Redis processes in your specs: 以下是resque关于如何在您的规范中最好地运行Redis进程的建议:
https://github.com/resque/resque/wiki/RSpec-and-Resque https://github.com/resque/resque/wiki/RSpec-and-Resque
You can use the resque_spec gem http://github.com/leshill/resque_spec . 您可以使用resque_spec gem http://github.com/leshill/resque_spec 。 A bunch of matcher to test resque.
一堆匹配测试resque。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.