Sha256: 16991e953a77164b980a6b3e2d6338eff28bbf2776085a969b2c182feec32e15

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

require 'spec/spec_helper'

describe EMJack::Job do
  it 'should convert id to an integer' do
    j = EMJack::Job.new(nil, "123", "body")
    j.id.should == 123
  end
  
  it 'should fail if id is not an integer' do
    proc {
      j = EMJack::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 = EMJack::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 = EMJack::Job.new(conn, 2, 'body')
    conn.should_receive(:stats).with(:job, j)

    j.stats
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-beanstalk-0.0.3 spec/job_spec.rb