Sha256: 66d1a266e3d5cfb00fa14ae66531cc069fee62e463ad34be89eceb517ef89298
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') require "moqueue" class SandwichWorker < Cloudist::Worker def process Cloudist.log.info(job.data.inspect) end end describe "Cloudist" do before(:each) do overload_amqp reset_broker Cloudist.remove_workers @mq = mock("MQ") @queue, @exchange = mock_queue_and_exchange('make.sandwich') @qobj = Cloudist::JobQueue.any_instance @qobj.stubs(:q).returns(@queue) @qobj.stubs(:mq).returns(@mq) @qobj.stubs(:ex).returns(@exchange) @qobj.stubs(:setup) end it "should register a worker" do Cloudist.register_worker('make.sandwich', SandwichWorker) Cloudist.workers.should have_key("make.sandwich") Cloudist.workers["make.sandwich"].size.should == 1 end it "should support handle syntax" do Cloudist.workers.should == {} Cloudist.handle('make.sandwich').with(SandwichWorker) Cloudist.workers.should have_key("make.sandwich") Cloudist.workers["make.sandwich"].size.should == 1 end # it "should support handle syntax with multiple queues" do # Cloudist.workers.should == {} # Cloudist.handle('make.sandwich', 'eat.sandwich').with(SandwichWorker) # # Cloudist.workers.should == {"make.sandwich"=>[SandwichWorker], "eat.sandwich"=>[SandwichWorker]} # end it "should call process on worker when job arrives" do job = Cloudist.enqueue('make.sandwich', {:bread => 'white'}) job.payload.published?.should be_true SandwichWorker.any_instance.expects(:process) Cloudist.handle('make.sandwich').with(SandwichWorker) Cloudist.workers.should have_key("make.sandwich") Cloudist.workers["make.sandwich"].size.should == 1 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloudist-0.2.1 | spec/cloudist_spec.rb |
cloudist-0.2.0 | spec/cloudist_spec.rb |