faye 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of faye might be problematic. Click here for more details.

Files changed (54) hide show
  1. data/History.txt +15 -3
  2. data/README.rdoc +2 -6
  3. data/lib/faye-browser-min.js +1 -1
  4. data/lib/faye.rb +25 -36
  5. data/lib/faye/adapters/rack_adapter.rb +43 -22
  6. data/lib/faye/engines/connection.rb +7 -10
  7. data/lib/faye/engines/memory.rb +28 -28
  8. data/lib/faye/engines/proxy.rb +109 -0
  9. data/lib/faye/mixins/logging.rb +1 -8
  10. data/lib/faye/mixins/timeouts.rb +1 -1
  11. data/lib/faye/protocol/channel.rb +3 -3
  12. data/lib/faye/protocol/client.rb +50 -45
  13. data/lib/faye/protocol/extensible.rb +11 -18
  14. data/lib/faye/protocol/server.rb +53 -38
  15. data/lib/faye/transport/http.rb +49 -27
  16. data/lib/faye/transport/transport.rb +3 -1
  17. data/lib/faye/transport/web_socket.rb +6 -10
  18. data/lib/faye/util/namespace.rb +2 -2
  19. data/spec/browser.html +3 -1
  20. data/spec/encoding_helper.rb +7 -0
  21. data/spec/javascript/client_spec.js +0 -5
  22. data/spec/javascript/engine/memory_spec.js +7 -0
  23. data/spec/javascript/engine_spec.js +22 -57
  24. data/spec/javascript/server/handshake_spec.js +10 -6
  25. data/spec/javascript/server/integration_spec.js +11 -10
  26. data/spec/javascript/server/publish_spec.js +85 -0
  27. data/spec/javascript/server_spec.js +5 -51
  28. data/spec/node.js +6 -6
  29. data/spec/ruby/client_spec.rb +1 -1
  30. data/spec/ruby/engine/memory_spec.rb +7 -0
  31. data/spec/ruby/{engine_spec.rb → engine_examples.rb} +28 -34
  32. data/spec/ruby/rack_adapter_spec.rb +1 -1
  33. data/spec/ruby/server/handshake_spec.rb +10 -6
  34. data/spec/ruby/server/publish_spec.rb +81 -0
  35. data/spec/ruby/server_spec.rb +6 -44
  36. data/spec/spec_helper.rb +5 -18
  37. data/spec/testswarm +1 -5
  38. metadata +105 -180
  39. data/lib/faye/engines/base.rb +0 -66
  40. data/lib/faye/engines/redis.rb +0 -225
  41. data/lib/faye/thin_extensions.rb +0 -75
  42. data/lib/faye/util/web_socket.rb +0 -89
  43. data/lib/faye/util/web_socket/api.rb +0 -103
  44. data/lib/faye/util/web_socket/client.rb +0 -82
  45. data/lib/faye/util/web_socket/draft75_parser.rb +0 -53
  46. data/lib/faye/util/web_socket/draft76_parser.rb +0 -53
  47. data/lib/faye/util/web_socket/protocol8_parser.rb +0 -324
  48. data/spec/javascript/web_socket/client_spec.js +0 -121
  49. data/spec/javascript/web_socket/draft75parser_spec.js +0 -39
  50. data/spec/javascript/web_socket/protocol8parser_spec.js +0 -153
  51. data/spec/redis.conf +0 -42
  52. data/spec/ruby/web_socket/client_spec.rb +0 -126
  53. data/spec/ruby/web_socket/draft75_parser_spec.rb +0 -41
  54. data/spec/ruby/web_socket/protocol8_parser_spec.rb +0 -145
