質問

rspecでリクエスト関連の仕様を書くための最良の方法は何ですか 前者を突き刺さずに?

現在、次のヘルパーを使用しています。

@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 スペックスイート全体がレーキを介して実行されるとき。

役に立ちましたか?

解決

スペックでRedisプロセスを実行するのが最善の方法についてのResqueの推奨事項は次のとおりです。

https://github.com/resque/resque/wiki/rspec-and-resque

他のヒント

resque_spec gemを使用できます http://github.com/leshill/resque_spec 。リクをテストするためのマッチャーの束。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top