Sha256: 6fb61de2a56669539ef29e23cb717f469dcd2e64f347dd092d0208409f5c6dd2
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
require File.dirname(__FILE__) + '/spec_helper' describe JobQueue::BeanstalkAdapter do before :all do JobQueue.adapter = JobQueue::BeanstalkAdapter.new end describe '#new' do it "should default to localhost:11300" do Beanstalk::Pool.should_receive(:new).with(['localhost:11300']) JobQueue::BeanstalkAdapter.new end it "should use options provided" do Beanstalk::Pool.should_receive(:new).with(['12.34.56.78:12345']) JobQueue::BeanstalkAdapter.new(:host => '12.34.56.78', :port => 12345) end end it "should write onto queue and fetch stuff back off" do JobQueue.put("hello") JobQueue.subscribe do |job| @job = job throw :stop end @job.should == "hello" end it "should output message if error raised in job" do JobQueue.put("hello") JobQueue.logger.should_receive(:error).with(/Job failed\w*/) index = 0 JobQueue.subscribe do |job| index +=1 raise 'foo' if index == 1 throw :stop end end it "should use error_report block if supplied" do JobQueue.put("hello") error_report = Proc.new do |job, e| JobQueue.logger.error "Yikes that broke matey!" end JobQueue.logger.should_receive(:error).with("Yikes that broke matey!") index = 0 JobQueue.subscribe(error_report) do |job| index +=1 raise 'foo' if index == 1 throw :stop end end end
Version data entries
5 entries across 5 versions & 2 rubygems