require 'spec_helper' describe "QuSpec Matchers" do before do QuSpec.reset! end let(:first_name) { 'Morton' } let(:last_name) { 'Jonuschat' } describe "#have_queued" do context "queued with a class" do before do Qu.enqueue(Person, first_name, last_name) end subject { Person } it { should have_queued(first_name, last_name) } it { should_not have_queued(last_name, first_name) } end context "#in" do before do Qu.enqueue(Person, first_name, last_name) end subject { Person } context "with #in(queue_name)" do it { should have_queued(first_name, last_name).in(:people) } it { should_not have_queued(last_name, first_name).in(:people) } end end end describe "#have_queue_size_of" do context "when nothing is queued" do subject { Person } it "raises the approrpiate exception" do expect do should have_queue_size_of(1) end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end end context "queued with a class" do before do Qu.enqueue(Person, first_name, last_name) end subject { Person } it { should have_queue_size_of(1) } end end describe "#in" do before do Qu.enqueue(Person, first_name, last_name) end subject { Person } context "with #in(queue_name)" do it { should have_queue_size_of(1).in(:people) } it { should_not have_queue_size_of(1).in(:other_people) } end context "with #in('queue_name')" do it { should have_queue_size_of(1).in('people') } it { should_not have_queue_size_of(1).in('other_people') } end end describe "#have_scheduled_at" do let(:scheduled_at) { Time.now + 5 * 60 } before do Qu.enqueue_at(scheduled_at, Person, first_name, last_name) end it "returns true if the arguments are found in the queue" do Person.should have_scheduled_at(scheduled_at, first_name, last_name) end it "returns false if the arguments are not found in the queue" do Qu.should_not have_scheduled_at(scheduled_at, last_name, first_name) end end end