Sha256: 3c91bb71f861fe990016e53ebe723cd9536fc822b0db2b000d59cef9ade8df74

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe JobQueue::BeanstalkAdapter do
  before :all do
    JobQueue.adapter = JobQueue::BeanstalkAdapter.new
  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

2 entries across 2 versions & 2 rubygems

Version Path
mloughran-job_queue-0.0.3 spec/beanstalk_adapter_spec.rb
strobemonkey-job_queue-0.0.5 spec/beanstalk_adapter_spec.rb