Sha256: 7606a73a6091e5708d405de9595f799fb8130a032a05cfb7cd21e157163a3b53

Contents?: true

Size: 966 Bytes

Versions: 7

Compression:

Stored size: 966 Bytes

Contents

require 'spec/spec_helper'

describe EM::Beanstalk::Job do
  it 'should convert id to an integer' do
    j = EM::Beanstalk::Job.new(nil, "123", "body")
    j.id.should == 123
  end
  
  it 'should fail if id is not an integer' do
    proc {
      j = EM::Beanstalk::Job.new(nil, "asd", "body")
    }.should raise_error
  end
  
  it 'should send a delete command to the connection' do
    conn = mock(:conn)
    conn.should_receive(:default_priority)
    conn.should_receive(:default_delay)
    conn.should_receive(:default_ttr)
    
    j = EM::Beanstalk::Job.new(conn, 1, "body")

    conn.should_receive(:delete).with(j)
    
    j.delete
  end

  it 'should send a stats command to the connection' do
    conn = mock(:conn)
    conn.should_receive(:default_priority)
    conn.should_receive(:default_delay)
    conn.should_receive(:default_ttr)

    j = EM::Beanstalk::Job.new(conn, 2, 'body')
    conn.should_receive(:stats).with(:job, j)

    j.stats
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
em-beanstalk-0.0.10 spec/job_spec.rb
em-beanstalk-0.0.9 spec/job_spec.rb
em-beanstalk-0.0.8 spec/job_spec.rb
em-beanstalk-0.0.7 spec/job_spec.rb
em-beanstalk-0.0.6 spec/job_spec.rb
em-beanstalk-0.0.5 spec/job_spec.rb
em-beanstalk-0.0.4 spec/job_spec.rb