Sha256: ce62b2b9d6c0037aaeb49d52086acc5b0f1cd3e8baebce7670bc96c034d63094

Contents?: true

Size: 895 Bytes

Versions: 9

Compression:

Stored size: 895 Bytes

Contents

require 'spec_helper'

describe SuckerPunch::Job do
  before :each do
    class ::FakeJob
      include SuckerPunch::Job
      workers 4

      def perform(name)
        "response #{name}"
      end
    end
  end

  after :each do
    Celluloid::Actor.clear_registry
  end

  it "includes Celluloid into requesting class when included" do
    expect(FakeJob).to respond_to(:pool)
  end

  it "sets the pool size to 4" do
    pool = FakeJob.new
    expect(pool.size).to eq(4)
  end

  it "returns the same pool on each instantiation" do
    pool = FakeJob.new
    pool2 = FakeJob.new
    expect(pool.thread).to eq(pool2.thread)
  end

  describe "when pool hasn't been created" do
    it "registers queue" do
      queue = double("queue")
      allow(SuckerPunch::Queue).to receive(:new).and_return(queue)
      expect(queue).to receive(:register){ 4 }
      pool = FakeJob.new
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sucker_punch-1.6.0 spec/sucker_punch/job_spec.rb
sucker_punch-1.5.1 spec/sucker_punch/job_spec.rb
sucker_punch-1.5.0 spec/sucker_punch/job_spec.rb
sucker_punch-1.4.0 spec/sucker_punch/job_spec.rb
sucker_punch-1.3.2 spec/sucker_punch/job_spec.rb
sucker_punch-1.3.1 spec/sucker_punch/job_spec.rb
sucker_punch-1.3.0 spec/sucker_punch/job_spec.rb
sucker_punch-1.2.1 spec/sucker_punch/job_spec.rb
sucker_punch-1.2 spec/sucker_punch/job_spec.rb