File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,11 @@ module Pusher
17
17
# end
18
18
class Error < RuntimeError ; end
19
19
class AuthenticationError < Error ; end
20
- class ConfigurationError < Error ; end
20
+ class ConfigurationError < Error
21
+ def initialize ( key )
22
+ super "missing key `#{ key } ' in the client configuration"
23
+ end
24
+ end
21
25
class HTTPError < Error ; attr_accessor :original_error ; end
22
26
23
27
class << self
Original file line number Diff line number Diff line change @@ -40,11 +40,14 @@ def initialize(options = {})
40
40
41
41
# @private Returns the authentication token for the client
42
42
def authentication_token
43
+ raise ConfigurationError , :key unless @key
44
+ raise ConfigurationError , :secret unless @secret
43
45
Pusher ::Signature ::Token . new ( @key , @secret )
44
46
end
45
47
46
48
# @private Builds a url for this app, optionally appending a path
47
49
def url ( path = nil )
50
+ raise ConfigurationError , :app_id unless @app_id
48
51
URI ::Generic . build ( {
49
52
:scheme => @scheme ,
50
53
:host => @host ,
@@ -186,7 +189,6 @@ def webhook(request)
186
189
# should not contain anything other than letters, numbers, or the
187
190
# characters "_\-=@,.;"
188
191
def channel ( channel_name )
189
- raise ConfigurationError , 'Missing client configuration: please check that key, secret and app_id are configured.' unless configured?
190
192
Channel . new ( url , channel_name , self )
191
193
end
192
194
Original file line number Diff line number Diff line change 58
58
it "should fail on bad urls" do
59
59
expect { @client . url = "gopher/somekey:somesecret@://api.staging.pusherapp.co://m:8080\a pps\8 7" } . to raise_error ( URI ::InvalidURIError )
60
60
end
61
+
62
+ it "should raise exception if app_id is not configured" do
63
+ @client . app_id = nil
64
+ expect {
65
+ @client . url
66
+ } . to raise_error ( Pusher ::ConfigurationError )
67
+ end
61
68
end
62
69
63
70
describe 'configuring the cluster' do
116
123
expect ( @channel ) . to be_kind_of ( Pusher ::Channel )
117
124
end
118
125
119
- %w{ app_id key secret } . each do |config |
120
- it "should raise exception if #{ config } not configured" do
121
- @client . send ( "#{ config } =" , nil )
122
- expect {
123
- @client [ 'test_channel' ]
124
- } . to raise_error ( Pusher ::ConfigurationError )
125
- end
126
+ it "should raise exception if app_id is not configured" do
127
+ @client . app_id = nil
128
+ expect {
129
+ @client [ 'test_channel' ]
130
+ } . to raise_error ( Pusher ::ConfigurationError )
126
131
end
127
132
end
128
133
You can’t perform that action at this time.
0 commit comments