README.md in resque_spec-0.7.0 vs README.md in resque_spec-0.8.0
- old
+ new
@@ -1,19 +1,16 @@
ResqueSpec
==========
-A simple RSpec and Cucumber matcher for Resque.enqueue and
-Resque.enqueue_at/enqueue_in (from `ResqueScheduler`), loosely based on
+A test double of Resque for RSpec and Cucumber. The code was originally based
+on
[http://github.com/justinweiss/resque_unit](http://github.com/justinweiss/resque_unit).
ResqueSpec will also fire Resque hooks if you are using them. See below.
-This should work with `Resque v1.15.0` and up and `RSpec v2.5.0` and up.
+The current version works with `Resque v1.19.0` and up and `RSpec v2.5.0` and up.
-If you are using `RSpec ~> 1.3.0`, you should use version `~> 0.2.0`. This
-branch is not actively maintained.
-
Install
-------
Update your Gemfile to include `resque_spec` only in the *test* group (Not using
`bundler`? Do the necessary thing for your app's gem management and use
@@ -21,10 +18,19 @@
group :test do
gem 'resque_spec'
end
+What is ResqueSpec?
+===================
+
+ResqueSpec is a fake of the *stable API* for Resque 1.19.x (which is `enqueue`,
+`enqueue_to`, `dequeue`, `reserve`, and the Resque hooks). 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
=================
Given this scenario
@@ -75,10 +81,33 @@
def recalculate
Resque.enqueue(Person, id, :calculate)
end
end
+You can check the size of the queue in your specs too.
+
+ describe "#recalculate" do
+ before do
+ ResqueSpec.reset!
+ end
+
+ it "adds an entry to the Person queue" do
+ person.recalculate
+ Person.should have_queue_size_of(1)
+ end
+ end
+
+ResqueMailer with Specs
+=======================
+
+To use with [ResqueMailer](https://github.com/zapnap/resque_mailer) you should
+have an initializer that does *not* exclude the `test` (or `cucumber`)
+environment. Your initializer will probably end up looking like:
+
+ # config/initializers/resque_mailer.rb
+ Resque::Mailer.excluded_environments = []
+
ResqueScheduler with Specs
==========================
To use with ResqueScheduler, add this require `require 'resque_spec/scheduler'`
@@ -120,30 +149,14 @@
def recalculate
Resque.enqueue_at(Time.now + 3600, Person, id, :calculate)
end
end
-Queue Size Specs
-================
-
-You can check the size of the queue in your specs too.
-
- describe "#recalculate" do
- before do
- ResqueSpec.reset!
- end
-
- it "adds an entry to the Person queue" do
- person.recalculate
- Person.should have_queue_size_of(1)
- end
- end
-
Performing Jobs in Specs
========================
-Normally, Resque does not perform queued jobs within tests. You may want to
+Normally, ResqueSpec does not perform queued jobs within tests. You may want to
make assertions based on the result of your jobs. ResqueSpec can process jobs
immediately as they are queued or under your control.
Performing jobs immediately
---------------------------
@@ -203,18 +216,23 @@
end
Hooks
=====
-Resque provides hooks at different points of the queueing lifecylce. ResqueSpec fires these hooks when appropriate.
+Resque provides hooks at different points of the queueing lifecylce.
+ResqueSpec fires these hooks when appropriate.
-The after enqueue hook is always called when you use `Resque#enqueue`.
+The before and after `enqueue` hooks are always called when you use
+`Resque#enqueue`. If your `before_enqueue` hook returns `false`, the job will
+not be queued and `after_enqueue` will not be called.
The `perform` hooks: before, around, after, and on failure are fired by
ResqueSpec if you are using the `with_resque` helper or set `ResqueSpec.inline = true`.
-Important! `Resque#enqueue_at/enqueue_in` does not fire the after enqueue hook (the job has not been queued yet!), but will fire the `perform` hooks if you are using `inline` mode.
+Important! If you are using ResqueScheduler, `Resque#enqueue_at/enqueue_in`
+does not fire the after enqueue hook (the job has not been queued yet!), but
+will fire the `perform` hooks if you are using `inline` mode.
Note on Patches/Pull Requests
=============================
* Fork the project.
@@ -222,9 +240,25 @@
* Add tests for it. This is important so I don't break it in a
future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
+
+Contributors
+============
+
+* Les Hill (@leshill) : author
+* Kenneth Kalmer (@kennethkalmer) : rspec dependency fix
+* Brian Cardarella (@bcardarella) : fix mutation bug
+* Joshua Davey (@joshdavey) : with_resque helper
+* Lar Van Der Jagt (@supaspoida) : with_resque helper
+* Evan Sagge (@evansagge) : Hook in via Job.create, have_queued.in
+* Jon Larkowski (@l4rk) : inline perform
+* James Conroy-Finn (@jcf) : spec fix
+* Dennis Walters (@ess) : enqueue_in support
+* (@RipTheJacker) : remove_delayed support
+* Kurt Werle (@kwerle) : explicit require spec for v020
+* (@dwilkie) : initial before_enqueue support
Copyright
=========
Copyright (c) 2010-2011 Les Hill. See LICENSE for details.