提交 b75bff42 编写于 作者: P Pratik Naik

Worker tests

上级 729f57af
......@@ -15,3 +15,5 @@
# Require all the stubs and models
Dir[File.dirname(__FILE__) + '/stubs/*.rb'].each {|file| require file }
Celluloid.logger = Logger.new(StringIO.new)
require 'test_helper'
class WorkerTest < ActiveSupport::TestCase
class Receiver
attr_accessor :last_action
def run
@last_action = :run
end
def process(message)
@last_action = [ :process, message ]
end
end
setup do
Celluloid.boot
@worker = ActionCable::Server::Worker.new
@receiver = Receiver.new
end
teardown do
@receiver.last_action = nil
end
test "invoke" do
@worker.invoke @receiver, :run
assert_equal :run, @receiver.last_action
end
test "invoke with arguments" do
@worker.invoke @receiver, :process, "Hello"
assert_equal [ :process, "Hello" ], @receiver.last_action
end
test "running periodic timers with a proc" do
@worker.run_periodic_timer @receiver, @receiver.method(:run)
assert_equal :run, @receiver.last_action
end
test "running periodic timers with a method" do
@worker.run_periodic_timer @receiver, :run
assert_equal :run, @receiver.last_action
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册