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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb7411c1afe37ebd51981648bbe24ceb80967e03189e99ac51c42d4be9f4ef5a
4
- data.tar.gz: '0009b2a240eb1a81c5506887eddbdf4e8ce502d5c74fdd34cf8bc3dcaa21b7be'
3
+ metadata.gz: 6993fd39f2e1cad04cc423a70ba7f15dcd44a6962c93f48e313b89e75a3d1c47
4
+ data.tar.gz: 1977fa24962781b903acd0d1909fd6ad5def66709d04934dba1319cbf11dfeda
5
5
  SHA512:
6
- metadata.gz: 48911f822229c658a154a20c8fd08fb7b6245b09a95776681aaad8b4f3101d773b6d99252129b027b5828ffcdd52fdf62ace6172f65f3639e8958d174098b4d3
7
- data.tar.gz: 6915a55afec899cd6cc8fa64b5641c97e9c30e1ff8408c56a344325bd5a0d54e3d13536d8cc8d66aecc12b1ef6736663cea590b0148222b9fcca4ecdf2dc8287
6
+ metadata.gz: 7f02b19da67f22d90fdf60ddcb3d24bfeb431dd87d80ccb1164288fd254028de65a1fefd70931b48cac0a0624ec21d76db2c5c91cd6b3be54be8d7414e88cc42
7
+ data.tar.gz: c9a7b23d5c8b139d28d2c30948661b80afb460c7e8093094b0f84773c59f5fa935796eb1dd67ccf55c0f58e001e893662152cfcb811a3fd510d1ce3d205d730d
@@ -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
- [client, client2].each do |client_|
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
- client_.send(subscribe_request)
29
+ client.send(subscribe_request)
31
30
 
32
- ack = {
33
- "identifier" => { channel: a_channel }.to_json, "type" => "confirm_subscription"
34
- }
31
+ ack = {
32
+ "identifier" => { channel: a_channel }.to_json, "type" => "confirm_subscription"
33
+ }
35
34
 
36
- assert_equal ack, client_.receive
35
+ assert_equal ack, client.receive
37
36
 
38
- subscribe_request = { command: "subscribe", identifier: { channel: b_channel }.to_json }
37
+ subscribe_request = { command: "subscribe", identifier: { channel: b_channel }.to_json }
39
38
 
40
- client_.send(subscribe_request)
39
+ client.send(subscribe_request)
41
40
 
42
- ack = {
43
- "identifier" => { channel: b_channel }.to_json, "type" => "confirm_subscription"
44
- }
41
+ ack = {
42
+ "identifier" => { channel: b_channel }.to_json, "type" => "confirm_subscription"
43
+ }
45
44
 
46
- assert_equal ack, client_.receive
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 = { "identifier" => { channel: a_channel }.to_json, "message" => { "data" => "user left" } }
57
- msg2 = { "identifier" => { channel: b_channel }.to_json, "message" => { "data" => "user left" } }
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anyt
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anyt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan