nebulous_stomp 1.1.5
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 +7 -0
- data/.hgignore +19 -0
- data/.hgtags +16 -0
- data/.rspec +8 -0
- data/.travis.yml +3 -0
- data/.yardoc/checksums +10 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +4 -0
- data/Guardfile +17 -0
- data/README.md +38 -0
- data/Rakefile +31 -0
- data/lib/nebulous/message.rb +368 -0
- data/lib/nebulous/nebrequest.rb +254 -0
- data/lib/nebulous/nebrequest_null.rb +39 -0
- data/lib/nebulous/param.rb +139 -0
- data/lib/nebulous/redis_handler.rb +103 -0
- data/lib/nebulous/redis_handler_null.rb +61 -0
- data/lib/nebulous/stomp_handler.rb +290 -0
- data/lib/nebulous/stomp_handler_null.rb +98 -0
- data/lib/nebulous/version.rb +5 -0
- data/lib/nebulous.rb +140 -0
- data/md/LICENSE.txt +3 -0
- data/md/nebulous_protocol.md +193 -0
- data/nebulous.gemspec +46 -0
- data/spec/doc_no_pending.rb +5 -0
- data/spec/helpers.rb +22 -0
- data/spec/message_spec.rb +575 -0
- data/spec/nebrequest_null_spec.rb +223 -0
- data/spec/nebrequest_spec.rb +241 -0
- data/spec/nebulous_spec.rb +124 -0
- data/spec/param_spec.rb +146 -0
- data/spec/redis_handler_null_spec.rb +97 -0
- data/spec/redis_handler_spec.rb +141 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/spec_helper_old.rb +19 -0
- data/spec/stomp_handler_null_spec.rb +173 -0
- data/spec/stomp_handler_spec.rb +446 -0
- data/tags +134 -0
- metadata +245 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Nebulous
|
4
|
+
|
5
|
+
require 'nebulous/nebrequest_null'
|
6
|
+
|
7
|
+
require 'nebulous/message'
|
8
|
+
#require 'nebulous/stomp_handler_null'
|
9
|
+
#require 'nebulous/redis_handler_null'
|
10
|
+
|
11
|
+
require 'pry'
|
12
|
+
|
13
|
+
|
14
|
+
describe NebRequestNull do
|
15
|
+
|
16
|
+
def new_request(target, verb, params=nil, desc=nil)
|
17
|
+
NebRequestNull.new(target, verb, params, desc)
|
18
|
+
end
|
19
|
+
|
20
|
+
def disable(thing)
|
21
|
+
Nebulous.init( :stompConnectHash => thing == :stomp ? {} : stomp_hash,
|
22
|
+
:redisConnectHash => thing == :redis ? {} : redis_hash,
|
23
|
+
:messageTimeout => 5,
|
24
|
+
:cacheTimeout => 20 )
|
25
|
+
|
26
|
+
Nebulous.add_target( :accord,
|
27
|
+
:sendQueue => "/queue/laplace.dev",
|
28
|
+
:receiveQueue => "/queue/laplace.out",
|
29
|
+
:messageTimeout => 1 )
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:stomp_hash) do
|
33
|
+
{ hosts: [{ login: 'guest',
|
34
|
+
passcode: 'guest',
|
35
|
+
host: '10.0.0.150',
|
36
|
+
port: 61613,
|
37
|
+
ssl: false }],
|
38
|
+
reliable: false }
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:redis_hash) { {host: '127.0.0.1', port: 6379, db: 0} }
|
43
|
+
|
44
|
+
before do
|
45
|
+
disable(:nothing)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
describe "#initialize" do
|
50
|
+
|
51
|
+
it "raises an exception for a bad target" do
|
52
|
+
expect{ new_request('badtarget', 'foo') }.
|
53
|
+
to raise_exception(NebulousError)
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
it "takes the timeout on the target over the default" do
|
58
|
+
expect( new_request('accord', 'foo').mTimeout ).to eq(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "falls back to the default if the timeout on the target is not set" do
|
62
|
+
Nebulous.add_target( :dracula,
|
63
|
+
:sendQueue => "/queue/laplace.dev",
|
64
|
+
:receiveQueue => "/queue/laplace.out" )
|
65
|
+
|
66
|
+
expect( new_request('dracula', 'foo').mTimeout ).to eq(5)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'doesn''t freak out if Nebulous is not "on"' do
|
70
|
+
disable(:stomp)
|
71
|
+
expect{ NebRequestNull.new('accord', 'foo', nil, nil) }.
|
72
|
+
not_to raise_exception
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
##
|
78
|
+
|
79
|
+
|
80
|
+
describe "#clear_cache" do
|
81
|
+
|
82
|
+
it 'returns self' do
|
83
|
+
r = new_request('accord', 'foo')
|
84
|
+
expect( r.clear_cache ).to eq r
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'doesn''t freak out if Redis is not connected' do
|
88
|
+
disable(:redis)
|
89
|
+
r = NebRequestNull.new( 'accord', 'foo', nil, nil)
|
90
|
+
|
91
|
+
expect{ r.clear_cache }.not_to raise_exception
|
92
|
+
expect( r.clear_cache ).to eq r
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
##
|
97
|
+
|
98
|
+
|
99
|
+
describe "#send_no_cache" do
|
100
|
+
|
101
|
+
it "returns something from STOMP" do
|
102
|
+
req = new_request('accord', 'foo')
|
103
|
+
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
104
|
+
response = req.send_no_cache
|
105
|
+
|
106
|
+
expect( response ).to be_a Nebulous::Message
|
107
|
+
expect( response.verb ).to eq('foo')
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns a nebulous timeout if there is no response' do
|
111
|
+
request = new_request('accord', 'foo')
|
112
|
+
expect{ request.send_no_cache }.
|
113
|
+
to raise_exception Nebulous::NebulousTimeout
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'returns nil if Nebulous is disabled in the config' do
|
118
|
+
disable(:stomp)
|
119
|
+
r = new_request('accord', 'foo')
|
120
|
+
|
121
|
+
expect( r.send_no_cache ).to eq nil
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
##
|
126
|
+
|
127
|
+
|
128
|
+
describe "#send" do
|
129
|
+
|
130
|
+
it "returns a Message object from STOMP the first time" do
|
131
|
+
req = new_request('accord', 'foo')
|
132
|
+
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
133
|
+
|
134
|
+
response = req.send
|
135
|
+
expect( response ).to be_a Nebulous::Message
|
136
|
+
expect( response.verb ).to eq('foo')
|
137
|
+
end
|
138
|
+
|
139
|
+
it "returns the answer from the cache if there is one" do
|
140
|
+
req = new_request('accord', 'foo')
|
141
|
+
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
142
|
+
req.insert_fake_redis('xxx', {'verb' => 'frog'}.to_json)
|
143
|
+
response = req.send
|
144
|
+
|
145
|
+
expect( response ).to be_a Nebulous::Message
|
146
|
+
expect( response.verb ).to eq('frog')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "allows you to specify a message timeout" do
|
150
|
+
req = new_request('accord', 'foo')
|
151
|
+
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
152
|
+
|
153
|
+
expect{ req.send(3) }.not_to raise_exception
|
154
|
+
end
|
155
|
+
|
156
|
+
it "allows you to specify a message timeout & cache timeout" do
|
157
|
+
req = new_request('accord', 'foo')
|
158
|
+
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
159
|
+
|
160
|
+
expect{ req.send(3, 120) }.not_to raise_exception
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'returns a nebulous timeout if there is no response' do
|
164
|
+
req = new_request('accord', 'foo')
|
165
|
+
expect{ req.send }.to raise_exception Nebulous::NebulousTimeout
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'still works if Redis is turned off in the config' do
|
169
|
+
disable(:redis)
|
170
|
+
r = new_request('accord', 'tom')
|
171
|
+
r.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
172
|
+
|
173
|
+
response = r.send
|
174
|
+
expect( response ).to be_a Nebulous::Message
|
175
|
+
expect( response.verb ).to eq('foo')
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'returns nil if Nebulous is disabled in the config' do
|
179
|
+
disable(:stomp)
|
180
|
+
r = new_request('accord', 'foo')
|
181
|
+
|
182
|
+
expect( r.send ).to eq nil
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
##
|
187
|
+
|
188
|
+
|
189
|
+
describe '#redis_on?' do
|
190
|
+
|
191
|
+
it 'is true if there is a redis connection hash' do
|
192
|
+
request = new_request('accord', 'foo')
|
193
|
+
expect( request.redis_on? ).to be_truthy
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'is false if there is no redis connection hash' do
|
197
|
+
disable(:redis)
|
198
|
+
r = new_request('accord', 'foo')
|
199
|
+
expect( r.redis_on? ).to be_falsy
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
##
|
204
|
+
|
205
|
+
|
206
|
+
describe '#nebulous_on?' do
|
207
|
+
|
208
|
+
it 'is true if there is a nebulous connection hash' do
|
209
|
+
r = new_request('accord', 'foo')
|
210
|
+
expect( r.nebulous_on? ).to be_truthy
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'is false if there is no nebulous connection hash' do
|
214
|
+
disable(:stomp)
|
215
|
+
r = new_request('accord', 'foo')
|
216
|
+
expect( r.nebulous_on? ).to be_falsy
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
##
|
221
|
+
|
222
|
+
end # of NebRequestNull
|
223
|
+
|
@@ -0,0 +1,241 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Nebulous
|
4
|
+
|
5
|
+
require 'nebulous/nebrequest'
|
6
|
+
require 'nebulous/message'
|
7
|
+
require 'nebulous/stomp_handler_null'
|
8
|
+
require 'nebulous/redis_handler_null'
|
9
|
+
|
10
|
+
require 'pry'
|
11
|
+
|
12
|
+
|
13
|
+
describe NebRequest do
|
14
|
+
|
15
|
+
let(:stomp_hash) do
|
16
|
+
{ hosts: [{ login: 'guest',
|
17
|
+
passcode: 'guest',
|
18
|
+
host: '10.0.0.150',
|
19
|
+
port: 61613,
|
20
|
+
ssl: false }],
|
21
|
+
reliable: false }
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:redis_hash) { {host: '127.0.0.1', port: 6379, db: 0} }
|
26
|
+
|
27
|
+
let(:stomp_h) { StompHandlerNull.new(stomp_hash) }
|
28
|
+
let(:redis_h) { RedisHandlerNull.new(redis_hash) }
|
29
|
+
|
30
|
+
def new_request(target, verb, params=nil, desc=nil)
|
31
|
+
NebRequest.new(target, verb, params, desc, stomp_h, redis_h)
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
Nebulous.init( :stompConnectHash => @stomph,
|
36
|
+
:redisConnectHash => @redish,
|
37
|
+
:messageTimeout => 5,
|
38
|
+
:cacheTimeout => 20 )
|
39
|
+
|
40
|
+
Nebulous.add_target( :accord,
|
41
|
+
:sendQueue => "/queue/laplace.dev",
|
42
|
+
:receiveQueue => "/queue/laplace.out",
|
43
|
+
:messageTimeout => 1 )
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
describe "#initialize" do
|
49
|
+
|
50
|
+
it "raises an exception for a bad target" do
|
51
|
+
expect{ new_request('badtarget', 'foo') }.
|
52
|
+
to raise_exception(NebulousError)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
it "takes the timeout on the target over the default" do
|
57
|
+
expect( new_request('accord', 'foo').mTimeout ).to eq(1)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "falls back to the default if the timeout on the target is not set" do
|
61
|
+
Nebulous.add_target( :dracula,
|
62
|
+
:sendQueue => "/queue/laplace.dev",
|
63
|
+
:receiveQueue => "/queue/laplace.out" )
|
64
|
+
|
65
|
+
expect( new_request('dracula', 'foo').mTimeout ).to eq(5)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'doesn\'t freak out if Nebulous is not "on"' do
|
69
|
+
sh = StompHandlerNull.new({})
|
70
|
+
|
71
|
+
expect{ NebRequest.new('accord','foo',nil,nil,sh,redis_h) }.
|
72
|
+
not_to raise_exception
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
##
|
78
|
+
|
79
|
+
|
80
|
+
describe "#clear_cache" do
|
81
|
+
|
82
|
+
it "removes the redis cache for a single request" do
|
83
|
+
redis_h.insert_fake('foo', 'bar')
|
84
|
+
expect( redis_h ).to receive(:del).with( {"verb"=>"foo"}.to_json )
|
85
|
+
|
86
|
+
new_request('accord', 'foo').clear_cache
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'returns self' do
|
90
|
+
r = new_request('accord', 'foo')
|
91
|
+
expect( r.clear_cache ).to eq r
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'doesn\'t freak out if Redis is not connected' do
|
95
|
+
rh = RedisHandlerNull.new({})
|
96
|
+
r = NebRequest.new( 'accord', 'foo', nil, nil, stomp_h, rh)
|
97
|
+
|
98
|
+
expect{ r.clear_cache }.not_to raise_exception
|
99
|
+
expect( r.clear_cache ).to eq r
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
##
|
104
|
+
|
105
|
+
|
106
|
+
describe "#send_no_cache" do
|
107
|
+
|
108
|
+
it "returns something from STOMP" do
|
109
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
110
|
+
request = new_request('accord', 'foo')
|
111
|
+
response = request.send_no_cache
|
112
|
+
|
113
|
+
expect( response ).to be_a Nebulous::Message
|
114
|
+
expect( response.verb ).to eq('foo')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'returns a nebulous timeout if there is no response' do
|
118
|
+
request = new_request('accord', 'foo')
|
119
|
+
expect{ request.send_no_cache }.
|
120
|
+
to raise_exception Nebulous::NebulousTimeout
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns nil if Nebulous is disabled in the config' do
|
125
|
+
sh = StompHandlerNull.new({})
|
126
|
+
r = NebRequest.new('accord', 'foo', nil, nil, sh, redis_h)
|
127
|
+
|
128
|
+
expect( r.send_no_cache ).to eq nil
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
##
|
133
|
+
|
134
|
+
|
135
|
+
describe "#send" do
|
136
|
+
|
137
|
+
it "returns a Message object from STOMP the first time" do
|
138
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
139
|
+
request = new_request('accord', 'foo')
|
140
|
+
|
141
|
+
response = request.send
|
142
|
+
expect( response ).to be_a Nebulous::Message
|
143
|
+
expect( response.verb ).to eq('foo')
|
144
|
+
end
|
145
|
+
|
146
|
+
it "returns the answer from the cache the second time" do
|
147
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
148
|
+
redis_h.insert_fake('xxx', {'verb' => 'frog'}.to_json)
|
149
|
+
|
150
|
+
# First time
|
151
|
+
request = new_request('accord', 'foo')
|
152
|
+
response = request.send
|
153
|
+
|
154
|
+
# Second time
|
155
|
+
request = new_request('accord', 'foo')
|
156
|
+
response = request.send
|
157
|
+
|
158
|
+
expect( response ).to be_a Nebulous::Message
|
159
|
+
expect( response.verb ).to eq('frog')
|
160
|
+
end
|
161
|
+
|
162
|
+
it "allows you to specify a message timeout" do
|
163
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
164
|
+
request = new_request('accord', 'foo')
|
165
|
+
|
166
|
+
expect{ request.send(3) }.not_to raise_exception
|
167
|
+
end
|
168
|
+
|
169
|
+
it "allows you to specify a message timeout & cache timeout" do
|
170
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
171
|
+
request = new_request('accord', 'foo')
|
172
|
+
|
173
|
+
expect{ request.send(3, 120) }.not_to raise_exception
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'returns a nebulous timeout if there is no response' do
|
177
|
+
request = new_request('accord', 'foo')
|
178
|
+
expect{ request.send }.to raise_exception Nebulous::NebulousTimeout
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'still works if Redis is turned off in the config' do
|
182
|
+
rh = RedisHandlerNull.new({})
|
183
|
+
stomp_h.insert_fake( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
184
|
+
r = NebRequest.new('accord', 'tom', nil, nil, stomp_h, rh)
|
185
|
+
|
186
|
+
response = r.send
|
187
|
+
expect( response ).to be_a Nebulous::Message
|
188
|
+
expect( response.verb ).to eq('foo')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'returns nil if Nebulous is disabled in the config' do
|
192
|
+
sh = StompHandlerNull.new({})
|
193
|
+
r = NebRequest.new('accord', 'foo', nil, nil, sh, redis_h)
|
194
|
+
|
195
|
+
expect( r.send ).to eq nil
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
##
|
200
|
+
|
201
|
+
|
202
|
+
describe '#redis_on?' do
|
203
|
+
|
204
|
+
it 'is true if there is a redis connection hash' do
|
205
|
+
request = new_request('accord', 'foo')
|
206
|
+
expect( request.redis_on? ).to be_truthy
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'is false if there is no redis connection hash' do
|
210
|
+
rh = RedisHandlerNull.new({})
|
211
|
+
r = NebRequest.new('accord', 'foo', nil, nil, stomp_h, rh)
|
212
|
+
|
213
|
+
expect( r.redis_on? ).to be_falsy
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
##
|
218
|
+
|
219
|
+
|
220
|
+
describe '#nebulous_on?' do
|
221
|
+
|
222
|
+
it 'is true if there is a nebulous connection hash' do
|
223
|
+
sh = StompHandlerNull.new({foo: 'bar'})
|
224
|
+
r = NebRequest.new('accord', 'foo', nil, nil, sh, redis_h)
|
225
|
+
|
226
|
+
expect( r.nebulous_on? ).to be_truthy
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'is false if there is no nebulous connection hash' do
|
230
|
+
sh = StompHandlerNull.new({})
|
231
|
+
r = NebRequest.new('accord', 'foo', nil, nil, sh, redis_h)
|
232
|
+
|
233
|
+
expect( r.nebulous_on? ).to be_falsy
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
##
|
238
|
+
|
239
|
+
|
240
|
+
end # of NebRequest
|
241
|
+
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
require 'nebulous/param'
|
6
|
+
|
7
|
+
|
8
|
+
describe Nebulous do
|
9
|
+
|
10
|
+
before { Nebulous::Param.reset }
|
11
|
+
after(:all) { Nebulous::Param.reset }
|
12
|
+
|
13
|
+
|
14
|
+
# Magically replaces the real Param module
|
15
|
+
let(:param) { class_double(Nebulous::Param).as_stubbed_const }
|
16
|
+
|
17
|
+
|
18
|
+
it 'has a version number' do
|
19
|
+
expect(Nebulous::VERSION).not_to be nil
|
20
|
+
end
|
21
|
+
##
|
22
|
+
|
23
|
+
|
24
|
+
describe "Nebulous.set_logger" do
|
25
|
+
|
26
|
+
it "calls Param.set_logger" do
|
27
|
+
l = Logger.new(STDOUT)
|
28
|
+
expect(param).to receive(:set_logger).with(l)
|
29
|
+
Nebulous.set_logger(l)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
##
|
34
|
+
|
35
|
+
|
36
|
+
describe 'Nebulous.logger' do
|
37
|
+
|
38
|
+
it 'returns the logger as set' do
|
39
|
+
l = Logger.new(STDOUT)
|
40
|
+
Nebulous.set_logger(l)
|
41
|
+
|
42
|
+
expect( Nebulous.logger ).to eq l
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'still works if no-one set the logger' do
|
46
|
+
expect{ Nebulous.logger }.not_to raise_exception
|
47
|
+
expect( Nebulous.logger ).to be_a_kind_of Logger
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
##
|
52
|
+
|
53
|
+
|
54
|
+
describe 'Nebulous.init' do
|
55
|
+
|
56
|
+
it 'calls Param.set' do
|
57
|
+
h = {one: 1, two: 2}
|
58
|
+
expect(param).to receive(:set).with(h)
|
59
|
+
Nebulous.init(h)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
##
|
64
|
+
|
65
|
+
|
66
|
+
describe 'Nebulous.add_target' do
|
67
|
+
|
68
|
+
it 'calls Param.add_target' do
|
69
|
+
t1 = :foo; t2 = {bar: 'baz'}
|
70
|
+
expect(param).to receive(:add_target).with(t1, t2)
|
71
|
+
Nebulous.add_target(t1, t2)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
##
|
76
|
+
|
77
|
+
|
78
|
+
describe 'Nebulous.on?' do
|
79
|
+
|
80
|
+
it 'should be true if there is anything in the stomp hash' do
|
81
|
+
allow(param).to receive(:get).
|
82
|
+
with(:stompConnectHash).
|
83
|
+
and_return( foo: 'bar' )
|
84
|
+
|
85
|
+
expect( Nebulous.on? ).to be_truthy
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should be false if the stomp hash is nil' do
|
89
|
+
allow(param).to receive(:get).
|
90
|
+
with(:stompConnectHash).
|
91
|
+
and_return( nil, {} )
|
92
|
+
|
93
|
+
expect( Nebulous.on? ).to be_falsy
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
##
|
99
|
+
|
100
|
+
|
101
|
+
describe 'Nebulous.redis_on?' do
|
102
|
+
|
103
|
+
it 'is true if there is anything in the Redis connection hash' do
|
104
|
+
allow(param).to receive(:get).
|
105
|
+
with(:redisConnectHash).
|
106
|
+
and_return( foo: 'bar' )
|
107
|
+
|
108
|
+
expect( Nebulous.redis_on? ).to be_truthy
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'is false if the Redis hash is nil or empty' do
|
112
|
+
allow(param).to receive(:get).
|
113
|
+
with(:redisConnectHash).
|
114
|
+
and_return( nil, {} )
|
115
|
+
|
116
|
+
expect( Nebulous.redis_on? ).to be_falsy
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
##
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|