spec/spec_helper.rb in sidekiq-status-0.6.0 vs spec/spec_helper.rb in sidekiq-status-0.7.0

- old
+ new

@@ -1,17 +1,23 @@ require "rspec" -require 'celluloid' require 'sidekiq' require 'sidekiq/processor' require 'sidekiq/manager' require 'sidekiq-status' +# Clears jobs before every test +RSpec.configure do |config| + config.before(:each) do + Sidekiq.redis { |conn| conn.flushall } + sleep 0.05 + end +end Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } -def client_middleware(client_middleware_options={}) +def client_middleware(client_middleware_options={}) Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add Sidekiq::Status::ClientMiddleware, client_middleware_options end end @@ -50,11 +56,13 @@ pid = Process.fork do $stdout.reopen File::NULL, 'w' $stderr.reopen File::NULL, 'w' require 'sidekiq/cli' Sidekiq.options[:queues] << 'default' - Sidekiq.options[:require] = File.expand_path('../support/test_jobs.rb', __FILE__) + Sidekiq.options[:require] = File.expand_path('environment.rb', File.dirname(__FILE__)) + Sidekiq.options[:timeout] = 1 + Sidekiq.options[:concurrency] = 5 Sidekiq.configure_server do |config| config.redis = Sidekiq::RedisConnection.create config.server_middleware do |chain| chain.add Sidekiq::Status::ServerMiddleware, server_middleware_options end @@ -63,9 +71,9 @@ end yield sleep 0.1 Process.kill 'TERM', pid - Timeout::timeout(10) { Process.wait pid } rescue Timeout::Error + Timeout::timeout(5) { Process.wait pid } rescue Timeout::Error ensure Process.kill 'KILL', pid rescue "OK" # it's OK if the process is gone already end