faye 0.8.11 → 1.0.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 (73) hide show
  1. data/{History.txt → CHANGELOG.md} +126 -105
  2. data/README.md +36 -0
  3. data/lib/faye-browser-min.js +2 -1
  4. data/lib/faye-browser-min.js.map +1 -8
  5. data/lib/faye-browser.js +923 -607
  6. data/lib/faye.rb +11 -5
  7. data/lib/faye/adapters/rack_adapter.rb +80 -85
  8. data/lib/faye/engines/connection.rb +7 -9
  9. data/lib/faye/engines/memory.rb +1 -0
  10. data/lib/faye/engines/proxy.rb +7 -6
  11. data/lib/faye/mixins/deferrable.rb +15 -0
  12. data/lib/faye/mixins/logging.rb +11 -22
  13. data/lib/faye/mixins/publisher.rb +9 -20
  14. data/lib/faye/protocol/channel.rb +2 -1
  15. data/lib/faye/protocol/client.rb +70 -48
  16. data/lib/faye/protocol/envelope.rb +24 -0
  17. data/lib/faye/protocol/extensible.rb +7 -4
  18. data/lib/faye/protocol/publication.rb +1 -1
  19. data/lib/faye/protocol/server.rb +8 -11
  20. data/lib/faye/protocol/socket.rb +6 -4
  21. data/lib/faye/protocol/subscription.rb +1 -1
  22. data/lib/faye/transport/http.rb +20 -27
  23. data/lib/faye/transport/local.rb +5 -5
  24. data/lib/faye/transport/transport.rb +42 -12
  25. data/lib/faye/transport/web_socket.rb +71 -38
  26. metadata +169 -137
  27. checksums.yaml +0 -7
  28. data/README.rdoc +0 -83
  29. data/spec/browser.html +0 -45
  30. data/spec/encoding_helper.rb +0 -7
  31. data/spec/install.sh +0 -78
  32. data/spec/javascript/channel_spec.js +0 -15
  33. data/spec/javascript/client_spec.js +0 -729
  34. data/spec/javascript/dispatcher_spec.js +0 -122
  35. data/spec/javascript/engine/memory_spec.js +0 -7
  36. data/spec/javascript/engine_spec.js +0 -417
  37. data/spec/javascript/faye_spec.js +0 -34
  38. data/spec/javascript/grammar_spec.js +0 -66
  39. data/spec/javascript/node_adapter_spec.js +0 -314
  40. data/spec/javascript/publisher_spec.js +0 -27
  41. data/spec/javascript/server/connect_spec.js +0 -168
  42. data/spec/javascript/server/disconnect_spec.js +0 -121
  43. data/spec/javascript/server/extensions_spec.js +0 -60
  44. data/spec/javascript/server/handshake_spec.js +0 -145
  45. data/spec/javascript/server/integration_spec.js +0 -131
  46. data/spec/javascript/server/publish_spec.js +0 -85
  47. data/spec/javascript/server/subscribe_spec.js +0 -247
  48. data/spec/javascript/server/unsubscribe_spec.js +0 -245
  49. data/spec/javascript/server_spec.js +0 -121
  50. data/spec/javascript/transport_spec.js +0 -135
  51. data/spec/node.js +0 -55
  52. data/spec/phantom.js +0 -17
  53. data/spec/ruby/channel_spec.rb +0 -17
  54. data/spec/ruby/client_spec.rb +0 -741
  55. data/spec/ruby/engine/memory_spec.rb +0 -7
  56. data/spec/ruby/engine_examples.rb +0 -427
  57. data/spec/ruby/faye_spec.rb +0 -30
  58. data/spec/ruby/grammar_spec.rb +0 -68
  59. data/spec/ruby/publisher_spec.rb +0 -27
  60. data/spec/ruby/rack_adapter_spec.rb +0 -241
  61. data/spec/ruby/server/connect_spec.rb +0 -170
  62. data/spec/ruby/server/disconnect_spec.rb +0 -120
  63. data/spec/ruby/server/extensions_spec.rb +0 -68
  64. data/spec/ruby/server/handshake_spec.rb +0 -143
  65. data/spec/ruby/server/integration_spec.rb +0 -133
  66. data/spec/ruby/server/publish_spec.rb +0 -81
  67. data/spec/ruby/server/subscribe_spec.rb +0 -247
  68. data/spec/ruby/server/unsubscribe_spec.rb +0 -247
  69. data/spec/ruby/server_spec.rb +0 -121
  70. data/spec/ruby/transport_spec.rb +0 -136
  71. data/spec/spec_helper.rb +0 -11
  72. data/spec/testswarm +0 -42
  73. data/spec/thin_proxy.rb +0 -37
