Sha256: 9a962837da194fc48c382efa293be404fa4ed5e0d2ca2d5c7b8f69f218e97085
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe DispatchRider::QueueServices::Simple do subject(:simple_queue) do described_class.new end describe "#assign_storage" do it "should return an empty array" do expect(simple_queue.assign_storage({})).to 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) expect(result['subject']).to eq('foo') expect(result['body']).to eq('bar') end end describe "#raw_head" do before 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) expect(result['subject']).to eq('foo') expect(result['body']).to 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) expect(result.subject).to eq('foo') expect(result.body).to eq('bar') end end describe "#delete" do before 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) expect(simple_queue).to be_empty end end describe "#size" do before do simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json) end it "should return the size of the queue" do expect(simple_queue.size).to eq(1) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dispatch-rider-2.2.0 | spec/lib/dispatch-rider/queue_services/simple_spec.rb |