Sha256: 724010272694627d068dcd9fdb79c4488e626d01f96812b20d3446819d34b837
Contents?: true
Size: 2 KB
Versions: 3
Compression:
Stored size: 2 KB
Contents
require 'rubygems' require 'spec/autorun' require 'mocha' dir = File.dirname(__FILE__) $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'resque-restriction' # # make sure we can run redis # if !system("which redis-server") puts '', "** can't find `redis-server` in your path" puts "** try running `sudo rake install`" abort '' end # # start our own redis when the tests start, # kill it when they end # at_exit do next if $! exit_code = Spec::Runner.run pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0] puts "Killing test redis server [#{pid}]..." `rm -f #{dir}/dump.rdb` Process.kill("KILL", pid.to_i) exit exit_code end puts "Starting redis for testing at localhost:9736..." `redis-server #{dir}/redis-test.conf` Resque.redis = 'localhost:9736' ## # Helper to perform job classes # module PerformJob def perform_job(klass, *args) resque_job = Resque::Job.new(:testqueue, 'class' => klass, 'args' => args) resque_job.perform end end class OneDayRestrictionJob < Resque::Plugins::RestrictionJob restrict :per_day => 100 @queue = 'normal' def self.perform(args) end end class OneHourRestrictionJob < Resque::Plugins::RestrictionJob restrict :per_hour => 10 @queue = 'normal' def self.perform(args) end end class IdentifiedRestrictionJob < Resque::Plugins::RestrictionJob restrict :per_hour => 10 @queue = 'normal' def self.identifier(*args) [self.to_s, args.first].join(":") end def self.perform(*args) end end class ConcurrentRestrictionJob < Resque::Plugins::RestrictionJob restrict :concurrent => 1 @queue = 'normal' def self.perform(*args) sleep 0.2 end end class MultipleRestrictionJob < Resque::Plugins::RestrictionJob restrict :per_hour => 10, :per_300 => 2 @queue = 'normal' def self.perform(args) end end class MultiCallRestrictionJob < Resque::Plugins::RestrictionJob restrict :per_hour => 10 restrict :per_300 => 2 @queue = 'normal' def self.perform(args) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
resque-restriction-0.2.2 | spec/spec_helper.rb |
resque-restriction-0.2.1 | spec/spec_helper.rb |
resque-restriction-0.2.0 | spec/spec_helper.rb |