pheme 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pheme/version.rb +1 -1
- data/pheme.gemspec +1 -0
- data/spec/logger_spec.rb +10 -0
- data/spec/message_handler_spec.rb +25 -4
- data/spec/queue_poller_spec.rb +46 -0
- data/spec/spec_helper.rb +9 -1
- data/spec/topic_publisher_spec.rb +8 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43b82532ae9c2d1e266860d9553d1b9e6c47fba937de781431f50f87921fa8b6
|
4
|
+
data.tar.gz: 14cd293a8fdbabab40154bf10a6e1cee36d4c609749a7ca4f0ee44d4df1780ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b1da30552e2ba5fb12a898c1af86a0f48654a6c3a3bca615ae00d7a762bd4a7db6f660bcfd99149d00ec0ebeaccdd4b115c06ce5233b382706045aa5d470d9e
|
7
|
+
data.tar.gz: d86bfe1b06f0d5040e4461a24bfc5cfe2e264c8014563b26c8e0e49912834f3db03286f49dd042f65b6f13a38547c8866406ff04a8f82814bfb644ef5b24c288
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 3.1.3 - 2019-02-14
|
8
|
+
### Fixed
|
9
|
+
- Increase code coverage to 100%.
|
10
|
+
|
7
11
|
## 3.1.2 - 2019-02-14
|
8
12
|
### Fixed
|
9
13
|
- Trying to recover code coverage, it only worked for first few builds.
|
data/lib/pheme/version.rb
CHANGED
data/pheme.gemspec
CHANGED
@@ -36,5 +36,6 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.add_development_dependency 'rspec-collection_matchers'
|
37
37
|
s.add_development_dependency 'rspec-its'
|
38
38
|
s.add_development_dependency 'rspec_junit_formatter', '~> 0.2'
|
39
|
+
s.add_development_dependency 'simplecov'
|
39
40
|
s.add_development_dependency 'ws-style'
|
40
41
|
end
|
data/spec/logger_spec.rb
ADDED
@@ -1,13 +1,34 @@
|
|
1
1
|
describe Pheme::MessageHandler do
|
2
2
|
before(:each) { use_default_configuration! }
|
3
|
-
let(:message) { RecursiveOpenStruct.new(status:
|
3
|
+
let(:message) { RecursiveOpenStruct.new(status: status) }
|
4
4
|
let(:timestamp) { '2018-04-17T21:45:05.915Z' }
|
5
5
|
subject { ExampleMessageHandler.new(message: message, metadata: { timestamp: timestamp }) }
|
6
6
|
|
7
7
|
describe "#handle" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
context 'complete message' do
|
9
|
+
let(:status) { 'complete' }
|
10
|
+
|
11
|
+
it "handles the message correctly" do
|
12
|
+
expect(Pheme.logger).to receive(:info).with("Done")
|
13
|
+
subject.handle
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'rejected message' do
|
18
|
+
let(:status) { 'rejected' }
|
19
|
+
|
20
|
+
it 'handles the message correctly' do
|
21
|
+
expect(Pheme.logger).to receive(:error).with("Oops")
|
22
|
+
subject.handle
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'base handler' do
|
27
|
+
subject { described_class.new(message: nil).handle }
|
28
|
+
|
29
|
+
it 'does not implement handle' do
|
30
|
+
expect { subject }.to raise_error(NotImplementedError)
|
31
|
+
end
|
11
32
|
end
|
12
33
|
end
|
13
34
|
end
|
data/spec/queue_poller_spec.rb
CHANGED
@@ -2,6 +2,14 @@ describe Pheme::QueuePoller do
|
|
2
2
|
let(:queue_url) { "https://sqs.us-east-1.amazonaws.com/whatever" }
|
3
3
|
let(:timestamp) { '2018-04-17T21:45:05.915Z' }
|
4
4
|
|
5
|
+
context 'base poller' do
|
6
|
+
subject { described_class.new(queue_url: 'https://sqs.aws.com').handle(nil, nil) }
|
7
|
+
|
8
|
+
it 'does not implement handle' do
|
9
|
+
expect { subject }.to raise_error(NotImplementedError)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
describe ".new" do
|
6
14
|
context "when initialized with valid params" do
|
7
15
|
it "does not raise an error" do
|
@@ -29,6 +37,22 @@ describe Pheme::QueuePoller do
|
|
29
37
|
ExampleQueuePoller.new(queue_url: "queue_url", sqs_client: sqs_client)
|
30
38
|
end
|
31
39
|
end
|
40
|
+
|
41
|
+
context 'received too many messages' do
|
42
|
+
let(:aws_poller) { instance_double('Aws::SQS::QueuePoller') }
|
43
|
+
let(:max_messages) { 50 }
|
44
|
+
|
45
|
+
before do
|
46
|
+
allow(Aws::SQS::QueuePoller).to receive(:new).and_return(aws_poller)
|
47
|
+
allow(aws_poller).to receive(:before_request).and_yield(OpenStruct.new(received_message_count: max_messages))
|
48
|
+
end
|
49
|
+
|
50
|
+
subject { described_class.new(queue_url: 'http://sqs.aws.com', max_messages: max_messages) }
|
51
|
+
|
52
|
+
it 'throws error' do
|
53
|
+
expect { subject }.to raise_error(UncaughtThrowError, /stop_polling/)
|
54
|
+
end
|
55
|
+
end
|
32
56
|
end
|
33
57
|
|
34
58
|
let(:poller) { ExampleQueuePoller.new(queue_url: queue_url, format: format) }
|
@@ -246,5 +270,27 @@ describe Pheme::QueuePoller do
|
|
246
270
|
subject.poll
|
247
271
|
end
|
248
272
|
end
|
273
|
+
|
274
|
+
context 'SignalException' do
|
275
|
+
let(:message) { { status: 'complete' } }
|
276
|
+
let(:notification) { { 'MessageId' => SecureRandom.uuid, 'Message' => message.to_json, 'Type' => 'Notification', 'Timestamp' => timestamp } }
|
277
|
+
let!(:queue_message) do
|
278
|
+
OpenStruct.new(
|
279
|
+
body: notification.to_json,
|
280
|
+
message_id: message_id,
|
281
|
+
)
|
282
|
+
end
|
283
|
+
|
284
|
+
before do
|
285
|
+
allow(subject.queue_poller).to receive(:poll).and_yield(queue_message)
|
286
|
+
allow(subject.queue_poller).to receive(:delete_message).and_raise(SignalException.new('KILL'))
|
287
|
+
end
|
288
|
+
|
289
|
+
subject { ExampleQueuePoller.new(queue_url: queue_url) }
|
290
|
+
|
291
|
+
it 'stops polling' do
|
292
|
+
expect { subject.poll }.to raise_error(UncaughtThrowError, /stop_polling/)
|
293
|
+
end
|
294
|
+
end
|
249
295
|
end
|
250
296
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
require 'simplecov'
|
1
2
|
require 'coveralls'
|
2
|
-
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter,
|
7
|
+
])
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter 'spec'
|
10
|
+
end
|
3
11
|
|
4
12
|
require 'rspec'
|
5
13
|
require 'rspec/its'
|
@@ -1,6 +1,14 @@
|
|
1
1
|
describe Pheme::TopicPublisher do
|
2
2
|
before(:each) { use_default_configuration! }
|
3
3
|
|
4
|
+
context 'base publisher' do
|
5
|
+
subject { described_class.new(topic_arn: 'arn::foo::bar').publish_events }
|
6
|
+
|
7
|
+
it 'does not implement handle' do
|
8
|
+
expect { subject }.to raise_error(NotImplementedError)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
describe ".new" do
|
5
13
|
context "when initialized with valid params" do
|
6
14
|
it "does not raise an error" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pheme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Graham
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0.2'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: ws-style
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,6 +252,7 @@ files:
|
|
238
252
|
- lib/pheme/version.rb
|
239
253
|
- pheme.gemspec
|
240
254
|
- spec/configuration_spec.rb
|
255
|
+
- spec/logger_spec.rb
|
241
256
|
- spec/message_handler_spec.rb
|
242
257
|
- spec/message_type/aws_event_spec.rb
|
243
258
|
- spec/message_type/sns_message_spec.rb
|
@@ -276,6 +291,7 @@ specification_version: 4
|
|
276
291
|
summary: Ruby SNS publisher + SQS poller & message handler
|
277
292
|
test_files:
|
278
293
|
- spec/configuration_spec.rb
|
294
|
+
- spec/logger_spec.rb
|
279
295
|
- spec/message_handler_spec.rb
|
280
296
|
- spec/message_type/aws_event_spec.rb
|
281
297
|
- spec/message_type/sns_message_spec.rb
|