require 'test_helper' class DummyDefaultWorker < Messaging::Worker end module Dummy class DefaultWorker < Messaging::Worker end end class DummyDefaultWorkerWithSpecifiedNames < Messaging::Worker address :MyAddressName queue :MyQueueName end module Messaging class WorkerManagerTest < ActiveSupport::TestCase context 'a default worker' do setup do @worker = DummyDefaultWorker.new @worker.message = 'foo' @worker.session = 'dummy session' @worker.thread_number = 4 end should "have address and queue names derived from it's class name" do assert_equal(@worker.address_name, 'DummyDefault') assert_equal(@worker.queue_name, 'DummyDefault') assert_equal(@worker.message, 'foo') assert_equal(@worker.session, 'dummy session') assert_equal(@worker.thread_number, 4) end end context 'a default worker in a namespace' do setup do @worker = Dummy::DefaultWorker.new end should "have address and queue names derived from it's class name" do assert_equal(@worker.address_name, 'Dummy_Default') assert_equal(@worker.queue_name, 'Dummy_Default') end end context 'a worker with specified names' do setup do @worker = DummyDefaultWorkerWithSpecifiedNames.new end should "have address and queue names matching the specified names" do assert_equal(@worker.address_name, 'MyAddressName') assert_equal(@worker.queue_name, 'MyQueueName') end end end end