Sha256: e9d2c2e301a9bbd23153befbd0958e4a699deea4009ac28bef4a336c5b395173

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

require 'beanstalk-client-rspec'

describe Beanstalk::MockPool do
  before do
    @beanstalk = Beanstalk::MockPool.new ['127.0.0.1:11301']
  end

  it 'should accept objects on the default' do
    @beanstalk.put 'cow'
    job = @beanstalk.reserve
    job.body.should == 'cow'

    job.release

    job = @beanstalk.reserve
    job.body.should == 'cow'

    job.delete
  end

  it 'should accept objects on a named tube' do
    @beanstalk.use 'moo'
    @beanstalk.put 'cow'

    @beanstalk.watch 'moo'
    @beanstalk.ignore 'default'
    job = @beanstalk.reserve
    job.body.should == 'cow'
  end

  it 'should deal with on_tube' do
    @beanstalk.on_tube 'foo' do |c|
      c.put 'cow'
    end

    @beanstalk.watch 'foo'
    @beanstalk.ignore 'default'
    job = @beanstalk.reserve
    job.body.should == 'cow'
  end

  describe 'reset!' do

    it 'should empty tubes' do
      @beanstalk.put 'cow'
      @beanstalk.should have_tube_size_of(1).for('default')
      @beanstalk.reset!
      @beanstalk.should have_tube_size_of(0).for('default')
    end

    it 'should not be watching anything' do
      @beanstalk.list_tubes_watched.values.flatten.should == ['default']
      @beanstalk.watch 'foo'
      @beanstalk.list_tubes_watched.values.flatten.should == ['default', 'foo']
      @beanstalk.reset!
      @beanstalk.list_tubes_watched.values.flatten.should == ['default']
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
beanstalk-client-rspec-0.0.3 spec/beanstalk_spec.rb