Sha256: 18701678eb5d664b8ea1b2021167e888f2e2c7bb6f30b19b8e5ed794353ad2ce

Contents?: true

Size: 1000 Bytes

Versions: 5

Compression:

Stored size: 1000 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.new
      lambda{ @w.start }.should raise_exception
    end

    it "should default to Quebert.config.worker.exception_handler handler" do
      @q.put Exceptional.new
      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.new
      @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

5 entries across 5 versions & 1 rubygems

Version Path
quebert-1.0.1 spec/worker_spec.rb
quebert-1.0.0 spec/worker_spec.rb
quebert-0.0.9 spec/worker_spec.rb
quebert-0.0.8 spec/worker_spec.rb
quebert-0.0.6 spec/worker_spec.rb