Sha256: e0a9b47431ca783b8b79f05612b54a101ef2c2ef1d89c1f5b40b4785c3a5b6a8

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

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

describe Worker do
  before(:each) do
    @q = Backend::InProcess.new
    @w = Worker.new do |w|
      w.backend = @q
    end
  end
  
  it "should start" do
    @w.start
  end
  
  context "pluggable exception handler" do
    it "should raise exception if nothing is provided" do
      @q.put Exceptional
      lambda{ @w.start }.should raise_exception
    end

    it "should default to Quebert.config.worker.exception_handler handler" do
      @q.put Exceptional
      Quebert.config.worker.exception_handler = Proc.new{|e| e.should be_instance_of(Exception) }
      @w.exception_handler = Proc.new{|e| e.should be_instance_of(Exception) }
      lambda{ @w.start }.should_not raise_exception
    end
    
    it "should intercept exceptions" do
      @q.put Exceptional
      @w.exception_handler = Proc.new{|e| e.should be_instance_of(Exception) }
      lambda{ @w.start }.should_not raise_exception
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quebert-0.0.4 spec/worker_spec.rb
quebert-0.0.3 spec/worker_spec.rb