Sha256: d0aa716713dcb47501dc4116aec38220c07074fc760273bc97002ededecad2ea

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 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::Backend.register :twenty, 20
    Quebert.backends[:twenty].should eql(20)
  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, 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, 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, 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

1 entries across 1 versions & 1 rubygems

Version Path
quebert-0.0.0 spec/backend_spec.rb