1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Modern celluloid now stable for testing purposes, yay!

This commit is contained in:
Mike Perham 2013-06-07 22:15:13 -07:00
parent 1192b36554
commit 4e66339f65
3 changed files with 7 additions and 62 deletions

View file

@ -1,67 +1,7 @@
module Sidekiq
#
# Celluloid has the nasty side effect of making objects
# very hard to test because they are immediately async
# upon creation. In testing we want to just treat
# the actors as POROs.
#
# Instead of including Celluloid, we'll just stub
# out the key methods we use so that everything works
# synchronously. The alternative is no test coverage.
#
module Actor
if $TESTING
TaskThread = 0
def sleep(amount=0)
end
def after(amount=0)
end
def defer
yield
end
def current_actor
self
end
def alive?
!@dead
end
def terminate
@dead = true
end
def async
self
end
def signal(sym)
end
# we don't want to hide or catch failures in testing
def watchdog(msg)
yield
end
def self.included(klass)
class << klass
alias_method :new_link, :new
def trap_exit(meth)
end
def task_class(konstant)
end
end
end
else
def self.included(klass)
klass.send(:include, Celluloid)
end
def self.included(klass)
klass.send(:include, Celluloid)
end
end
end

View file

@ -64,6 +64,10 @@ module Sidekiq
@boss.async.processor_done(current_actor)
end
def inspect
"<Processor##{object_id.to_s(16)}>"
end
private
# We use Celluloid's defer to workaround tiny little

View file

@ -20,6 +20,7 @@ end
require 'minitest/autorun'
require 'minitest/pride'
require 'celluloid/autostart'
require 'sidekiq'
require 'sidekiq/util'
Sidekiq.logger.level = Logger::ERROR