freddy 0.3.4 → 0.3.5

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: bc5a587ccd4505868a43c8444abdbb376d30e124
4
- data.tar.gz: f4f09ae1d1f046689e71245b9170cf9154fa0946
3
+ metadata.gz: 593764803da4d2ba342a36a9cffcdcaa7f4feefe
4
+ data.tar.gz: 9b0707d5cbb886ccd0a030112c9ff30c8ee2d7b0
5
5
  SHA512:
6
- metadata.gz: c9e6c129c97c63e92abdb3449f127fdb3c64dcf6b73a385b3bd3acd57682f8d3ceb30850e3a38a3431cc7bd61408f2177db9f861547beed33ff58e9babc7b4ba
7
- data.tar.gz: bdcc1cbb44b821cda0494177c326eab270f254e2c0cb8988bd620f3dbb221967788c2ec58bbe23c87f416fd2f85d4d9724e80d242868fb0c47662cce64a71ec9
6
+ metadata.gz: 2c738e2e59c211ead4fcfbdd347fe4fb6f457f77bc7809698a4f6988ca3ee15522d44ba0922c2fbf3e456e9353d3bfe5571899602ae08bc3e00d30d9dcec3b4c
7
+ data.tar.gz: 062fa84e713fd6591b7c26824139e452e2981b6eb53095fe5aa09342808ce8de2de2b6e5c72afeaacf5365ae257f3389b9b8e6afed88623371643cba6efd9217
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- freddy (0.3.4)
4
+ freddy (0.3.5)
5
5
  bunny (= 1.6.3)
6
6
  hamster (~> 1.0.1.pre.rc3)
7
7
  symbolizer
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "freddy"
7
- spec.version = '0.3.4'
7
+ spec.version = '0.3.5'
8
8
  spec.authors = ["Urmas Talimaa"]
9
9
  spec.email = ["urmas.talimaa@gmail.com"]
10
10
  spec.description = %q{Messaging API}
@@ -8,11 +8,22 @@ require_relative 'freddy/request'
8
8
 
9
9
  class Freddy
10
10
  class ErrorResponse < StandardError
11
+ DEFAULT_ERROR_MESSAGE = 'Use #response to get the error response'
12
+
11
13
  attr_reader :response
12
14
 
13
15
  def initialize(response)
14
16
  @response = response
15
- super('Use #response to get the error response')
17
+ super(format_message(response) || DEFAULT_ERROR_MESSAGE)
18
+ end
19
+
20
+ private
21
+
22
+ def format_message(response)
23
+ return unless response.is_a?(Hash)
24
+
25
+ message = [response[:error], response[:message]].compact.join(': ')
26
+ message.empty? ? nil : message
16
27
  end
17
28
  end
18
29
 
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Freddy::ErrorResponse do
4
+ subject(:error) { described_class.new(input) }
5
+
6
+ context 'with an error type' do
7
+ let(:input) { {error: 'SomeError'} }
8
+
9
+ describe '#response' do
10
+ subject { error.response }
11
+
12
+ it { should eq(input) }
13
+ end
14
+
15
+ describe '#message' do
16
+ subject { error.message }
17
+
18
+ it 'uses error type as a message' do
19
+ should eq('SomeError')
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'with an error type and message' do
25
+ let(:input) { {error: 'SomeError', message: 'extra info'} }
26
+
27
+ describe '#response' do
28
+ subject { error.response }
29
+
30
+ it { should eq(input) }
31
+ end
32
+
33
+ describe '#message' do
34
+ subject { error.message }
35
+
36
+ it 'uses error type as a message' do
37
+ should eq('SomeError: extra info')
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'without an error type' do
43
+ let(:input) { {something: 'else'} }
44
+
45
+ describe '#response' do
46
+ subject { error.response }
47
+
48
+ it { should eq(input) }
49
+ end
50
+
51
+ describe '#message' do
52
+ subject { error.message }
53
+
54
+ it 'uses default error message as a message' do
55
+ should eq('Use #response to get the error response')
56
+ end
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-28 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -110,6 +110,7 @@ files:
110
110
  - lib/freddy/responder_handler.rb
111
111
  - lib/freddy/sync_response_container.rb
112
112
  - spec/freddy/consumer_spec.rb
113
+ - spec/freddy/error_response_spec.rb
113
114
  - spec/freddy/freddy_spec.rb
114
115
  - spec/freddy/message_handler_spec.rb
115
116
  - spec/freddy/request_spec.rb
@@ -137,12 +138,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  version: '0'
138
139
  requirements: []
139
140
  rubyforge_project:
140
- rubygems_version: 2.4.3
141
+ rubygems_version: 2.2.2
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: API for inter-application messaging supporting acknowledgements and request-response
144
145
  test_files:
145
146
  - spec/freddy/consumer_spec.rb
147
+ - spec/freddy/error_response_spec.rb
146
148
  - spec/freddy/freddy_spec.rb
147
149
  - spec/freddy/message_handler_spec.rb
148
150
  - spec/freddy/request_spec.rb