@@ -28,7 +28,7 @@ def stub_post_to_raise(e)
28
28
29
29
describe '#trigger!' do
30
30
it "should use @client.trigger internally" do
31
- @client . should_receive ( :trigger )
31
+ expect ( @client ) . to receive ( :trigger )
32
32
@channel . trigger ( 'new_event' , 'Some data' )
33
33
end
34
34
end
@@ -37,47 +37,47 @@ def stub_post_to_raise(e)
37
37
it "should log failure if error raised in http call" do
38
38
stub_post_to_raise ( HTTPClient ::BadResponseError )
39
39
40
- Pusher . logger . should_receive ( :error ) . with ( "Exception from WebMock (HTTPClient::BadResponseError) (Pusher::HTTPError)" )
41
- Pusher . logger . should_receive ( :debug ) #backtrace
40
+ expect ( Pusher . logger ) . to receive ( :error ) . with ( "Exception from WebMock (HTTPClient::BadResponseError) (Pusher::HTTPError)" )
41
+ expect ( Pusher . logger ) . to receive ( :debug ) #backtrace
42
42
channel = Pusher ::Channel . new ( @client . url , 'test_channel' , @client )
43
43
channel . trigger ( 'new_event' , 'Some data' )
44
44
end
45
45
46
46
it "should log failure if Pusher returns an error response" do
47
47
stub_post 401 , "some signature info"
48
- Pusher . logger . should_receive ( :error ) . with ( "some signature info (Pusher::AuthenticationError)" )
49
- Pusher . logger . should_receive ( :debug ) #backtrace
48
+ expect ( Pusher . logger ) . to receive ( :error ) . with ( "some signature info (Pusher::AuthenticationError)" )
49
+ expect ( Pusher . logger ) . to receive ( :debug ) #backtrace
50
50
channel = Pusher ::Channel . new ( @client . url , 'test_channel' , @client )
51
51
channel . trigger ( 'new_event' , 'Some data' )
52
52
end
53
53
end
54
54
55
55
describe "#initialization" do
56
56
it "should not be too long" do
57
- lambda { @client [ 'b' *201 ] } . should raise_error ( Pusher ::Error )
57
+ expect { @client [ 'b' *201 ] } . to raise_error ( Pusher ::Error )
58
58
end
59
59
60
60
it "should not use bad characters" do
61
- lambda { @client [ '*^!±`/""' ] } . should raise_error ( Pusher ::Error )
61
+ expect { @client [ '*^!±`/""' ] } . to raise_error ( Pusher ::Error )
62
62
end
63
63
end
64
64
65
65
describe "#trigger_async" do
66
66
it "should use @client.trigger_async internally" do
67
- @client . should_receive ( :trigger_async )
67
+ expect ( @client ) . to receive ( :trigger_async )
68
68
@channel . trigger_async ( 'new_event' , 'Some data' )
69
69
end
70
70
end
71
71
72
72
describe '#info' do
73
73
it "should call the Client#channel_info" do
74
- @client . should_receive ( :get ) . with ( "/channels/mychannel" , anything )
74
+ expect ( @client ) . to receive ( :get ) . with ( "/channels/mychannel" , anything )
75
75
@channel = @client [ 'mychannel' ]
76
76
@channel . info
77
77
end
78
78
79
79
it "should assemble the requested attributes into the info option" do
80
- @client . should_receive ( :get ) . with ( anything , {
80
+ expect ( @client ) . to receive ( :get ) . with ( anything , {
81
81
:info => "user_count,connection_count"
82
82
} )
83
83
@channel = @client [ 'presence-foo' ]
@@ -87,7 +87,7 @@ def stub_post_to_raise(e)
87
87
88
88
describe '#users' do
89
89
it "should call the Client#channel_users" do
90
- @client . should_receive ( :get ) . with ( "/channels/presence-mychannel/users" ) . and_return ( { :users => { 'id' => '4' } } )
90
+ expect ( @client ) . to receive ( :get ) . with ( "/channels/presence-mychannel/users" ) . and_return ( { :users => { 'id' => '4' } } )
91
91
@channel = @client [ 'presence-mychannel' ]
92
92
@channel . users
93
93
end
@@ -101,28 +101,28 @@ def authentication_string(*data)
101
101
it "should return an authentication string given a socket id" do
102
102
auth = @channel . authentication_string ( '1.1' )
103
103
104
- auth . should == '12345678900000001:02259dff9a2a3f71ea8ab29ac0c0c0ef7996c8f3fd3702be5533f30da7d7fed4'
104
+ expect ( auth ) . to eq ( '12345678900000001:02259dff9a2a3f71ea8ab29ac0c0c0ef7996c8f3fd3702be5533f30da7d7fed4' )
105
105
end
106
106
107
107
it "should raise error if authentication is invalid" do
108
108
[ nil , '' ] . each do |invalid |
109
- authentication_string ( invalid ) . should raise_error Pusher ::Error
109
+ expect ( authentication_string ( invalid ) ) . to raise_error Pusher ::Error
110
110
end
111
111
end
112
112
113
113
describe 'with extra string argument' do
114
114
it 'should be a string or nil' do
115
- authentication_string ( '1.1' , 123 ) . should raise_error Pusher ::Error
116
- authentication_string ( '1.1' , { } ) . should raise_error Pusher ::Error
115
+ expect ( authentication_string ( '1.1' , 123 ) ) . to raise_error Pusher ::Error
116
+ expect ( authentication_string ( '1.1' , { } ) ) . to raise_error Pusher ::Error
117
117
118
- authentication_string ( '1.1' , 'boom' ) . should_not raise_error
119
- authentication_string ( '1.1' , nil ) . should_not raise_error
118
+ expect ( authentication_string ( '1.1' , 'boom' ) ) . not_to raise_error
119
+ expect ( authentication_string ( '1.1' , nil ) ) . not_to raise_error
120
120
end
121
121
122
122
it "should return an authentication string given a socket id and custom args" do
123
123
auth = @channel . authentication_string ( '1.1' , 'foobar' )
124
124
125
- auth . should == "12345678900000001:#{ hmac ( @client . secret , "1.1:test_channel:foobar" ) } "
125
+ expect ( auth ) . to eq ( "12345678900000001:#{ hmac ( @client . secret , "1.1:test_channel:foobar" ) } " )
126
126
end
127
127
end
128
128
end
@@ -133,36 +133,36 @@ def authentication_string(*data)
133
133
end
134
134
135
135
it 'should return a hash with signature including custom data and data as json string' do
136
- MultiJson . stub ( :encode ) . with ( @custom_data ) . and_return 'a json string'
136
+ allow ( MultiJson ) . to receive ( :encode ) . with ( @custom_data ) . and_return 'a json string'
137
137
138
138
response = @channel . authenticate ( '1.1' , @custom_data )
139
139
140
- response . should == {
140
+ expect ( response ) . to eq ( {
141
141
:auth => "12345678900000001:#{ hmac ( @client . secret , "1.1:test_channel:a json string" ) } " ,
142
142
:channel_data => 'a json string'
143
- }
143
+ } )
144
144
end
145
145
146
146
it 'should fail on invalid socket_ids' do
147
- lambda {
147
+ expect {
148
148
@channel . authenticate ( '1.1:' )
149
- } . should raise_error Pusher ::Error
149
+ } . to raise_error Pusher ::Error
150
150
151
- lambda {
151
+ expect {
152
152
@channel . authenticate ( '1.1foo' , 'channel' )
153
- } . should raise_error Pusher ::Error
153
+ } . to raise_error Pusher ::Error
154
154
155
- lambda {
155
+ expect {
156
156
@channel . authenticate ( ':1.1' )
157
- } . should raise_error Pusher ::Error
157
+ } . to raise_error Pusher ::Error
158
158
159
- lambda {
159
+ expect {
160
160
@channel . authenticate ( 'foo1.1' , 'channel' )
161
- } . should raise_error Pusher ::Error
161
+ } . to raise_error Pusher ::Error
162
162
163
- lambda {
163
+ expect {
164
164
@channel . authenticate ( 'foo' , 'channel' )
165
- } . should raise_error Pusher ::Error
165
+ } . to raise_error Pusher ::Error
166
166
end
167
167
end
168
168
end
0 commit comments