spec/spec_helper.rb in resque-restriction-0.3.0 vs spec/spec_helper.rb in resque-restriction-0.4.0
- old
+ new
@@ -1,7 +1,6 @@
require 'rubygems'
-require 'spec/autorun'
require 'mocha'
dir = File.dirname(__FILE__)
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'resque-restriction'
@@ -36,74 +35,73 @@
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
+ klass.perform_now(*args)
end
end
class OneDayRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_day => 100
- @queue = 'normal'
-
- def self.perform(args)
+ queue_as 'normal'
+
+ def perform(args)
end
end
class OneHourRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_hour => 10
- @queue = 'normal'
+ queue_as 'normal'
- def self.perform(args)
+ def perform(args)
end
end
class IdentifiedRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_hour => 10
- @queue = 'normal'
+ queue_as 'normal'
def self.restriction_identifier(*args)
[self.to_s, args.first].join(":")
end
- def self.perform(*args)
+ def perform(args)
end
end
class ConcurrentRestrictionJob < Resque::Plugins::RestrictionJob
restrict :concurrent => 1
- @queue = 'normal'
+ queue_as 'normal'
- def self.perform(*args)
+ def perform(args)
sleep 0.2
end
end
class MultipleRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_hour => 10, :per_300 => 2
- @queue = 'normal'
+ queue_as 'normal'
- def self.perform(args)
+ def perform(args)
end
end
class MultiCallRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_hour => 10
restrict :per_300 => 2
- @queue = 'normal'
+ queue_as 'normal'
- def self.perform(args)
+ def perform(args)
end
-end
+end
\ No newline at end of file