Sha256: 21f4abecebc6593b4f161f2dfe248509dfc8b9da1f61c3c8b67dac7517378f58

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

require '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

7 entries across 7 versions & 1 rubygems

Version Path
quebert-1.0.9 spec/worker_spec.rb
quebert-1.0.8 spec/worker_spec.rb
quebert-1.0.7 spec/worker_spec.rb
quebert-1.0.6 spec/worker_spec.rb
quebert-1.0.5 spec/worker_spec.rb
quebert-1.0.4 spec/worker_spec.rb
quebert-1.0.2 spec/worker_spec.rb