Skip to content
This repository
Browse code

Update README with ResqueSchedulerSpec

  • Loading branch information...
commit d374f384a958c15cb06562f2edae6fa8baa3a1f7 1 parent 2611f7e
Les Hill authored

Showing 1 changed file with 41 additions and 1 deletion. Show diff stats Hide diff stats

  1. +41 1 README.md
42 README.md
Source Rendered
... ... @@ -1,7 +1,7 @@
1 1 ResqueSpec
2 2 ==========
3 3
4   -A simple RSpec and Cucumber matcher for Resque.enqueue, loosely based on
  4 +A simple RSpec and Cucumber matcher for Resque.enqueue and Resque.enqueue_at (from `ResqueScheduler`), loosely based on
5 5 [http://github.com/justinweiss/resque_unit](resque_unit).
6 6
7 7 This should work with Resque v1.6.0 and up and RSpec v1.3.0 and up.
@@ -61,6 +61,46 @@ Then I write some code to make it pass:
61 61 end
62 62 end
63 63
  64 +ResqueScheduler with Specs
  65 +--------------------------
  66 +
  67 +Given this scenario
  68 +
  69 + Given a person
  70 + When I schedule a recalculate
  71 + Then the person has calculate scheduled
  72 +
  73 +And I write this spec using the `resque_spec` matcher
  74 +
  75 + describe "#recalculate" do
  76 + before do
  77 + ResqueSpec.reset!
  78 + end
  79 +
  80 + it "adds person.calculate to the Person queue" do
  81 + person.recalculate
  82 + Person.should have_scheduled(person.id, :calculate)
  83 + end
  84 + end
  85 +
  86 +(And I take note of the `before` block that is calling `reset!` for every spec)
  87 +
  88 +And I might write this as a Cucumber step
  89 +
  90 + Then /the (\w?) has (\w?) scheduled/ do |thing, method|
  91 + thing_obj = instance_variable_get("@#{thing}")
  92 + thing_obj.class.should have_scheduled(thing_obj.id, method.to_sym)
  93 + end
  94 +
  95 +Then I write some code to make it pass:
  96 +
  97 + class Person
  98 + @queue = :people
  99 +
  100 + def recalculate
  101 + Resque.enqueue_at(Time.now + 3600, Person, id, :calculate)
  102 + end
  103 + end
64 104
65 105 Note on Patches/Pull Requests
66 106 =============================

0 comments on commit d374f38

Please sign in to comment.
Something went wrong with that request. Please try again.