@@ -1,121 +0,0 @@
1
- JS.ENV.WebSocket = JS.ENV.WebSocket || {}
2
-
3
- JS.ENV.WebSocketSteps = JS.ENV.IntegrationSteps = JS.Test.asyncSteps({
4
- server: function(port, callback) {
5
- this._adapter = new Faye.NodeAdapter({mount: "/bayeux", timeout: 25})
6
- this._adapter.listen(port)
7
- this._port = port
8
- setTimeout(callback, 100)
9
- },
10
-
11
- stop: function(callback) {
12
- this._adapter.stop()
13
- setTimeout(callback, 100)
14
- },
15
-
16
- open_socket: function(url, callback) {
17
- var done = false,
18
- self = this,
19
-
20
- resume = function(open) {
21
- if (done) return
22
- done = true
23
- self._open = open
24
- callback()
25
- }
26
-
27
- this._ws = new Faye.WebSocket.Client(url)
28
-
29
- this._ws.onopen = function() { resume(true) }
30
- this._ws.onclose = function() { resume(false) }
31
- },
32
-
33
- close_socket: function(callback) {
34
- var self = this
35
- this._ws.onclose = function() {
36
- self._open = false
37
- callback()
38
- }
39
- this._ws.close()
40
- },
41
-
42
- check_open: function(callback) {
43
- this.assert( this._open )
44
- callback()
45
- },
46
-
47
- check_closed: function(callback) {
48
- this.assert( !this._open )
49
- callback()
50
- },
51
-
52
- listen_for_message: function(callback) {
53
- var self = this
54
- this._ws.onmessage = function(message) { self._message = message.data }
55
- callback()
56
- },
57
-
58
- send_subscribe: function(callback) {
59
- this._ws.send(JSON.stringify({channel: "/meta/subscribe", subscription: "/ws"}))
60
- setTimeout(callback, 100)
61
- },
62
-
63
- check_subscribe_response: function(callback) {
64
- this.assertEqual( [{ channel: "/meta/subscribe",
65
- error: "402:clientId:Missing required parameter",
66
- subscription: "/ws",
67
- successful: false
68
- }],
69
- JSON.parse(this._message) )
70
- callback()
71
- },
72
-
73
- check_no_response: function(callback) {
74
- this.assert( !this._message )
75
- callback()
76
- }
77
- })
78
-
79
- JS.ENV.WebSocket.ClientSpec = JS.Test.describe("WebSocket.Client", function() { with(this) {
80
- include(WebSocketSteps)
81
-
82
- before(function() { this.server(8000) })
83
- after (function() { this.stop() })
84
-
85
- it("can open a connection", function() { with(this) {
86
- open_socket("ws://localhost:8000/bayeux")
87
- check_open()
88
- }})
89
-
90
- it("can close the connection", function() { with(this) {
91
- open_socket("ws://localhost:8000/bayeux")
92
- close_socket()
93
- check_closed()
94
- }})
95
-
96
- describe("in the OPEN state", function() { with(this) {
97
- before(function() { with(this) {
98
- open_socket("ws://localhost:8000/bayeux")
99
- }})
100
-
101
- it("can send and receive messages", function() { with(this) {
102
- listen_for_message()
103
- send_subscribe()
104
- check_subscribe_response()
105
- }})
106
- }})
107
-
108
- describe("in the CLOSED state", function() { with(this) {
109
- before(function() { with(this) {
110
- open_socket("ws://localhost:8000/bayeux")
111
- close_socket()
112
- }})
113
-
114
- it("cannot send and receive messages", function() { with(this) {
115
- listen_for_message()
116
- send_subscribe()
117
- check_no_response()
118
- }})
119
- }})
120
- }})
121
-
@@ -1,39 +0,0 @@
1
- JS.ENV.WebSocket = JS.ENV.WebSocket || {}
2
-
3
- JS.ENV.WebSocket.Draft75ParserSpec = JS.Test.describe("WebSocket.Draft75Parser", function() { with(this) {
4
- before(function() { with(this) {
5
- this.webSocket = {dispatchEvent: function() {}}
6
- this.socket = new FakeSocket
7
- this.parser = new Faye.WebSocket.Draft75Parser(webSocket, socket)
8
- }})
9
-
10
- describe("parse", function() { with(this) {
11
- it("parses text frames", function() { with(this) {
12
- expect(webSocket, "receive").given("Hello")
13
- parser.parse([0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff])
14
- }})
15
-
16
- it("parses multibyte text frames", function() { with(this) {
17
- expect(webSocket, "receive").given("Apple = ")
18
- parser.parse([0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff])
19
- }})
20
-
21
- it("parses fragmented frames", function() { with(this) {
22
- expect(webSocket, "receive").given("Hello")
23
- parser.parse([0x00, 0x48, 0x65, 0x6c])
24
- parser.parse([0x6c, 0x6f, 0xff])
25
- }})
26
- }})
27
-
28
- describe("frame", function() { with(this) {
29
- it("returns the given string formatted as a WebSocket frame", function() { with(this) {
30
- parser.frame("Hello")
31
- assertEqual( [0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0xff], socket.read() )
32
- }})
33
-
34
- it("encodes multibyte characters correctly", function() { with(this) {
35
- parser.frame("Apple = ")
36
- assertEqual( [0x00, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf, 0xff], socket.read() )
37
- }})
38
- }})
39
- }})
@@ -1,153 +0,0 @@
1
- JS.ENV.WebSocket = JS.ENV.WebSocket || {}
2
-
3
- JS.ENV.WebSocket.Protocol8ParserSpec = JS.Test.describe("WebSocket.Protocol8Parser", function() { with(this) {
4
- before(function() { with(this) {
5
- this.webSocket = {dispatchEvent: function() {}}
6
- this.socket = new FakeSocket
7
- this.parser = new Faye.WebSocket.Protocol8Parser(webSocket, socket)
8
- }})
9
-
10
- define("parse", function() {
11
- var bytes = [];
12
- for (var i = 0, n = arguments.length; i < n; i++) bytes = bytes.concat(arguments[i])
13
- this.parser.parse(new Buffer(bytes))
14
- })
15
-
16
- define("buffer", function(string) {
17
- return {
18
- equals: function(buffer) {
19
- return buffer.toString('utf8', 0, buffer.length) === string
20
- }
21
- }
22
- })
23
-
24
- describe("parse", function() { with(this) {
25
- define("mask", function() {
26
- return this._mask = this._mask || Faye.map([1,2,3,4], function() { return Math.floor(Math.random() * 255) })
27
- })
28
-
29
- define("maskMessage", function(bytes) {
30
- var output = []
31
- Array.prototype.forEach.call(bytes, function(b, i) {
32
- output[i] = bytes[i] ^ this.mask()[i % 4]
33
- }, this)
34
- return output
35
- })
36
-
37
- it("parses unmasked text frames", function() { with(this) {
38
- expect(webSocket, "receive").given("Hello")
39
- parse([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
40
- }})
41
-
42
- it("parses empty text frames", function() { with(this) {
43
- expect(webSocket, "receive").given("")
44
- parse([0x81, 0x00])
45
- }})
46
-
47
- it("parses fragmented text frames", function() { with(this) {
48
- expect(webSocket, "receive").given("Hello")
49
- parse([0x01, 0x03, 0x48, 0x65, 0x6c])
50
- parse([0x80, 0x02, 0x6c, 0x6f])
51
- }})
52
-
53
- it("parses masked text frames", function() { with(this) {
54
- expect(webSocket, "receive").given("Hello")
55
- parse([0x81, 0x85], mask(), maskMessage([0x48, 0x65, 0x6c, 0x6c, 0x6f]))
56
- }})
57
-
58
- it("parses masked empty text frames", function() { with(this) {
59
- expect(webSocket, "receive").given("")
60
- parse([0x81, 0x80], mask(), maskMessage([]))
61
- }})
62
-
63
- it("parses masked fragmented text frames", function() { with(this) {
64
- expect(webSocket, "receive").given("Hello")
65
- parse([0x01, 0x81], mask(), maskMessage([0x48]))
66
- parse([0x80, 0x84], mask(), maskMessage([0x65, 0x6c, 0x6c, 0x6f]))
67
- }})
68
-
69
- it("closes the socket if the frame has an unrecognized opcode", function() { with(this) {
70
- expect(webSocket, "close").given(1002, null, false)
71
- parse([0x83, 0x00])
72
- }})
73
-
74
- it("closes the socket if a close frame is received", function() { with(this) {
75
- expect(webSocket, "close").given(1000, "Hello", false)
76
- parse([0x88, 0x07, 0x03, 0xe8, 0x48, 0x65, 0x6c, 0x6c, 0x6f])
77
- }})
78
-
79
- it("parses unmasked multibyte text frames", function() { with(this) {
80
- expect(webSocket, "receive").given("Apple = ")
81
- parse([0x81, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf])
82
- }})
83
-
84
- it("parses fragmented multibyte text frames", function() { with(this) {
85
- expect(webSocket, "receive").given("Apple = ")
86
- parse([0x01, 0x0a, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3])
87
- parse([0x80, 0x01, 0xbf])
88
- }})
89
-
90
- it("parses masked multibyte text frames", function() { with(this) {
91
- expect(webSocket, "receive").given("Apple = ")
92
- parse([0x81, 0x8b], mask(), maskMessage([0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf]))
93
- }})
94
-
95
- it("parses masked fragmented multibyte text frames", function() { with(this) {
96
- expect(webSocket, "receive").given("Apple = ")
97
- parse([0x01, 0x8a], mask(), maskMessage([0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3]))
98
- parse([0x80, 0x81], mask(), maskMessage([0xbf]))
99
- }})
100
-
101
- it("parses unmasked medium-length text frames", function() { with(this) {
102
- expect(webSocket, "receive").given("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello")
103
- parse([129, 126, 0, 200, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111])
104
- }})
105
-
106
- it("parses masked medium-length text frames", function() { with(this) {
107
- expect(webSocket, "receive").given("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello")
108
- parse([129, 254, 0, 200], mask(), maskMessage([72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111]))
109
- }})
110
-
111
- it("replies to pings with a pong", function() { with(this) {
112
- expect(webSocket, "send").given(buffer("OHAI"), "pong")
113
- parse([0x89, 0x04, 0x4f, 0x48, 0x41, 0x49])
114
- }})
115
- }})
116
-
117
- describe("frame", function() { with(this) {
118
- it("returns the given string formatted as a WebSocket frame", function() { with(this) {
119
- parser.frame("Hello")
120
- assertEqual( [0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f], socket.read() )
121
- }})
122
-
123
- it("encodes multibyte characters correctly", function() { with(this) {
124
- parser.frame("Apple = ")
125
- assertEqual( [0x81, 0x0b, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0xef, 0xa3, 0xbf], socket.read() )
126
- }})
127
-
128
- it("encodes medium-length strings using extra length bytes", function() { with(this) {
129
- parser.frame("HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello")
130
- assertEqual( [129, 126, 0, 200, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111], socket.read() )
131
- }})
132
-
133
- it("encodes long strings using extra length bytes", function() { with(this) {
134
- var reps = 13108, message = '', output = [0x81, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04]
135
- while (reps--) {
136
- message += "Hello"
137
- output = output.concat([0x48, 0x65, 0x6c, 0x6c, 0x6f])
138
- }
139
- parser.frame(message)
140
- assertEqual( output, socket.read() )
141
- }})
142
-
143
- it("encodes close frames with an error code", function() { with(this) {
144
- parser.frame("Hello", "close", 1002)
145
- assertEqual( [0x88, 0x07, 0x03, 0xea, 0x48, 0x65, 0x6c, 0x6c, 0x6f], socket.read() )
146
- }})
147
-
148
- it("encodes pong frames", function() { with(this) {
149
- parser.frame("", "pong")
150
- assertEqual( [0x8a, 0x00], socket.read() )
151
- }})
152
- }})
153
- }})
@@ -1,42 +0,0 @@
1
- daemonize no
2
- pidfile /tmp/redis.pid
3
- port 6379
4
- unixsocket /tmp/redis.sock
5
- timeout 300
6
- loglevel verbose
7
- logfile stdout
8
- databases 16
9
-
10
- save 900 1
11
- save 300 10
12
- save 60 10000
13
-
14
- rdbcompression yes
15
- dbfilename dump.rdb
16
- dir ./
17
-
18
- slave-serve-stale-data yes
19
-
20
- requirepass foobared
21
-
22
- appendonly no
23
- appendfsync everysec
24
- no-appendfsync-on-rewrite no
25
-
26
- vm-enabled no
27
- vm-swap-file /tmp/redis.swap
28
- vm-max-memory 0
29
- vm-page-size 32
30
- vm-pages 134217728
31
- vm-max-threads 4
32
-
33
- hash-max-zipmap-entries 512
34
- hash-max-zipmap-value 64
35
-
36
- list-max-ziplist-entries 512
37
- list-max-ziplist-value 64
38
-
39
- set-max-intset-entries 512
40
-
41
- activerehashing yes
42
-
@@ -1,126 +0,0 @@
1
- # encoding=utf-8
2
-
3
- require "spec_helper"
4
-
5
- require "thin"
6
- Thin::Logging.silent = true
7
-
8
- WebSocketSteps = EM::RSpec.async_steps do
9
- def server(port, &callback)
10
- @adapter = Faye::RackAdapter.new(:mount => "/bayeux", :timeout => 25)
11
- @adapter.listen(port)
12
- @port = port
13
- EM.add_timer(0.1, &callback)
14
- end
15
-
16
- def stop(&callback)
17
- @adapter.stop
18
- EM.next_tick(&callback)
19
- end
20
-
21
- def open_socket(url, &callback)
22
- done = false
23
-
24
- resume = lambda do |open|
25
- unless done
26
- done = true
27
- @open = true
28
- callback.call
29
- end
30
- end
31
-
32
- @ws = Faye::WebSocket::Client.new(url)
33
-
34
- @ws.onopen = lambda { |e| resume.call(true) }
35
- @ws.onclose = lambda { |e| resume.call(false) }
36
- end
37
-
38
- def close_socket(&callback)
39
- @ws.onclose = lambda do |e|
40
- @open = false
41
- callback.call
42
- end
43
- @ws.close
44
- end
45
-
46
- def check_open(&callback)
47
- @open.should == true
48
- callback.call
49
- end
50
-
51
- def check_closed(&callback)
52
- @open.should == false
53
- callback.call
54
- end
55
-
56
- def listen_for_message(&callback)
57
- @ws.onmessage = lambda { |e| @message = e.data }
58
- callback.call
59
- end
60
-
61
- def send_sunscription(&callback)
62
- @ws.send(JSON.dump "channel" => "/meta/subscribe", "subscription" => "/ws")
63
- EM.add_timer(0.1, &callback)
64
- end
65
-
66
- def check_subscribe_response(&callback)
67
- JSON.parse(@message).should == [{ "channel" => "/meta/subscribe",
68
- "successful" => false,
69
- "error" => "402:clientId:Missing required parameter",
70
- "subscription" => "/ws"
71
- }]
72
- callback.call
73
- end
74
-
75
- def check_no_response(&callback)
76
- @message.should == nil
77
- callback.call
78
- end
79
- end
80
-
81
- describe Faye::WebSocket::Client do
82
- include WebSocketSteps
83
-
84
- before do
85
- Faye.ensure_reactor_running!
86
- server 8000
87
- sync
88
- end
89
-
90
- after { sync ; stop }
91
-
92
- it "can open a connection" do
93
- open_socket "ws://localhost:8000/bayeux"
94
- check_open
95
- end
96
-
97
- it "can close the connection" do
98
- open_socket "ws://localhost:8000/bayeux"
99
- close_socket
100
- check_closed
101
- end
102
-
103
- describe "in the OPEN state" do
104
- before { open_socket "ws://localhost:8000/bayeux" }
105
-
106
- it "can send and receive messages" do
107
- listen_for_message
108
- send_sunscription
109
- check_subscribe_response
110
- end
111
- end
112
-
113
- describe "in the CLOSED state" do
114
- before do
115
- open_socket "ws://localhost:8000/bayeux"
116
- close_socket
117
- end
118
-
119
- it "cannot send and receive messages" do
120
- listen_for_message
121
- send_sunscription
122
- check_no_response
123
- end
124
- end
125
- end
126
-