require File.expand_path("../../test_helper", __FILE__) class BBQueue::ConsumerTest < MiniTest::Test def test_job consumer = BBQueue::Consumer.new("default") assert_equal 3, Stalking::Consumer.instances.last.run_job("default", { "object" => BBQueue::Serializer.dump(BBQueue::TestJob.new(1, 2)) }) end def test_error logger = BBQueue::TestLogger.new consumer = BBQueue::Consumer.new("default", :logger => logger) assert_difference "logger.count", 2 do Stalking::Consumer.instances.last.run_error("Error", "default", { "object" => BBQueue::Serializer.dump(BBQueue::TestJob.new(1, 2)) }) end end def test_before logger = BBQueue::TestLogger.new consumer = BBQueue::Consumer.new("default", :logger => logger) assert_difference "logger.count" do Stalking::Consumer.instances.last.run_before("default", { "object" => BBQueue::Serializer.dump(BBQueue::TestJob.new(1, 2)) }) end end def test_after logger = BBQueue::TestLogger.new consumer = BBQueue::Consumer.new("default", :logger => logger) assert_difference "logger.count" do Stalking::Consumer.instances.last.run_after("default", { "object" => BBQueue::Serializer.dump(BBQueue::TestJob.new(1, 2)) }) end end end