fake_sqs 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 909e1da7c44403638eb5d95fe363a7d2c7282135
4
- data.tar.gz: 94f87e79eef035cf8c6d89f0de61d1cd4e5f951c
3
+ metadata.gz: c424f4af6489d03024c8cc27bc894df0ffd8e065
4
+ data.tar.gz: 81d0da9ebe28dd1d47808d14f91f6a0d490d0bef
5
5
  SHA512:
6
- metadata.gz: 9ace909c2bcf251ea0234b0ceb5804bf5b5780765d41ea838bff230a7a8765caa0a32b6792eace91783b8a0a73022d93bf5e5d815236e9ec1a8e8aa1f236014f
7
- data.tar.gz: 2e7baaa00ba1fe6da88e20276edad298813f7477c3be0fb82bc0c988e6ddfab7cd33ff211c058677da08b53633369b80b0ef6de3382a7bed7463d78d0af85b43
6
+ metadata.gz: 6f8286741675fb8beb9e8206ce5102bc82183386c5ea2297917fb44e9d03ff876265c1dd3c0838717fd7b34496e4de31becb0e1a7f276c155ccbf8b3619cc2cb
7
+ data.tar.gz: f0f65a2c48b86beb6a935843cff6c37fe38148a4723add4176a5c24f264ca9afd1ff5b60054ee6ad97f5b48fb89d4e8e380470a40ff537d4a57ef816de75cd50
data/bin/fake_sqs CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
3
+ lib = File.expand_path("../../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
5
6
  require 'fake_sqs'
6
7
  require 'optparse'
@@ -16,7 +16,7 @@ module FakeSQS
16
16
  results[value] = params.fetch("Attribute.#{$1}.Value")
17
17
  end
18
18
  end
19
- queue.attributes.merge!(results)
19
+ queue.add_queue_attributes(results)
20
20
  @responder.call :SetQueueAttributes
21
21
  end
22
22
 
@@ -6,16 +6,28 @@ module FakeSQS
6
6
 
7
7
  class Queue
8
8
 
9
- attr_reader :name, :messages, :message_factory, :messages_in_flight, :attributes
9
+ attr_reader :name, :messages, :message_factory, :messages_in_flight, :arn
10
10
 
11
11
  def initialize(options = {})
12
12
  @name = options.fetch("QueueName")
13
13
  @message_factory = options.fetch(:message_factory)
14
- @attributes = {}
15
- @attributes["QueueArn"] = "arn:aws:sqs:us-east-1:#{SecureRandom.hex}:#{@name}"
14
+ @arn = "arn:aws:sqs:us-east-1:#{SecureRandom.hex}:#{@name}"
15
+ @queue_attributes = {}
16
16
  reset
17
17
  end
18
18
 
19
+ def add_queue_attributes(attrs)
20
+ @queue_attributes.merge!(attrs)
21
+ end
22
+
23
+ def attributes
24
+ @queue_attributes.merge(
25
+ "QueueArn" => arn,
26
+ "ApproximateNumberOfMessages" => messages.size,
27
+ "ApproximateNumberOfMessagesNotVisible" => messages_in_flight.size,
28
+ )
29
+ end
30
+
19
31
  def send_message(options = {})
20
32
  message = message_factory.new(options)
21
33
  messages << message
@@ -1,3 +1,3 @@
1
1
  module FakeSQS
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -54,7 +54,7 @@ describe FakeSQS::Queue do
54
54
 
55
55
  sample_group.times do
56
56
  sent_first = send_message
57
- sent_second = send_message
57
+ _ = send_message
58
58
  message = receive_message.values.first
59
59
  if message == sent_first
60
60
  indexes[:first] += 1
@@ -88,10 +88,18 @@ describe FakeSQS::Queue do
88
88
  end
89
89
 
90
90
  it "keeps track of sent messages" do
91
+
91
92
  send_message
93
+
92
94
  queue.should have(0).messages_in_flight
95
+ queue.attributes["ApproximateNumberOfMessagesNotVisible"].should eq 0
96
+ queue.attributes["ApproximateNumberOfMessages"].should eq 1
97
+
93
98
  receive_message
99
+
94
100
  queue.should have(1).messages_in_flight
101
+ queue.attributes["ApproximateNumberOfMessagesNotVisible"].should eq 1
102
+ queue.attributes["ApproximateNumberOfMessages"].should eq 0
95
103
  end
96
104
 
97
105
  it "gets multiple message" do
@@ -117,7 +125,7 @@ describe FakeSQS::Queue do
117
125
  describe "#delete_message" do
118
126
 
119
127
  it "deletes by the receipt" do
120
- message = send_message
128
+ send_message
121
129
  receipt = receive_message.keys.first
122
130
 
123
131
  queue.should have(1).messages_in_flight
@@ -132,6 +140,20 @@ describe FakeSQS::Queue do
132
140
 
133
141
  end
134
142
 
143
+ describe "#add_queue_attributes" do
144
+
145
+ it "adds to it's queue attributes" do
146
+ queue.add_queue_attributes("foo" => "bar")
147
+ queue.attributes.should eq(
148
+ "foo" => "bar",
149
+ "QueueArn" => queue.arn,
150
+ "ApproximateNumberOfMessages" => 0,
151
+ "ApproximateNumberOfMessagesNotVisible" => 0
152
+ )
153
+ end
154
+
155
+ end
156
+
135
157
  def send_message(options = {})
136
158
  queue.send_message(options)
137
159
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - iain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-05 00:00:00.000000000 Z
11
+ date: 2013-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra