fluffle 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/testing.rb +1 -0
- data/lib/fluffle/client.rb +1 -1
- data/lib/fluffle/testing.rb +34 -12
- data/lib/fluffle/version.rb +1 -1
- data/spec/client_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5873bf894f32f349386f18661620aabd487dabb9
|
4
|
+
data.tar.gz: 6f832fa861f56d4186a7e260bbed46b0233c7428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59bedfeb61ff2766100e3515dbcd75f4f240cb58febb9ceb904e9a696d305e52e894fb6aef61124a852554c09ef0fee202735cb06a85e5548b2c4888ec661446
|
7
|
+
data.tar.gz: 6a9bfdbc4940b1ff64a2536c9c65ed61fd36dde610a0a4cf1b9390a4bf7709f31a626179028df42ce0f3cd82f6111bf2ea7a368067cca6988df313f84a69168e
|
data/examples/testing.rb
CHANGED
data/lib/fluffle/client.rb
CHANGED
data/lib/fluffle/testing.rb
CHANGED
@@ -2,19 +2,35 @@ require 'concurrent'
|
|
2
2
|
|
3
3
|
module Fluffle
|
4
4
|
module Testing
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
class << self
|
6
|
+
def setup!(use_fake_thread_pool: true)
|
7
|
+
# Inject our own custom `Connectable` implementation
|
8
|
+
[Fluffle::Client, Fluffle::Server].each do |mod|
|
9
|
+
mod.include Connectable
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
Fluffle::Server.class_eval do
|
13
|
+
# Overwriting this so that we don't actually block waiting for signal
|
14
|
+
def wait_for_signal
|
15
|
+
# pass
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if use_fake_thread_pool
|
20
|
+
Fluffle::Server.class_eval do
|
21
|
+
# Wrap the `initialize` implementation to switch out the handler pool
|
22
|
+
# to a local unthreaded one
|
23
|
+
alias_method :original_initialize, :initialize
|
24
|
+
|
25
|
+
def initialize(*args)
|
26
|
+
original_initialize *args
|
27
|
+
|
28
|
+
@handler_pool = ThreadPool.new
|
29
|
+
end
|
30
|
+
end
|
15
31
|
end
|
16
32
|
end
|
17
|
-
end
|
33
|
+
end # class << self
|
18
34
|
|
19
35
|
# Patch in a new `#connect` method that injects the loopback
|
20
36
|
module Connectable
|
@@ -29,6 +45,14 @@ module Fluffle
|
|
29
45
|
end
|
30
46
|
end
|
31
47
|
|
48
|
+
# Fake thread pool that executes `#post`'ed blocks immediately in the
|
49
|
+
# current thread
|
50
|
+
class ThreadPool
|
51
|
+
def post(&block)
|
52
|
+
block.call
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
32
56
|
# Fake RabbitMQ server presented through a subset of the `Bunny`
|
33
57
|
# library's interface
|
34
58
|
class Loopback
|
@@ -130,5 +154,3 @@ module Fluffle
|
|
130
154
|
end # class LoopbackServer
|
131
155
|
end # module Testing
|
132
156
|
end # module Fluffle
|
133
|
-
|
134
|
-
Fluffle::Testing.setup!
|
data/lib/fluffle/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -71,6 +71,16 @@ describe Fluffle::Client do
|
|
71
71
|
expect(subject.call(method)).to eq(result)
|
72
72
|
end
|
73
73
|
|
74
|
+
it 'accepts null as a result' do
|
75
|
+
respond = prepare_response 'result' => nil
|
76
|
+
|
77
|
+
allow(@exchange_spy).to receive(:publish) do |payload, _opts|
|
78
|
+
respond.call Oj.load(payload)['id']
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(subject.call('something')).to eq(nil)
|
82
|
+
end
|
83
|
+
|
74
84
|
it 'raises on error from server' do
|
75
85
|
code = 1337
|
76
86
|
message = 'Uh-oh!'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluffle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dirk Gadsden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|