Sha256: d7d12ea2fd451425eea733058ba6d1c7f5a88fe81c60da39630f76b1b3add8c2

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

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

describe Backend do
  it "should have register backends" do
    Quebert.backends.keys.should include(:in_process, :beanstalk, :sync)
  end
  
  it "should register backends" do
    Quebert.backends.register :twenty, 20
    Quebert.backends[:twenty].should eql(20)
  end
  
  it "should unregister backends" do
    Quebert.backends.unregister :twenty
    Quebert.backends[:twenty].should be_nil
  end
end

describe Backend::InProcess do
  before(:all) do
    @q = Backend::InProcess.new
  end
  
  it "should put on queue" do
    3.times do |num|
      @q.put Adder.new(num)
    end
  end
  
  it "should consume from queue" do
    3.times do |num|
      @q.reserve.perform.should eql(num)
    end
  end
end

describe Backend::Beanstalk  do
  before(:all) do
    @q = Backend::Beanstalk.new('localhost:11300','quebert-test')
    @q.drain!
  end
  
  it "should put on queue" do
    3.times do |num|
      @q.put Adder.new(num)
    end
  end
  
  it "should consume from queue" do
    3.times do |num|
      @q.reserve.perform.should eql(num)
    end
  end
end

describe Backend::Sync do
  before(:all) do
    @q = Backend::Sync.new
  end
  
  it "should put on queue" do
    3.times do |num|
      @q.put(Adder.new(num)).should eql(num)
    end
  end
  
  it "should consume from queue" do
    3.times do |num|
      lambda{
        @q.reserve.perform.should eql(num)
      }.should raise_exception
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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