-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconsumer_group_spec.rb
37 lines (31 loc) · 989 Bytes
/
consumer_group_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require File.dirname(__FILE__) + '/spec_helper'
class PgqGr < Pgq::ConsumerGroup
def perform_group opts; end
def hahah; end
def bla; end
end
describe Pgq::ConsumerGroup do
before :each do
@consumer = PgqGr.new
@consumer.stub!(:get_next_batch).and_return ''
@consumer.stub!(:finish_batch).and_return ''
@coder = @consumer.coder
end
it "queue_name" do
PgqGr.queue_name.should == 'gr'
end
it "should call consume" do
@consumer.should_receive(:perform_group) do |h|
ev1 = h['hahah']
ev1.size.should == 2
ev1.first.data.should == '1'
ev1.second.data.should == '3'
ev2 = h['bla']
ev2.size.should == 1
ev2.first.data.should == '2'
end
@consumer.should_receive(:get_batch_events).and_return([{'ev_type' => 'hahah', 'ev_data' => @coder.dump('1')},
{'ev_type' => 'bla', 'ev_data' => @coder.dump('2')}, {'ev_type' => 'hahah', 'ev_data' => @coder.dump('3')}])
@consumer.perform_batch
end
end