freddy 0.5.1 → 0.5.2

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: aec4d79c45cbf9bc4204b7e47cf2636e133c6db7
4
- data.tar.gz: f5ddfd889863171d89ca28e0a3eeb9c3da7cd52e
3
+ metadata.gz: 87c1ea2e30dfb3705596a40af65a95c4d722ad41
4
+ data.tar.gz: 60c14e4980b8e72cf131cb6161ebf8a6b632157a
5
5
  SHA512:
6
- metadata.gz: 3cc387f36dfb0151233444e40c0ef1a7150ef84781c98dd9e1dc32f11849bdcdf4f7ee59f3785ba47d54be9573a74a91356a27aac329d52015a6955d7150805d
7
- data.tar.gz: 7e65b4f8d86689743bc1bd12109b09e57473d02e7d1f6e713cfd86b377ebe158a6ea94cb1268b26adb708bad78a1bb825988fd066c6cb23d161b599b9886029b
6
+ metadata.gz: 68b0c2b6aa8b41ec71ead2d99e01be93e5e686aec774a6c99313e0d227196b0d56336ef255858c41916f35b72cdb946ff945723c02a270df898c13ad8f9a1ee4
7
+ data.tar.gz: 3f4a430ef425723992644418e3a526cf51bc6cca1abe7ef3043f0d9569d84953c20240541a384ddfba92ee93596e2d9ad06b7e1a9458fe26a7095b18ecfbdc47
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  else
9
9
  spec.name = "freddy"
10
10
  end
11
- spec.version = '0.5.1'
11
+ spec.version = '0.5.2'
12
12
  spec.authors = ["Urmas Talimaa"]
13
13
  spec.email = ["urmas.talimaa@gmail.com"]
14
14
  spec.description = %q{Messaging API}
@@ -19,8 +19,10 @@ class Freddy
19
19
  @mutex.sleep(timeout)
20
20
  end
21
21
 
22
- if @response.nil?
22
+ if !defined?(@response)
23
23
  raise Timeout::Error, 'execution expired'
24
+ elsif @response.nil?
25
+ raise StandardError, 'unexpected nil value for response'
24
26
  elsif @response[:error] == 'RequestTimeout'
25
27
  raise TimeoutError.new(@response)
26
28
  elsif !@delivery || @delivery.type == 'error'
@@ -35,9 +37,5 @@ class Freddy
35
37
  def to_proc
36
38
  Proc.new {|*args| self.call(*args)}
37
39
  end
38
-
39
- def filled?
40
- !@response.nil?
41
- end
42
40
  end
43
41
  end
@@ -10,4 +10,21 @@ describe Freddy::SyncResponseContainer do
10
10
  expect { subject }.to raise_error(Timeout::Error, 'execution expired')
11
11
  end
12
12
  end
13
+
14
+ context 'when nil resonse' do
15
+ let(:delivery) { {} }
16
+
17
+ before do
18
+ Thread.new do
19
+ default_sleep
20
+ container.call(nil, delivery)
21
+ end
22
+ end
23
+
24
+ it 'raises timeout error' do
25
+ expect {
26
+ container.wait_for_response(2)
27
+ }.to raise_error(StandardError, 'unexpected nil value for response')
28
+ end
29
+ end
13
30
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Reply' do
4
+ let(:freddy) { Freddy.build(logger, config) }
5
+
6
+ let(:destination) { random_destination }
7
+ let(:request_payload) { {req: 'load'} }
8
+ let(:response_payload) { {res: 'load'} }
9
+
10
+ after { freddy.close }
11
+
12
+ context 'when a synchronized request' do
13
+ before do
14
+ freddy.respond_to(destination) do |payload, msg_handler|
15
+ msg_handler.success(response_payload)
16
+ end
17
+ end
18
+
19
+ it 'sends reply' do
20
+ response = freddy.deliver_with_response(destination, request_payload)
21
+ expect(response).to eq(response_payload)
22
+ end
23
+
24
+ it 'does not send the reply to the topic queue' do
25
+ freddy.tap_into 'amq.*' do |payload|
26
+ @message_received = true
27
+ end
28
+
29
+ freddy.deliver_with_response(destination, request_payload)
30
+ default_sleep
31
+
32
+ expect(@message_received).to be_falsy
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
@@ -143,6 +143,7 @@ files:
143
143
  - spec/freddy/sync_response_container_spec.rb
144
144
  - spec/integration/concurrency_spec.rb
145
145
  - spec/integration/logging_spec.rb
146
+ - spec/integration/reply_spec.rb
146
147
  - spec/spec_helper.rb
147
148
  homepage:
148
149
  licenses:
@@ -177,4 +178,5 @@ test_files:
177
178
  - spec/freddy/sync_response_container_spec.rb
178
179
  - spec/integration/concurrency_spec.rb
179
180
  - spec/integration/logging_spec.rb
181
+ - spec/integration/reply_spec.rb
180
182
  - spec/spec_helper.rb