-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathclient_spec.rb
759 lines (645 loc) · 25.7 KB
/
client_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
require 'base64'
require 'rbnacl'
require 'em-http'
require 'spec_helper'
encryption_master_key = RbNaCl::Random.random_bytes(32)
describe Pusher do
# The behaviour should be the same when using the Client object, or the
# 'global' client delegated through the Pusher class
[lambda { Pusher }, lambda { Pusher::Client.new }].each do |client_gen|
before :each do
@client = client_gen.call
end
describe 'default configuration' do
it 'should be preconfigured for api host' do
expect(@client.host).to eq('api-mt1.pusher.com')
end
it 'should be preconfigured for port 443' do
expect(@client.port).to eq(443)
end
it 'should use standard logger if no other logger if defined' do
Pusher.logger.debug('foo')
expect(Pusher.logger).to be_kind_of(Logger)
end
end
describe 'logging configuration' do
it "can be configured to use any logger" do
logger = double("ALogger")
expect(logger).to receive(:debug).with('foo')
Pusher.logger = logger
Pusher.logger.debug('foo')
Pusher.logger = nil
end
end
describe "configuration using url" do
it "should be possible to configure everything by setting the url" do
@client.url = "test://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
expect(@client.scheme).to eq('test')
expect(@client.host).to eq('api.staging.pusherapp.com')
expect(@client.port).to eq(8080)
expect(@client.key).to eq('somekey')
expect(@client.secret).to eq('somesecret')
expect(@client.app_id).to eq('87')
end
it "should override scheme and port when setting encrypted=true after url" do
@client.url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
@client.encrypted = true
expect(@client.scheme).to eq('https')
expect(@client.port).to eq(443)
end
it "should fail on bad urls" do
expect { @client.url = "gopher/somekey:somesecret@://api.staging.pusherapp.co://m:8080\apps\87" }.to raise_error(URI::InvalidURIError)
end
it "should raise exception if app_id is not configured" do
@client.app_id = nil
expect {
@client.url
}.to raise_error(Pusher::ConfigurationError)
end
end
describe 'configuring the cluster' do
it 'should set a new default host' do
@client.cluster = 'eu'
expect(@client.host).to eq('api-eu.pusher.com')
end
it 'should handle nil gracefully' do
@client.cluster = nil
expect(@client.host).to eq('api-mt1.pusher.com')
end
it 'should handle empty string' do
@client.cluster = ""
expect(@client.host).to eq('api-mt1.pusher.com')
end
it 'should be overridden by host if it comes after' do
@client.cluster = 'eu'
@client.host = 'api.staging.pusher.com'
expect(@client.host).to eq('api.staging.pusher.com')
end
it 'should be overridden by url if it comes after' do
@client.cluster = 'eu'
@client.url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
expect(@client.host).to eq('api.staging.pusherapp.com')
end
it 'should override the url configuration if it comes after' do
@client.url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
@client.cluster = 'eu'
expect(@client.host).to eq('api-eu.pusher.com')
end
it 'should override the host configuration if it comes after' do
@client.host = 'api.staging.pusher.com'
@client.cluster = 'eu'
expect(@client.host).to eq('api-eu.pusher.com')
end
end
describe 'configuring TLS' do
it 'should set port and scheme if "use_tls" disabled' do
client = Pusher::Client.new({
:use_tls => false,
})
expect(client.scheme).to eq('http')
expect(client.port).to eq(80)
end
it 'should set port and scheme if "encrypted" disabled' do
client = Pusher::Client.new({
:encrypted => false,
})
expect(client.scheme).to eq('http')
expect(client.port).to eq(80)
end
it 'should use TLS port and scheme if "encrypted" or "use_tls" are not set' do
client = Pusher::Client.new
expect(client.scheme).to eq('https')
expect(client.port).to eq(443)
end
it 'should override port if "use_tls" option set but a different port is specified' do
client = Pusher::Client.new({
:use_tls => true,
:port => 8443
})
expect(client.scheme).to eq('https')
expect(client.port).to eq(8443)
end
it 'should override port if "use_tls" option set but a different port is specified' do
client = Pusher::Client.new({
:use_tls => false,
:port => 8000
})
expect(client.scheme).to eq('http')
expect(client.port).to eq(8000)
end
end
describe 'configuring a http proxy' do
it "should be possible to configure everything by setting the http_proxy" do
@client.http_proxy = 'http://someuser:somepassword@proxy.host.com:8080'
expect(@client.proxy).to eq({:scheme => 'http', :host => 'proxy.host.com', :port => 8080, :user => 'someuser', :password => 'somepassword'})
end
end
describe 'configuring from env' do
after do
ENV['PUSHER_URL'] = nil
end
it "works" do
url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
ENV['PUSHER_URL'] = url
client = Pusher::Client.from_env
expect(client.key).to eq("somekey")
expect(client.secret).to eq("somesecret")
expect(client.app_id).to eq("87")
expect(client.url.to_s).to eq("http://api.staging.pusherapp.com:8080/apps/87")
end
end
describe 'configuring from url' do
it "works" do
url = "http://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
client = Pusher::Client.from_url(url)
expect(client.key).to eq("somekey")
expect(client.secret).to eq("somesecret")
expect(client.app_id).to eq("87")
expect(client.url.to_s).to eq("http://api.staging.pusherapp.com:8080/apps/87")
end
end
describe 'can set encryption_master_key_base64' do
it "sets encryption_master_key" do
@client.encryption_master_key_base64 =
Base64.strict_encode64(encryption_master_key)
expect(@client.encryption_master_key).to eq(encryption_master_key)
end
end
describe 'when configured' do
before :each do
@client.app_id = '20'
@client.key = '12345678900000001'
@client.secret = '12345678900000001'
@client.encryption_master_key_base64 =
Base64.strict_encode64(encryption_master_key)
end
describe '#[]' do
before do
@channel = @client['test_channel']
end
it 'should return a channel' do
expect(@channel).to be_kind_of(Pusher::Channel)
end
it "should raise exception if app_id is not configured" do
@client.app_id = nil
expect {
@channel.trigger!('foo', 'bar')
}.to raise_error(Pusher::ConfigurationError)
end
end
describe '#channels' do
it "should call the correct URL and symbolise response correctly" do
api_path = %r{/apps/20/channels}
stub_request(:get, api_path).to_return({
:status => 200,
:body => MultiJson.encode('channels' => {
"channel1" => {},
"channel2" => {}
})
})
expect(@client.channels).to eq({
:channels => {
"channel1" => {},
"channel2" => {}
}
})
end
end
describe '#channel_info' do
it "should call correct URL and symbolise response" do
api_path = %r{/apps/20/channels/mychannel}
stub_request(:get, api_path).to_return({
:status => 200,
:body => MultiJson.encode({
'occupied' => false,
})
})
expect(@client.channel_info('mychannel')).to eq({
:occupied => false,
})
end
end
describe '#channel_users' do
it "should call correct URL and symbolise response" do
api_path = %r{/apps/20/channels/mychannel/users}
stub_request(:get, api_path).to_return({
:status => 200,
:body => MultiJson.encode({
'users' => [{ 'id' => 1 }]
})
})
expect(@client.channel_users('mychannel')).to eq({
:users => [{ 'id' => 1}]
})
end
end
describe '#authenticate' do
before :each do
@custom_data = {:uid => 123, :info => {:name => 'Foo'}}
end
it 'should return a hash with signature including custom data and data as json string' do
allow(MultiJson).to receive(:encode).with(@custom_data).and_return 'a json string'
response = @client.authenticate('test_channel', '1.1', @custom_data)
expect(response).to eq({
:auth => "12345678900000001:#{hmac(@client.secret, "1.1:test_channel:a json string")}",
:channel_data => 'a json string'
})
end
it 'should include a shared_secret if the private-encrypted channel' do
allow(MultiJson).to receive(:encode).with(@custom_data).and_return 'a json string'
@client.instance_variable_set(:@encryption_master_key, '3W1pfB/Etr+ZIlfMWwZP3gz8jEeCt4s2pe6Vpr+2c3M=')
response = @client.authenticate('private-encrypted-test_channel', '1.1', @custom_data)
expect(response).to eq({
:auth => "12345678900000001:#{hmac(@client.secret, "1.1:private-encrypted-test_channel:a json string")}",
:shared_secret => "o0L3QnIovCeRC8KTD8KBRlmi31dGzHVS2M93uryqDdw=",
:channel_data => 'a json string'
})
end
end
describe '#authenticate_user' do
before :each do
@user_data = {:id => '123', :foo => { :name => 'Bar' }}
end
it 'should return a hash with signature including custom data and data as json string' do
allow(MultiJson).to receive(:encode).with(@user_data).and_return 'a json string'
response = @client.authenticate_user('1.1', @user_data)
expect(response).to eq({
:auth => "12345678900000001:#{hmac(@client.secret, "1.1::user::a json string")}",
:user_data => 'a json string'
})
end
end
describe '#trigger' do
before :each do
@api_path = %r{/apps/20/events}
stub_request(:post, @api_path).to_return({
:status => 200,
:body => MultiJson.encode({})
})
end
it "should call correct URL" do
expect(@client.trigger(['mychannel'], 'event', {'some' => 'data'})).
to eq({})
end
it "should not allow too many channels" do
expect {
@client.trigger((0..101).map{|i| 'mychannel#{i}'},
'event', {'some' => 'data'}, {
:socket_id => "12.34"
})}.to raise_error(Pusher::Error)
end
it "should pass any parameters in the body of the request" do
@client.trigger(['mychannel', 'c2'], 'event', {'some' => 'data'}, {
:socket_id => "12.34"
})
expect(WebMock).to have_requested(:post, @api_path).with { |req|
parsed = MultiJson.decode(req.body)
expect(parsed["name"]).to eq('event')
expect(parsed["channels"]).to eq(["mychannel", "c2"])
expect(parsed["socket_id"]).to eq('12.34')
}
end
it "should convert non string data to JSON before posting" do
@client.trigger(['mychannel'], 'event', {'some' => 'data'})
expect(WebMock).to have_requested(:post, @api_path).with { |req|
expect(MultiJson.decode(req.body)["data"]).to eq('{"some":"data"}')
}
end
it "should accept a single channel as well as an array" do
@client.trigger('mychannel', 'event', {'some' => 'data'})
expect(WebMock).to have_requested(:post, @api_path).with { |req|
expect(MultiJson.decode(req.body)["channels"]).to eq(['mychannel'])
}
end
%w[app_id key secret].each do |key|
it "should fail in missing #{key}" do
@client.public_send("#{key}=", nil)
expect {
@client.trigger('mychannel', 'event', {'some' => 'data'})
}.to raise_error(Pusher::ConfigurationError)
expect(WebMock).not_to have_requested(:post, @api_path).with { |req|
expect(MultiJson.decode(req.body)["channels"]).to eq(['mychannel'])
}
end
end
it "should fail to publish to encrypted channels when missing key" do
@client.encryption_master_key_base64 = nil
expect {
@client.trigger('private-encrypted-channel', 'event', {'some' => 'data'})
}.to raise_error(Pusher::ConfigurationError)
expect(WebMock).not_to have_requested(:post, @api_path)
end
it "should fail to publish to multiple channels if one is encrypted" do
expect {
@client.trigger(
['private-encrypted-channel', 'some-other-channel'],
'event',
{'some' => 'data'},
)
}.to raise_error(Pusher::Error)
expect(WebMock).not_to have_requested(:post, @api_path)
end
it "should encrypt publishes to encrypted channels" do
@client.trigger(
'private-encrypted-channel',
'event',
{'some' => 'data'},
)
expect(WebMock).to have_requested(:post, @api_path).with { |req|
data = MultiJson.decode(MultiJson.decode(req.body)["data"])
key = RbNaCl::Hash.sha256(
'private-encrypted-channel' + encryption_master_key
)
expect(MultiJson.decode(RbNaCl::SecretBox.new(key).decrypt(
Base64.strict_decode64(data["nonce"]),
Base64.strict_decode64(data["ciphertext"]),
))).to eq({ 'some' => 'data' })
}
end
end
describe '#trigger_batch' do
before :each do
@api_path = %r{/apps/20/batch_events}
stub_request(:post, @api_path).to_return({
:status => 200,
:body => MultiJson.encode({})
})
end
it "should call correct URL" do
expect(@client.trigger_batch(channel: 'mychannel', name: 'event', data: {'some' => 'data'})).
to eq({})
end
it "should convert non string data to JSON before posting" do
@client.trigger_batch(
{channel: 'mychannel', name: 'event', data: {'some' => 'data'}},
{channel: 'mychannel', name: 'event', data: 'already encoded'},
)
expect(WebMock).to have_requested(:post, @api_path).with { |req|
parsed = MultiJson.decode(req.body)
expect(parsed).to eq(
"batch" => [
{ "channel" => "mychannel", "name" => "event", "data" => "{\"some\":\"data\"}"},
{ "channel" => "mychannel", "name" => "event", "data" => "already encoded"}
]
)
}
end
it "should fail to publish to encrypted channels when missing key" do
@client.encryption_master_key_base64 = nil
expect {
@client.trigger_batch(
{
channel: 'private-encrypted-channel',
name: 'event',
data: {'some' => 'data'},
},
{channel: 'mychannel', name: 'event', data: 'already encoded'},
)
}.to raise_error(Pusher::ConfigurationError)
expect(WebMock).not_to have_requested(:post, @api_path)
end
it "should encrypt publishes to encrypted channels" do
@client.trigger_batch(
{
channel: 'private-encrypted-channel',
name: 'event',
data: {'some' => 'data'},
},
{channel: 'mychannel', name: 'event', data: 'already encoded'},
)
expect(WebMock).to have_requested(:post, @api_path).with { |req|
batch = MultiJson.decode(req.body)["batch"]
expect(batch.length).to eq(2)
expect(batch[0]["channel"]).to eq("private-encrypted-channel")
expect(batch[0]["name"]).to eq("event")
data = MultiJson.decode(batch[0]["data"])
key = RbNaCl::Hash.sha256(
'private-encrypted-channel' + encryption_master_key
)
expect(MultiJson.decode(RbNaCl::SecretBox.new(key).decrypt(
Base64.strict_decode64(data["nonce"]),
Base64.strict_decode64(data["ciphertext"]),
))).to eq({ 'some' => 'data' })
expect(batch[1]["channel"]).to eq("mychannel")
expect(batch[1]["name"]).to eq("event")
expect(batch[1]["data"]).to eq("already encoded")
}
end
end
describe '#trigger_async' do
before :each do
@api_path = %r{/apps/20/events}
stub_request(:post, @api_path).to_return({
:status => 200,
:body => MultiJson.encode({})
})
end
it "should call correct URL" do
EM.run {
@client.trigger_async('mychannel', 'event', {'some' => 'data'}).callback { |r|
expect(r).to eq({})
EM.stop
}
}
end
it "should pass any parameters in the body of the request" do
EM.run {
@client.trigger_async('mychannel', 'event', {'some' => 'data'}, {
:socket_id => "12.34"
}).callback {
expect(WebMock).to have_requested(:post, @api_path).with { |req|
expect(MultiJson.decode(req.body)["socket_id"]).to eq('12.34')
}
EM.stop
}
}
end
it "should convert non string data to JSON before posting" do
EM.run {
@client.trigger_async('mychannel', 'event', {'some' => 'data'}).callback {
expect(WebMock).to have_requested(:post, @api_path).with { |req|
expect(MultiJson.decode(req.body)["data"]).to eq('{"some":"data"}')
}
EM.stop
}
}
end
end
[:get, :post].each do |verb|
describe "##{verb}" do
before :each do
@url_regexp = %r{api-mt1.pusher.com}
stub_request(verb, @url_regexp).
to_return(:status => 200, :body => "{}")
end
let(:call_api) { @client.send(verb, '/path') }
it "should use https by default" do
call_api
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
end
it "should use https if configured" do
@client.encrypted = false
call_api
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
end
it "should format the respose hash with symbols at first level" do
stub_request(verb, @url_regexp).to_return({
:status => 200,
:body => MultiJson.encode({'something' => {'a' => 'hash'}})
})
expect(call_api).to eq({
:something => {'a' => 'hash'}
})
end
it "should catch all http exceptions and raise a Pusher::HTTPError wrapping the original error" do
stub_request(verb, @url_regexp).to_raise(HTTPClient::TimeoutError)
error = nil
begin
call_api
rescue => e
error = e
end
expect(error.class).to eq(Pusher::HTTPError)
expect(error).to be_kind_of(Pusher::Error)
expect(error.message).to eq('Exception from WebMock (HTTPClient::TimeoutError)')
expect(error.original_error.class).to eq(HTTPClient::TimeoutError)
end
it "should raise Pusher::Error if call returns 400" do
stub_request(verb, @url_regexp).to_return({:status => 400})
expect { call_api }.to raise_error(Pusher::Error)
end
it "should raise AuthenticationError if pusher returns 401" do
stub_request(verb, @url_regexp).to_return({:status => 401})
expect { call_api }.to raise_error(Pusher::AuthenticationError)
end
it "should raise Pusher::Error if pusher returns 404" do
stub_request(verb, @url_regexp).to_return({:status => 404})
expect { call_api }.to raise_error(Pusher::Error, '404 Not found (/apps/20/path)')
end
it "should raise Pusher::Error if pusher returns 407" do
stub_request(verb, @url_regexp).to_return({:status => 407})
expect { call_api }.to raise_error(Pusher::Error, 'Proxy Authentication Required')
end
it "should raise Pusher::Error if pusher returns 413" do
stub_request(verb, @url_regexp).to_return({:status => 413})
expect { call_api }.to raise_error(Pusher::Error, 'Payload Too Large > 10KB')
end
it "should raise Pusher::Error if pusher returns 500" do
stub_request(verb, @url_regexp).to_return({:status => 500, :body => "some error"})
expect { call_api }.to raise_error(Pusher::Error, 'Unknown error (status code 500): some error')
end
end
end
describe "async calling without eventmachine" do
[[:get, :get_async], [:post, :post_async]].each do |verb, method|
describe "##{method}" do
before :each do
@url_regexp = %r{api-mt1.pusher.com}
stub_request(verb, @url_regexp).
to_return(:status => 200, :body => "{}")
end
let(:call_api) {
@client.send(method, '/path').tap { |c|
# Allow the async thread (inside httpclient) to run
while !c.finished?
sleep 0.01
end
}
}
it "should use https by default" do
call_api
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
end
it "should use http if configured" do
@client.encrypted = false
call_api
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
end
# Note that the raw httpclient connection object is returned and
# the response isn't handled (by handle_response) in the normal way.
it "should return a httpclient connection object" do
connection = call_api
expect(connection.finished?).to be_truthy
response = connection.pop
expect(response.status).to eq(200)
expect(response.body.read).to eq("{}")
end
end
end
end
describe "async calling with eventmachine" do
[[:get, :get_async], [:post, :post_async]].each do |verb, method|
describe "##{method}" do
before :each do
@url_regexp = %r{api-mt1.pusher.com}
stub_request(verb, @url_regexp).
to_return(:status => 200, :body => "{}")
end
let(:call_api) { @client.send(method, '/path') }
it "should use https by default" do
EM.run {
call_api.callback {
expect(WebMock).to have_requested(verb, %r{https://api-mt1.pusher.com/apps/20/path})
EM.stop
}
}
end
it "should use http if configured" do
EM.run {
@client.encrypted = false
call_api.callback {
expect(WebMock).to have_requested(verb, %r{http://api-mt1.pusher.com})
EM.stop
}
}
end
it "should format the respose hash with symbols at first level" do
EM.run {
stub_request(verb, @url_regexp).to_return({
:status => 200,
:body => MultiJson.encode({'something' => {'a' => 'hash'}})
})
call_api.callback { |response|
expect(response).to eq({
:something => {'a' => 'hash'}
})
EM.stop
}
}
end
it "should errback with Pusher::Error on unsuccessful response" do
EM.run {
stub_request(verb, @url_regexp).to_return({:status => 400})
call_api.errback { |e|
expect(e.class).to eq(Pusher::Error)
EM.stop
}.callback {
fail
}
}
end
end
end
end
end
end
describe 'configuring cluster' do
it 'should allow clients to specify the cluster only with the default host' do
client = Pusher::Client.new({
:scheme => 'http',
:cluster => 'eu',
:port => 80
})
expect(client.host).to eq('api-eu.pusher.com')
end
it 'should always have host override any supplied cluster value' do
client = Pusher::Client.new({
:scheme => 'http',
:host => 'api.staging.pusherapp.com',
:cluster => 'eu',
:port => 80
})
expect(client.host).to eq('api.staging.pusherapp.com')
end
end
end