lapine 0.2.2 → 0.2.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
  SHA1:
3
- metadata.gz: 6ee36980b342bf290005bfe32c3645b60637fd29
4
- data.tar.gz: 4c45b563a43f1ba82017801c257304779bc87a10
3
+ metadata.gz: d72d9ebaaaca0995cdf88aa8a2741f95b17d7514
4
+ data.tar.gz: 113b59cf6d8f411b983cd1202da0c8b557b78d94
5
5
  SHA512:
6
- metadata.gz: d6b9b11710eef507aff965297bd94d35fbbaec1ea61d6c49068762c47c362d901b2fdca982217510acc6dcff18ddd140ea1a156f05fe77d7dc2cfdd6d472ae92
7
- data.tar.gz: 77230701216a54be3410548a282c67e1aa05a33a085001aef88f9d98fb8df26dfd1a24ec505e1b9072be27fa39c096fe1d8195df865a7963097cba2f9d4a00be
6
+ metadata.gz: 6fb7291e77fb106921cbd0c9036de7fee053cb6ed396d614e2d0f88d6be9bc2f9cc804f4eca77896563288708bf8da344890f28fb052a5b7a9bad9f7868d2ffc
7
+ data.tar.gz: 347b60824f615d3329b210bd7d83d2b7eeb97c86ad21d159ac6fe18464df2e35a93b045fdb49d9ad16220b34d6b36d248267de45939b6cf24d8895cc3f8e7b45
@@ -17,7 +17,7 @@ module Lapine
17
17
  option :logfile,
18
18
  short: '-l LOGFILE',
19
19
  long: '--logfile LOGFILE',
20
- description: 'where to log consumer info',
20
+ description: 'where to log consumer info (default to STDOUT)',
21
21
  required: false
22
22
 
23
23
  option :host,
@@ -5,8 +5,9 @@ module Lapine
5
5
  module Consumer
6
6
  class Dispatcher
7
7
  class DefaultErrorHandler
8
+
8
9
  def call(e, data)
9
- logger.info "Lapine::Dispatcher unable to dispatch, #{e.message}, data: #{data}"
10
+ $stderr.puts "Lapine::Dispatcher unable to dispatch, #{e.message}, data: #{data}"
10
11
  end
11
12
  end
12
13
 
@@ -47,7 +48,7 @@ module Lapine
47
48
  ret = yield
48
49
  time_end = Time.now
49
50
  duration = (time_end - time) * 1000
50
- logger.info "Processing rabbit message handler:#{delegate_class.name} duration(ms):#{duration} payload:#{json.inspect}"
51
+ logger.info "Processing rabbit message handler:#{delegate_class.name} duration(ms):#{duration} payload:#{json.inspect}"
51
52
  ret
52
53
  end
53
54
 
@@ -1,3 +1,3 @@
1
1
  module Lapine
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -12,10 +12,8 @@ RSpec.describe Lapine::Consumer::Dispatcher do
12
12
 
13
13
  let(:caught_errors) { [] }
14
14
 
15
- before do
16
- Lapine::Consumer::Dispatcher.error_handler = ->(error, data) {
17
- caught_errors << [error, data]
18
- }
15
+ after do
16
+ Lapine::Consumer::Dispatcher.error_handler = nil
19
17
  end
20
18
 
21
19
  describe "#delegation" do
@@ -43,23 +41,42 @@ RSpec.describe Lapine::Consumer::Dispatcher do
43
41
  end
44
42
 
45
43
  describe 'error cases' do
46
- context 'with invalid json' do
47
- let(:json) { 'oh boy I am not actually JSON' }
48
44
 
49
- it 'notifies the error handler with the raw payload' do
50
- dispatcher.dispatch
51
- expect(caught_errors).to include([an_instance_of(Oj::ParseError), json])
45
+ context 'custom error handler' do
46
+ before do
47
+ Lapine::Consumer::Dispatcher.error_handler = ->(error, data) {
48
+ caught_errors << [error, data]
49
+ }
50
+ end
51
+ context 'with invalid json' do
52
+ let(:json) { 'oh boy I am not actually JSON' }
53
+
54
+ it 'notifies the error handler with the raw payload' do
55
+ dispatcher.dispatch
56
+ expect(caught_errors).to include([an_instance_of(Oj::ParseError), json])
57
+ end
58
+ end
59
+
60
+ context 'with any other error' do
61
+ before { allow(dispatcher).to receive(:do_dispatch).and_raise(ArgumentError) }
62
+
63
+ it 'notifies error handler with the parsed json' do
64
+ dispatcher.dispatch
65
+ expect(caught_errors).to include([an_instance_of(ArgumentError), hash])
66
+ end
52
67
  end
53
68
  end
54
69
 
55
- context 'with any other error' do
70
+ context 'default error handler' do
56
71
  before { allow(dispatcher).to receive(:do_dispatch).and_raise(ArgumentError) }
57
72
 
58
- it 'notifies error handler with the parsed json' do
73
+ it 'notifies default error handler' do
74
+ expect($stderr).to receive(:puts)
59
75
  dispatcher.dispatch
60
- expect(caught_errors).to include([an_instance_of(ArgumentError), hash])
61
76
  end
62
77
  end
78
+
79
+
63
80
  end
64
81
  end
65
82
  end
@@ -21,5 +21,6 @@ RSpec.configure do |config|
21
21
 
22
22
  config.before :each do
23
23
  Lapine.instance_variable_set(:@config, nil)
24
+
24
25
  end
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lapine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-02 00:00:00.000000000 Z
12
+ date: 2014-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amqp