anyt 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/anyt/client.rb +2 -0
- data/lib/anyt/tests/request/disconnection_test.rb +83 -17
- data/lib/anyt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6993fd39f2e1cad04cc423a70ba7f15dcd44a6962c93f48e313b89e75a3d1c47
|
4
|
+
data.tar.gz: 1977fa24962781b903acd0d1909fd6ad5def66709d04934dba1319cbf11dfeda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f02b19da67f22d90fdf60ddcb3d24bfeb431dd87d80ccb1164288fd254028de65a1fefd70931b48cac0a0624ec21d76db2c5c91cd6b3be54be8d7414e88cc42
|
7
|
+
data.tar.gz: c9a7b23d5c8b139d28d2c30948661b80afb460c7e8093094b0f84773c59f5fa935796eb1dd67ccf55c0f58e001e893662152cfcb811a3fd510d1ce3d205d730d
|
data/lib/anyt/client.rb
CHANGED
@@ -14,6 +14,7 @@ module Anyt
|
|
14
14
|
|
15
15
|
# rubocop: disable Metrics/AbcSize
|
16
16
|
# rubocop: disable Metrics/MethodLength
|
17
|
+
# rubocop: disable Metrics/BlockLength
|
17
18
|
def initialize(
|
18
19
|
ignore: [], url: Anyt.config.target_url, qs: "",
|
19
20
|
cookies: "", headers: {}
|
@@ -68,6 +69,7 @@ module Anyt
|
|
68
69
|
|
69
70
|
open.wait!(WAIT_WHEN_EXPECTING_EVENT)
|
70
71
|
end
|
72
|
+
# rubocop: enable Metrics/BlockLength
|
71
73
|
# rubocop: enable Metrics/AbcSize
|
72
74
|
# rubocop: enable Metrics/MethodLength
|
73
75
|
|
@@ -7,7 +7,7 @@ feature "Request" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def unsubscribed
|
10
|
-
ActionCable.server.broadcast("a", data: "user left")
|
10
|
+
ActionCable.server.broadcast("a", data: "user left#{params[:id].presence}")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -24,37 +24,103 @@ feature "Request" do
|
|
24
24
|
let(:client2) { build_client(ignore: %w[ping welcome]) }
|
25
25
|
|
26
26
|
before do
|
27
|
-
|
28
|
-
subscribe_request = { command: "subscribe", identifier: { channel: a_channel }.to_json }
|
27
|
+
subscribe_request = { command: "subscribe", identifier: { channel: a_channel }.to_json }
|
29
28
|
|
30
|
-
|
29
|
+
client.send(subscribe_request)
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
ack = {
|
32
|
+
"identifier" => { channel: a_channel }.to_json, "type" => "confirm_subscription"
|
33
|
+
}
|
35
34
|
|
36
|
-
|
35
|
+
assert_equal ack, client.receive
|
37
36
|
|
38
|
-
|
37
|
+
subscribe_request = { command: "subscribe", identifier: { channel: b_channel }.to_json }
|
39
38
|
|
40
|
-
|
39
|
+
client.send(subscribe_request)
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
ack = {
|
42
|
+
"identifier" => { channel: b_channel }.to_json, "type" => "confirm_subscription"
|
43
|
+
}
|
45
44
|
|
46
|
-
|
47
|
-
end
|
45
|
+
assert_equal ack, client.receive
|
48
46
|
end
|
49
47
|
|
50
48
|
scenario %{
|
51
49
|
Client disconnect invokes #unsubscribe callbacks
|
50
|
+
for different channels
|
52
51
|
} do
|
52
|
+
subscribe_request = { command: "subscribe", identifier: { channel: a_channel }.to_json }
|
53
|
+
|
54
|
+
client2.send(subscribe_request)
|
55
|
+
|
56
|
+
ack = {
|
57
|
+
"identifier" => { channel: a_channel }.to_json, "type" => "confirm_subscription"
|
58
|
+
}
|
59
|
+
|
60
|
+
assert_equal ack, client2.receive
|
61
|
+
|
62
|
+
subscribe_request = { command: "subscribe", identifier: { channel: b_channel }.to_json }
|
63
|
+
|
64
|
+
client2.send(subscribe_request)
|
65
|
+
|
66
|
+
ack = {
|
67
|
+
"identifier" => { channel: b_channel }.to_json, "type" => "confirm_subscription"
|
68
|
+
}
|
69
|
+
|
70
|
+
assert_equal ack, client2.receive
|
53
71
|
|
54
72
|
client2.close
|
55
73
|
|
56
|
-
msg = {
|
57
|
-
|
74
|
+
msg = {
|
75
|
+
"identifier" => { channel: a_channel }.to_json,
|
76
|
+
"message" => { "data" => "user left" }
|
77
|
+
}
|
78
|
+
msg2 = {
|
79
|
+
"identifier" => { channel: b_channel }.to_json,
|
80
|
+
"message" => { "data" => "user left" }
|
81
|
+
}
|
82
|
+
|
83
|
+
msgs = [client.receive, client.receive]
|
84
|
+
|
85
|
+
assert_includes msgs, msg
|
86
|
+
assert_includes msgs, msg2
|
87
|
+
end
|
88
|
+
|
89
|
+
scenario %{
|
90
|
+
Client disconnect invokes #unsubscribe callbacks
|
91
|
+
for multiple subscriptions from the same channel
|
92
|
+
} do
|
93
|
+
subscribe_request = { command: "subscribe", identifier: { channel: a_channel, id: 1 }.to_json }
|
94
|
+
|
95
|
+
client2.send(subscribe_request)
|
96
|
+
|
97
|
+
ack = {
|
98
|
+
"identifier" => { channel: a_channel, id: 1 }.to_json, "type" => "confirm_subscription"
|
99
|
+
}
|
100
|
+
|
101
|
+
assert_equal ack, client2.receive
|
102
|
+
|
103
|
+
subscribe_request = { command: "subscribe", identifier: { channel: a_channel, id: 2 }.to_json }
|
104
|
+
|
105
|
+
client2.send(subscribe_request)
|
106
|
+
|
107
|
+
ack = {
|
108
|
+
"identifier" => { channel: a_channel, id: 2 }.to_json, "type" => "confirm_subscription"
|
109
|
+
}
|
110
|
+
|
111
|
+
assert_equal ack, client2.receive
|
112
|
+
|
113
|
+
client2.close
|
114
|
+
|
115
|
+
msg = {
|
116
|
+
"identifier" => { channel: a_channel }.to_json,
|
117
|
+
"message" => { "data" => "user left1" }
|
118
|
+
}
|
119
|
+
|
120
|
+
msg2 = {
|
121
|
+
"identifier" => { channel: a_channel }.to_json,
|
122
|
+
"message" => { "data" => "user left2" }
|
123
|
+
}
|
58
124
|
|
59
125
|
msgs = [client.receive, client.receive]
|
60
126
|
|
data/lib/anyt/version.rb
CHANGED