@@ -1,81 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "server publish" do
4
- let(:engine) { mock "engine" }
5
- let(:server) { Faye::Server.new }
6
- let(:message) {{ "channel" => "/some/channel", "data" => "publish" }}
7
-
8
- before do
9
- Faye::Engine.stub(:get).and_return engine
10
- end
11
-
12
- describe "publishing a message" do
13
- it "tells the engine to publish the message" do
14
- engine.should_receive(:publish).with(message)
15
- server.process(message, false) {}
16
- end
17
-
18
- it "returns a successful response" do
19
- engine.stub(:publish)
20
- server.process(message, false) do |response|
21
- response.should == [
22
- { "channel" => "/some/channel",
23
- "successful" => true
24
- }
25
- ]
26
- end
27
- end
28
-
29
- describe "with an invalid channel" do
30
- before { message["channel"] = "channel" }
31
-
32
- it "does not tell the engine to publish the message" do
33
- engine.should_not_receive(:publish)
34
- server.process(message, false) {}
35
- end
36
-
37
- it "returns an unsuccessful response" do
38
- engine.stub(:publish)
39
- server.process(message, false) do |response|
40
- response.should == [
41
- { "channel" => "channel",
42
- "successful" => false,
43
- "error" => "405:channel:Invalid channel"
44
- }
45
- ]
46
- end
47
- end
48
- end
49
-
50
- describe "with an error" do
51
- before { message["error"] = "invalid" }
52
-
53
- it "does not tell the engine to publish the message" do
54
- engine.should_not_receive(:publish)
55
- server.process(message, false) {}
56
- end
57
-
58
- it "returns an unsuccessful response" do
59
- engine.stub(:publish)
60
- server.process(message, false) do |response|
61
- response.should == [
62
- { "channel" => "/some/channel",
63
- "successful" => false,
64
- "error" => "invalid"
65
- }
66
- ]
67
- end
68
- end
69
- end
70
-
71
- describe "to an invalid channel" do
72
- before { message["channel"] = "/invalid/*" }
73
-
74
- it "does not tell the engine to publish the message" do
75
- engine.should_not_receive(:publish)
76
- server.process(message, false) {}
77
- end
78
- end
79
- end
80
- end
81
-
@@ -1,247 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "server subscribe" do
4
- let(:engine) { mock "engine" }
5
- let(:server) { Faye::Server.new }
6
-
7
- before do
8
- Faye::Engine.stub(:get).and_return engine
9
- end
10
-
11
- describe :subscribe do
12
- let(:client_id) { "fakeclientid" }
13
- let(:message) {{"channel" => "/meta/subscribe",
14
- "clientId" => "fakeclientid",
15
- "subscription" => "/foo"
16
- }}
17
-
18
- describe "with valid parameters" do
19
- before do
20
- engine.should_receive(:client_exists).with(client_id).and_yield true
21
- end
22
-
23
- it "subscribes the client to the channel" do
24
- engine.should_receive(:subscribe).with(client_id, "/foo")
25
- server.subscribe(message) {}
26
- end
27
-
28
- it "returns a successful response" do
29
- engine.stub(:subscribe)
30
- server.subscribe(message) do |response|
31
- response.should == {
32
- "channel" => "/meta/subscribe",
33
- "successful" => true,
34
- "clientId" => client_id,
35
- "subscription" => "/foo"
36
- }
37
- end
38
- end
39
-
40
- describe "with a list of subscriptions" do
41
- before do
42
- message["subscription"] = ["/foo", "/bar"]
43
- end
44
-
45
- it "creates multiple subscriptions" do
46
- engine.should_receive(:subscribe).with(client_id, "/foo")
47
- engine.should_receive(:subscribe).with(client_id, "/bar")
48
- server.subscribe(message) {}
49
- end
50
-
51
- it "returns a successful response" do
52
- engine.stub(:subscribe)
53
- server.subscribe(message) do |response|
54
- response.should == {
55
- "channel" => "/meta/subscribe",
56
- "successful" => true,
57
- "clientId" => client_id,
58
- "subscription" => ["/foo", "/bar"]
59
- }
60
- end
61
- end
62
- end
63
-
64
- describe "with a subscription pattern" do
65
- before do
66
- message["subscription"] = "/foo/**"
67
- end
68
-
69
- it "subscribes the client to the channel pattern" do
70
- engine.should_receive(:subscribe).with(client_id, "/foo/**")
71
- server.subscribe(message) {}
72
- end
73
-
74
- it "returns a successful response" do
75
- engine.stub(:subscribe)
76
- server.subscribe(message) do |response|
77
- response.should == {
78
- "channel" => "/meta/subscribe",
79
- "successful" => true,
80
- "clientId" => client_id,
81
- "subscription" => "/foo/**"
82
- }
83
- end
84
- end
85
- end
86
- end
87
-
88
- describe "with an unknown client" do
89
- before do
90
- engine.should_receive(:client_exists).with(client_id).and_yield false
91
- end
92
-
93
- it "does not subscribe the client to the channel" do
94
- engine.should_not_receive(:subscribe)
95
- server.subscribe(message) {}
96
- end
97
-
98
- it "returns an unsuccessful response" do
99
- server.subscribe(message) do |response|
100
- response.should == {
101
- "channel" => "/meta/subscribe",
102
- "successful" => false,
103
- "error" => "401:fakeclientid:Unknown client",
104
- "clientId" => client_id,
105
- "subscription" => "/foo"
106
- }
107
- end
108
- end
109
- end
110
-
111
- describe "missing clientId" do
112
- before do
113
- message.delete("clientId")
114
- engine.should_receive(:client_exists).with(nil).and_yield false
115
- end
116
-
117
- it "does not subscribe the client to the channel" do
118
- engine.should_not_receive(:subscribe)
119
- server.subscribe(message) {}
120
- end
121
-
122
- it "returns an unsuccessful response" do
123
- server.subscribe(message) do |response|
124
- response.should == {
125
- "channel" => "/meta/subscribe",
126
- "successful" => false,
127
- "error" => "402:clientId:Missing required parameter",
128
- "subscription" => "/foo"
129
- }
130
- end
131
- end
132
- end
133
-
134
- describe "missing subscription" do
135
- before do
136
- message.delete("subscription")
137
- engine.should_receive(:client_exists).with(client_id).and_yield true
138
- end
139
-
140
- it "does not subscribe the client to the channel" do
141
- engine.should_not_receive(:subscribe)
142
- server.subscribe(message) {}
143
- end
144
-
145
- it "returns an unsuccessful response" do
146
- server.subscribe(message) do |response|
147
- response.should == {
148
- "channel" => "/meta/subscribe",
149
- "successful" => false,
150
- "error" => "402:subscription:Missing required parameter",
151
- "clientId" => client_id,
152
- "subscription" => []
153
- }
154
- end
155
- end
156
- end
157
-
158
- describe "with an invalid channel" do
159
- before do
160
- message["subscription"] = "foo"
161
- engine.should_receive(:client_exists).with(client_id).and_yield true
162
- end
163
-
164
- it "does not subscribe the client to the channel" do
165
- engine.should_not_receive(:subscribe)
166
- server.subscribe(message) {}
167
- end
168
-
169
- it "returns an unsuccessful response" do
170
- server.subscribe(message) do |response|
171
- response.should == {
172
- "channel" => "/meta/subscribe",
173
- "successful" => false,
174
- "error" => "405:foo:Invalid channel",
175
- "clientId" => client_id,
176
- "subscription" => "foo"
177
- }
178
- end
179
- end
180
- end
181
-
182
- describe "with a /meta/* channel" do
183
- before do
184
- message["subscription"] = "/meta/foo"
185
- engine.should_receive(:client_exists).with(client_id).and_yield true
186
- end
187
-
188
- it "does not subscribe the client to the channel" do
189
- engine.should_not_receive(:subscribe)
190
- server.subscribe(message) {}
191
- end
192
-
193
- it "returns an unsuccessful response" do
194
- server.subscribe(message) do |response|
195
- response.should == {
196
- "channel" => "/meta/subscribe",
197
- "successful" => false,
198
- "error" => "403:/meta/foo:Forbidden channel",
199
- "clientId" => client_id,
200
- "subscription" => "/meta/foo"
201
- }
202
- end
203
- end
204
-
205
- it "subscribes local clients to the channel" do
206
- engine.should_receive(:subscribe).with(client_id, "/meta/foo")
207
- server.subscribe(message, true) {}
208
- end
209
-
210
- it "returns a successful response for local clients" do
211
- engine.stub(:subscribe)
212
- server.subscribe(message, true) do |response|
213
- response.should == {
214
- "channel" => "/meta/subscribe",
215
- "successful" => true,
216
- "clientId" => client_id,
217
- "subscription" => "/meta/foo"
218
- }
219
- end
220
- end
221
- end
222
-
223
- describe "with an error" do
224
- before do
225
- message["error"] = "invalid"
226
- engine.should_receive(:client_exists).with(client_id).and_yield true
227
- end
228
-
229
- it "does not subscribe the client to the channel" do
230
- engine.should_not_receive(:subscribe)
231
- server.subscribe(message) {}
232
- end
233
-
234
- it "returns an unsuccessful response" do
235
- server.subscribe(message) do |response|
236
- response.should == {
237
- "channel" => "/meta/subscribe",
238
- "successful" => false,
239
- "error" => "invalid",
240
- "clientId" => client_id,
241
- "subscription" => "/foo"
242
- }
243
- end
244
- end
245
- end
246
- end
247
- end
@@ -1,247 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "server unsubscribe" do
4
- let(:engine) { mock "engine" }
5
- let(:server) { Faye::Server.new }
6
-
7
- before do
8
- Faye::Engine.stub(:get).and_return engine
9
- end
10
-
11
- describe :unsubscribe do
12
- let(:client_id) { "fakeclientid" }
13
- let(:message) {{"channel" => "/meta/unsubscribe",
14
- "clientId" => "fakeclientid",
15
- "subscription" => "/foo"
16
- }}
17
-
18
- describe "with valid parameters" do
19
- before do
20
- engine.should_receive(:client_exists).with(client_id).and_yield true
21
- end
22
-
23
- it "unsubscribes the client from the channel" do
24
- engine.should_receive(:unsubscribe).with(client_id, "/foo")
25
- server.unsubscribe(message) {}
26
- end
27
-
28
- it "returns a successful response" do
29
- engine.stub(:unsubscribe)
30
- server.unsubscribe(message) do |response|
31
- response.should == {
32
- "channel" => "/meta/unsubscribe",
33
- "successful" => true,
34
- "clientId" => client_id,
35
- "subscription" => "/foo"
36
- }
37
- end
38
- end
39
-
40
- describe "with a list of subscriptions" do
41
- before do
42
- message["subscription"] = ["/foo", "/bar"]
43
- end
44
-
45
- it "destroys multiple subscriptions" do
46
- engine.should_receive(:unsubscribe).with(client_id, "/foo")
47
- engine.should_receive(:unsubscribe).with(client_id, "/bar")
48
- server.unsubscribe(message) {}
49
- end
50
-
51
- it "returns a successful response" do
52
- engine.stub(:unsubscribe)
53
- server.unsubscribe(message) do |response|
54
- response.should == {
55
- "channel" => "/meta/unsubscribe",
56
- "successful" => true,
57
- "clientId" => client_id,
58
- "subscription" => ["/foo", "/bar"]
59
- }
60
- end
61
- end
62
- end
63
-
64
- describe "with a subscription pattern" do
65
- before do
66
- message["subscription"] = "/foo/**"
67
- end
68
-
69
- it "destroys the subscription to the channel pattern" do
70
- engine.should_receive(:unsubscribe).with(client_id, "/foo/**")
71
- server.unsubscribe(message) {}
72
- end
73
-
74
- it "returns a successful response" do
75
- engine.stub(:unsubscribe)
76
- server.unsubscribe(message) do |response|
77
- response.should == {
78
- "channel" => "/meta/unsubscribe",
79
- "successful" => true,
80
- "clientId" => client_id,
81
- "subscription" => "/foo/**"
82
- }
83
- end
84
- end
85
- end
86
- end
87
-
88
- describe "with an unknown client" do
89
- before do
90
- engine.should_receive(:client_exists).with(client_id).and_yield false
91
- end
92
-
93
- it "does not unsubscribe the client from the channel" do
94
- engine.should_not_receive(:unsubscribe)
95
- server.unsubscribe(message) {}
96
- end
97
-
98
- it "returns an unsuccessful response" do
99
- server.unsubscribe(message) do |response|
100
- response.should == {
101
- "channel" => "/meta/unsubscribe",
102
- "successful" => false,
103
- "error" => "401:fakeclientid:Unknown client",
104
- "clientId" => client_id,
105
- "subscription" => "/foo"
106
- }
107
- end
108
- end
109
- end
110
-
111
- describe "missing clientId" do
112
- before do
113
- message.delete("clientId")
114
- engine.should_receive(:client_exists).with(nil).and_yield false
115
- end
116
-
117
- it "does not unsubscribe the client from the channel" do
118
- engine.should_not_receive(:unsubscribe)
119
- server.unsubscribe(message) {}
120
- end
121
-
122
- it "returns an unsuccessful response" do
123
- server.unsubscribe(message) do |response|
124
- response.should == {
125
- "channel" => "/meta/unsubscribe",
126
- "successful" => false,
127
- "error" => "402:clientId:Missing required parameter",
128
- "subscription" => "/foo"
129
- }
130
- end
131
- end
132
- end
133
-
134
- describe "missing subscription" do
135
- before do
136
- message.delete("subscription")
137
- engine.should_receive(:client_exists).with(client_id).and_yield true
138
- end
139
-
140
- it "does not unsubscribe the client from the channel" do
141
- engine.should_not_receive(:unsubscribe)
142
- server.unsubscribe(message) {}
143
- end
144
-
145
- it "returns an unsuccessful response" do
146
- server.unsubscribe(message) do |response|
147
- response.should == {
148
- "channel" => "/meta/unsubscribe",
149
- "successful" => false,
150
- "error" => "402:subscription:Missing required parameter",
151
- "clientId" => client_id,
152
- "subscription" => []
153
- }
154
- end
155
- end
156
- end
157
-
158
- describe "with an invalid channel" do
159
- before do
160
- message["subscription"] = "foo"
161
- engine.should_receive(:client_exists).with(client_id).and_yield true
162
- end
163
-
164
- it "does not unsubscribe the client from the channel" do
165
- engine.should_not_receive(:unsubscribe)
166
- server.unsubscribe(message) {}
167
- end
168
-
169
- it "returns an unsuccessful response" do
170
- server.unsubscribe(message) do |response|
171
- response.should == {
172
- "channel" => "/meta/unsubscribe",
173
- "successful" => false,
174
- "error" => "405:foo:Invalid channel",
175
- "clientId" => client_id,
176
- "subscription" => "foo"
177
- }
178
- end
179
- end
180
- end
181
-
182
- describe "with a /meta/* channel" do
183
- before do
184
- message["subscription"] = "/meta/foo"
185
- engine.should_receive(:client_exists).with(client_id).and_yield true
186
- end
187
-
188
- it "does not unsubscribe the client from the channel" do
189
- engine.should_not_receive(:unsubscribe)
190
- server.unsubscribe(message) {}
191
- end
192
-
193
- it "returns an unsuccessful response" do
194
- server.unsubscribe(message) do |response|
195
- response.should == {
196
- "channel" => "/meta/unsubscribe",
197
- "successful" => false,
198
- "error" => "403:/meta/foo:Forbidden channel",
199
- "clientId" => client_id,
200
- "subscription" => "/meta/foo"
201
- }
202
- end
203
- end
204
-
205
- it "unsubscribes local clients from the channel" do
206
- engine.should_receive(:unsubscribe).with(client_id, "/meta/foo")
207
- server.unsubscribe(message, true) {}
208
- end
209
-
210
- it "returns a successful response for local clients" do
211
- engine.stub(:unsubscribe)
212
- server.unsubscribe(message, true) do |response|
213
- response.should == {
214
- "channel" => "/meta/unsubscribe",
215
- "successful" => true,
216
- "clientId" => client_id,
217
- "subscription" => "/meta/foo"
218
- }
219
- end
220
- end
221
- end
222
-
223
- describe "with an error" do
224
- before do
225
- message["error"] = "invalid"
226
- engine.should_receive(:client_exists).with(client_id).and_yield true
227
- end
228
-
229
- it "does not unsubscribe the client from the channel" do
230
- engine.should_not_receive(:unsubscribe)
231
- server.unsubscribe(message) {}
232
- end
233
-
234
- it "returns an unsuccessful response" do
235
- server.unsubscribe(message) do |response|
236
- response.should == {
237
- "channel" => "/meta/unsubscribe",
238
- "successful" => false,
239
- "error" => "invalid",
240
- "clientId" => client_id,
241
- "subscription" => "/foo"
242
- }
243
- end
244
- end
245
- end
246
- end
247
- end