boss_queue 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
data/boss_queue.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "boss_queue"
8
- s.version = "0.1.8"
8
+ s.version = "0.1.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Nelson"]
@@ -39,12 +39,15 @@ class BossQueue
39
39
  end
40
40
 
41
41
  def self.work
42
+ work_done = false
42
43
  self.sqs_queue.receive_message do |job_id|
43
44
  # When a block is given, each message is yielded to the block and then deleted as long as the block exits normally - http://docs.aws.amazon.com/AWSRubySDK/latest/frames.html
44
45
  job = BossQueue::Job.shard(table_name).find(job_id.body)
45
46
  job.queue_name = self.queue_name
46
47
  job.work
48
+ work_done = true
47
49
  end
50
+ work_done
48
51
  end
49
52
 
50
53
  def self.enqueue(class_or_instance, method_name, *args)
@@ -213,7 +213,7 @@ describe "BossQueue module" do
213
213
 
214
214
  @sqs_message = double('message')
215
215
  @sqs_message.stub(:body).and_return('ijk')
216
- @queue.stub(:receive_message).and_yield(@sqs_message)
216
+ @queue.stub(:receive_message)
217
217
 
218
218
  @job = double('job')
219
219
  @job.stub(:work)
@@ -227,8 +227,11 @@ describe "BossQueue module" do
227
227
  end
228
228
 
229
229
  context "when something is dequeued from SQS" do
230
- it "should use the dequeued id to retrieve a BossQueue::Job object" do
230
+ before(:each) do
231
231
  @queue.should_receive(:receive_message).and_yield(@sqs_message)
232
+ end
233
+
234
+ it "should use the dequeued id to retrieve a BossQueue::Job object" do
232
235
  shard = double('shard')
233
236
  BossQueue::Job.should_receive(:shard).with(BossQueue.table_name).and_return(shard)
234
237
  shard.should_receive(:find).with('ijk').and_return(@job)
@@ -239,6 +242,16 @@ describe "BossQueue module" do
239
242
  @job.should_receive(:work)
240
243
  BossQueue.work
241
244
  end
245
+
246
+ it "should return true" do
247
+ BossQueue.work.should be_true
248
+ end
249
+ end
250
+
251
+ context "when nothing is dequeued from SQS" do
252
+ it "should return false" do
253
+ BossQueue.work.should be_false
254
+ end
242
255
  end
243
256
  end
244
257
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boss_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: -3048139913803681453
163
+ hash: 2558686148370497532
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements: