Sha256: ecaeb75806bead9b99c22072517af950854048c823bff2f70d97075959399009
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'spec_helper' require 'resque/rate_limited_queue' class RateLimitedTestQueueTw def self.perform(succeed) fail(Twitter::Error::TooManyRequests .new('', 'x-rate-limit-reset' => (Time.now + 60).to_i)) unless succeed end end describe Resque::Plugins::RateLimitedQueue::TwitterQueue do before do Resque::Plugins::RateLimitedQueue::TwitterQueue.stub(:paused?).and_return(false) end describe 'enqueue' do it 'enqueues to the correct queue with the correct parameters' do Resque.should_receive(:enqueue_to).with( :twitter_api, Resque::Plugins::RateLimitedQueue::TwitterQueue, RateLimitedTestQueueTw.to_s, true) Resque::Plugins::RateLimitedQueue::TwitterQueue .enqueue(RateLimitedTestQueueTw, true) end end describe 'perform' do before do Resque.inline = true end context 'with everything' do it 'calls the class with the right parameters' do RateLimitedTestQueueTw.should_receive(:perform).with('test_param') Resque::Plugins::RateLimitedQueue::TwitterQueue .enqueue(RateLimitedTestQueueTw, 'test_param') end end context 'with rate limit exception' do before do Resque::Plugins::RateLimitedQueue::TwitterQueue.stub(:rate_limited_requeue) end it 'pauses queue when request fails' do Resque::Plugins::RateLimitedQueue::TwitterQueue.should_receive(:pause_until) Resque::Plugins::RateLimitedQueue::TwitterQueue .enqueue(RateLimitedTestQueueTw, false) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
resque-rate_limited_queue-1.0.4 | spec/apis/twitter_queue_spec.rb |