Sha256: f25c166add4642a88165225a11539a7e2017c5b993fe8a50b972f82cb4aa6400

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe DispatchRider::QueueServices::Simple do
  subject(:simple_queue) do
    DispatchRider::QueueServices::Simple.new
  end

  describe "#assign_storage" do
    it "should return an empty array" do
      simple_queue.assign_storage({}).should eq([])
    end
  end

  describe "#insert" do
    it "should insert a serialized object into the queue" do
      simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
      result = JSON.parse(simple_queue.queue.pop)
      result['subject'].should eq('foo')
      result['body'].should eq('bar')
    end
  end

  describe "#raw_head" do
    before :each do
      simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
    end

    it "should return the first item from the queue" do
      result = JSON.parse(simple_queue.raw_head)
      result['subject'].should eq('foo')
      result['body'].should eq('bar')
    end
  end

  describe "#construct_message_from" do
    it "should return the item casted as a message" do
      result = simple_queue.construct_message_from({'subject' => 'foo', 'body' => 'bar'}.to_json)
      result.subject.should eq('foo')
      result.body.should eq('bar')
    end
  end

  describe "#delete" do
    before :each do
      simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
    end

    it "should remove the item from the queue" do
      simple_queue.delete({'subject' => 'foo', 'body' => 'bar'}.to_json)
      simple_queue.should be_empty
    end
  end

  describe "#size" do
    before :each do
      simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
    end

    it "should return the size of the queue" do
      simple_queue.size.should eq(1)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dispatch-rider-1.5.3 spec/lib/dispatch-rider/queue_services/simple_spec.rb
dispatch-rider-1.5.2 spec/lib/dispatch-rider/queue_services/simple_spec.rb
dispatch-rider-1.5.1 spec/lib/dispatch-rider/queue_services/simple_spec.rb
dispatch-rider-1.5.0 spec/lib/dispatch-rider/queue_services/simple_spec.rb
dispatch-rider-1.4.2 spec/lib/dispatch-rider/queue_services/simple_spec.rb