Created
March 14, 2012 22:50
-
-
Save denniskuczynski/2040189 to your computer and use it in GitHub Desktop.
Basic Stalker RSpec Test Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe Stalker, "/jobs/stalker_example.rb" do | |
before :all do | |
# Make sure beanstalkd is running | |
if `pgrep beanstalkd` == "" | |
raise "PRECONDITION NOT MET: beanstalkd not running" | |
end | |
# Turn off all log output | |
module Stalker | |
def log(msg); end | |
def log_error(msg); end | |
end | |
end | |
before :each do | |
@entered_error_handler = false | |
# Clears all job, before, and error handlers | |
Stalker.clear! | |
# Load all jobs in our jobs file | |
require File.dirname(__FILE__) + "/../../../lib/jobs/stalker_example" | |
end | |
it "enqueue and work (basic_job) ensuring that (second_job) is placed on the queue" do | |
#Redefine the error handler | |
Stalker.error { |e| @entered_error_handler = true } | |
id = "test" | |
Stalker.enqueue('basic_job', {:id => id}) | |
Stalker.prep | |
Stalker.work_one_job | |
@entered_error_handler.should eq(false) | |
# Work (second_job) | |
Stalker.work_one_job | |
@entered_error_handler.should eq(false) | |
# Check that (second_job) did what it was supposed to (TODO: example doesn't do anything) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment