spec/unit/queues_spec.rb in fake_sqs-0.0.9 vs spec/unit/queues_spec.rb in fake_sqs-0.0.10
- old
+ new
@@ -1,18 +1,20 @@
require 'fake_sqs/queues'
+require 'fake_sqs/memory_database'
describe FakeSQS::Queues do
+ let(:fake_database) { FakeSQS::MemoryDatabase.new }
let(:queue_factory) { double :queue_factory, :new => double }
- subject(:queues) { FakeSQS::Queues.new(queue_factory: queue_factory) }
+ subject(:queues) { FakeSQS::Queues.new(queue_factory: queue_factory, database: fake_database) }
describe "#create" do
it "creates new queues" do
- queues.should have(0).queues
+ queues.list.size.should eq 0
create_queue("test")
- queues.should have(1).queues
+ queues.list.size.should eq 1
end
it "uses the queue factory" do
params = double :params
queue_factory.should_receive(:new).with(params)
@@ -36,13 +38,13 @@
describe "#delete" do
it "deletes an existing queue" do
create_queue("test")
- queues.should have(1).queues
+ queues.list.size.should eq 1
queues.delete("test")
- queues.should have(0).queues
+ queues.list.size.should eq 0
end
it "cannot delete an non-existing queue" do
expect {
queues.delete("test")
@@ -60,11 +62,11 @@
end
it "can be filtered by prefix" do
queue1 = create_queue("test-1")
queue2 = create_queue("test-2")
- queue3 = create_queue("other-3")
+ _ = create_queue("other-3")
queues.list("QueueNamePrefix" => "test").should eq [ queue1, queue2 ]
end
end
@@ -86,12 +88,12 @@
describe "#reset" do
it "clears all queues" do
create_queue("foo")
create_queue("bar")
- queues.should have(2).queues
+ queues.list.size.should eq 2
queues.reset
- queues.should have(0).queues
+ queues.list.size.should eq 0
end
end
def create_queue(name, options = {})