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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00c644d86dd28023ad4f19c881f9e62e4c3fc37db5145d1c74ad45ee6172febd
4
- data.tar.gz: fe23557df0047f7747f18fef98c36d758f2349cb5dd19b3aaa4c75c14f161109
3
+ metadata.gz: 43b82532ae9c2d1e266860d9553d1b9e6c47fba937de781431f50f87921fa8b6
4
+ data.tar.gz: 14cd293a8fdbabab40154bf10a6e1cee36d4c609749a7ca4f0ee44d4df1780ee
5
5
  SHA512:
6
- metadata.gz: 220fb2de76fbe6782849a23cb104128681bbd0b6510de4fc47a67d806d9752a83c4e4fa69c8e720c4630371132027fce624e381708b21be3aa0ffb99ae1faff3
7
- data.tar.gz: 7492c1a2d0550b1cdf922222afd291bd14c515d18bd680365a69a974a56380fb3f721d38a004428b963b1c34e7fcb50b1cf5173bbed777f5b5479a0508f9ffe2
6
+ metadata.gz: 1b1da30552e2ba5fb12a898c1af86a0f48654a6c3a3bca615ae00d7a762bd4a7db6f660bcfd99149d00ec0ebeaccdd4b115c06ce5233b382706045aa5d470d9e
7
+ data.tar.gz: d86bfe1b06f0d5040e4461a24bfc5cfe2e264c8014563b26c8e0e49912834f3db03286f49dd042f65b6f13a38547c8866406ff04a8f82814bfb644ef5b24c288
@@ -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.
@@ -1,3 +1,3 @@
1
1
  module Pheme
2
- VERSION = '3.1.2'.freeze
2
+ VERSION = '3.1.3'.freeze
3
3
  end
@@ -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
@@ -0,0 +1,10 @@
1
+ RSpec.describe Pheme do
2
+ describe '.log' do
3
+ let(:method) { 'info' }
4
+ let(:text) { 'Some informational message' }
5
+
6
+ subject { Pheme.log(method, text) }
7
+
8
+ it { subject }
9
+ end
10
+ end
@@ -1,13 +1,34 @@
1
1
  describe Pheme::MessageHandler do
2
2
  before(:each) { use_default_configuration! }
3
- let(:message) { RecursiveOpenStruct.new(status: "complete") }
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
- it "handles the message correctly" do
9
- expect(Pheme.logger).to receive(:info).with("Done")
10
- subject.handle
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
@@ -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
@@ -1,5 +1,13 @@
1
+ require 'simplecov'
1
2
  require 'coveralls'
2
- Coveralls.wear!
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.2
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