Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 什么';在RSpec中编写Resque相关规范的最佳方法是什么?_Ruby On Rails_Ruby_Rspec_Redis_Resque - Fatal编程技术网

Ruby on rails 什么';在RSpec中编写Resque相关规范的最佳方法是什么?

Ruby on rails 什么';在RSpec中编写Resque相关规范的最佳方法是什么?,ruby-on-rails,ruby,rspec,redis,resque,Ruby On Rails,Ruby,Rspec,Redis,Resque,在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,

在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自己的测试助手,这可以很好地工作,但当整个规范套件通过rake运行时,会抛出一个恼人的
zsh:killed rake

您可以使用Resque_spec gem。一组matcher来测试resque。

以下是resque关于如何在您的规范中最好地运行Redis进程的建议:


这会留下Resque,我想这对于单元测试来说很好,但我更喜欢运行Resque的实际实例来编写更复杂的集成测试。看来我们现在只能处理上面的问题了。@HakanEnsari,你有没有为你的规范做过任何不同的事情?我正在编写一个需要集成resque(使用resque_-mailer)的测试,我被难住了。