Sha256: 5e34b3f592e11ce62cddbd93960ff2e3712d9f80f208f81ac5af23b30654bde2

Contents?: true

Size: 870 Bytes

Versions: 4

Compression:

Stored size: 870 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, opts| e.should be_a(StandardError) }
      lambda{ @w.start }.should_not raise_exception
    end

    it "should intercept exceptions" do
      @q.put Exceptional.new
      @w.exception_handler = Proc.new{|e, opts| e.should be_a(StandardError) }
      lambda{ @w.start }.should_not raise_exception
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
quebert-3.0.3 spec/worker_spec.rb
quebert-3.0.2 spec/worker_spec.rb
quebert-3.0.1 spec/worker_spec.rb
quebert-3.0.0 spec/worker_spec.rb