Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #39 from marcinb/master

have_schedule_size_of matcher
  • Loading branch information...
commit 580c618edee8689631fa9a233617c08853b6eb4c 2 parents fa6491b + 58857d3
@leshill leshill authored
Showing with 38 additions and 0 deletions.
  1. +18 −0 lib/resque_spec/matchers.rb
  2. +20 −0 spec/resque_spec/matchers_spec.rb
View
18 lib/resque_spec/matchers.rb
@@ -100,3 +100,21 @@ def queue(actual)
"have scheduled at the given time the arguments"
end
end
+
+RSpec::Matchers.define :have_schedule_size_of do |size|
+ match do |actual|
+ ResqueSpec.schedule_for(actual).size == size
+ end
+
+ failure_message_for_should do |actual|
+ "expected that #{actual} would have #{size} scheduled entries, but got #{ResqueSpec.schedule_for(actual).size} instead"
+ end
+
+ failure_message_for_should_not do |actual|
+ "expected that #{actual} would have #{size} scheduled entries."
+ end
+
+ description do
+ "have schedule size of #{size}"
+ end
+end
View
20 spec/resque_spec/matchers_spec.rb
@@ -152,4 +152,24 @@
Person.should_not have_scheduled(last_name, first_name)
end
end
+
+ describe "#have_schedule_size_of" do
+ before do
+ Resque.enqueue_at(Time.now + 5 * 60, Person, first_name, last_name)
+ end
+
+ it "raises the approrpiate exception" do
+ lambda {
+ Person.should have_schedule_size_of(2)
+ }.should raise_error(RSpec::Expectations::ExpectationNotMetError)
+ end
+
+ it "returns true if actual schedule size matches positive expectation" do
+ Person.should have_schedule_size_of(1)
+ end
+
+ it "returns true if actual schedule size matches negative expectation" do
+ Person.should_not have_schedule_size_of(2)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.