README.md in resque_spec-0.8.1 vs README.md in resque_spec-0.9.0
- old
+ new
@@ -23,12 +23,14 @@
What is ResqueSpec?
===================
ResqueSpec implements the *stable API* for Resque 1.19.x (which is `enqueue`,
-`enqueue_to` (*unreleased*), `dequeue`, `reserve`, and the Resque hooks). It
-does not have a test double for Redis, so this may lead to some interesting and
+`enqueue_to` (*unreleased*), `dequeue`, `reserve`, the Resque hooks, and
+because of the way `resque_scheduler` works `Job.create` and `Job.destroy`).
+
+It does not have a test double for Redis, so this may lead to some interesting and
puzzling behaviour if you use some of the popular Resque plugins (such as
`resque_lock`).
Resque with Specs
=================
@@ -129,12 +131,54 @@
person.recalculate
Person.should have_scheduled(person.id, :calculate)
end
end
-(And I take note of the `before` block that is calling `reset!` for every spec)
+And I might use the `at` statement to specify the time:
-*(There is also a **have_scheduled_at** matcher)*
+ describe "#recalculate" do
+ before do
+ ResqueSpec.reset!
+ end
+
+ it "adds person.calculate to the Person queue" do
+ person.recalculate
+
+ # Is it scheduled to be executed at 2010-02-14 06:00:00 ?
+ Person.should have_scheduled(person.id, :calculate).at(Time.mktime(2010,2,14,6,0,0))
+ end
+ end
+
+And I might use the `in` statement to specify time interval (in seconds):
+
+ describe "#recalculate" do
+ before do
+ ResqueSpec.reset!
+ end
+
+ it "adds person.calculate to the Person queue" do
+ person.recalculate
+
+ # Is it scheduled to be executed in 5 minutes?
+ Person.should have_scheduled(person.id, :calculate).in(5 * 60)
+ end
+ end
+
+You can also check the size of the schedule:
+
+ describe "#recalculate" do
+ before do
+ ResqueSpec.reset!
+ end
+
+ it "adds person.calculate to the Person queue" do
+ person.recalculate
+
+ Person.should have_schedule_size_of(1)
+ end
+ end
+
+(And I take note of the `before` block that is calling `reset!` for every spec)
And I might write this as a Cucumber step
Then /the (\w?) has (\w?) scheduled/ do |thing, method|
thing_obj = instance_variable_get("@#{thing}")