I’m trying to spec this method which is attempting to connect to
beanstalkd message queue. I’m trying to figure out how to spec this so
it catches the retry without actually retrying the block forever.
Any help would be appreciated.
def get_message(name, peek=false)
get_queue(name).reserve if get_queue(name).peek_ready
rescue Beanstalk::NotConnected => e
it "should sleep for 10 seconds" do queue = mock("queue") queue.should_receive(:reserve).and_raise(Beanstalk::NotConnected) BeanstalkMessageQueue.should_receive(:get_queue).with('cheese').and_return(queue) BeanstalkMessageQueue.should_receive(:sleep).with(10).and_return(true)