Skip to content

Commit 796122a

Browse files
committed
Stub out WebSocket object in websocket_connection spec to fix jasmine:ci
1 parent 10bd330 commit 796122a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spec/javascripts/websocket_rails/websocket_connection_spec.coffee

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ describe 'WebsocketRails.WebSocketConnection:', ->
33
dispatcher =
44
new_message: -> true
55
dispatch: -> true
6-
WebSocket = (url) ->
6+
# Have to stub the WebSocket object due to Firefox error during jasmine:ci
7+
window.WebSocket = (url) ->
78
@url = url
8-
@send = ->
9+
@send = -> true
910
@connection = new WebSocketRails.WebSocketConnection('localhost:3000/websocket',dispatcher)
1011

1112
describe 'constructor', ->
@@ -29,6 +30,8 @@ describe 'WebsocketRails.WebSocketConnection:', ->
2930

3031
it 'should encode the data and send it through the WebSocket object', ->
3132
message = ['event','message']
33+
@connection._conn =
34+
send: -> true
3235
mock_connection = sinon.mock @connection._conn
3336
mock_connection.expects('send').once().withArgs JSON.stringify(message)
3437
@connection.trigger 'event', 'message', 123
@@ -38,6 +41,8 @@ describe 'WebsocketRails.WebSocketConnection:', ->
3841

3942
it 'should encode the data and send it through the WebSocket object', ->
4043
message = ['channel','event','message']
44+
@connection._conn =
45+
send: -> true
4146
mock_connection = sinon.mock @connection._conn
4247
mock_connection.expects('send').once().withArgs JSON.stringify(message)
4348
@connection.trigger_channel 'channel', 'event', 'message', 123

0 commit comments

Comments
 (0)