anyt 1.0.1 → 1.0.2

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: 75c73a6373cc4d26033b8fd5caf3d8b5601d06644227f7ee279818b8fc5e4afd
4
- data.tar.gz: d187153da7f0e4b3d7aae6d5a67594a66817beac1364e7741b0b2fb98b2ef7b3
3
+ metadata.gz: cc9f527d5ead1058291854236f7b011c64df27da0be2559bb27893c1dbb471fc
4
+ data.tar.gz: 0dce342de8720db9d2208e4fc44c7c1ba3b489c0d82bce7b936152df2c70ccca
5
5
  SHA512:
6
- metadata.gz: 1b06df7c02346d0c6986f42e5e71b33875c99ee0924c41a31ea4de574b3b65eaf15069f410962aaf6d62a1af511efd9505f49ade5cbf9815f2bdec00e5a7ff51
7
- data.tar.gz: 4955e07d7fac679f27f55604faea71d513bc66cfaf85abcd2e6f46db375a706a6d9d281ad36529f7d124a2e7242a777d4c83d11ec6020bfe9160f0bfbb076bfe
6
+ metadata.gz: 6237b496a2cfb034d4b0d83eff127be84c360a124039bf14c32e4886732f9b9cff9def7e1515168dc87027ca85bcc64b78dfdd4d10988a1e84206b9fc4be7b3a
7
+ data.tar.gz: 9cd9d41ebdaf1321d13a08685b1955fe92875fb86fda8c4a230b1df9d30e7e39e5564a2614fb1693666a203926770cbdf3d9a0fda7265f3893524baa7cb8f89a
@@ -7,16 +7,25 @@ feature "Channel state" do
7
7
  def subscribed
8
8
  self.user = {name: params["name"]}
9
9
  self.count = 1
10
+
11
+ stream_from "state_counts"
10
12
  end
11
13
 
12
14
  def tick
13
15
  self.count += 2
14
16
  transmit(count: count, name: user[:name])
15
17
  end
18
+
19
+ def unsubscribed
20
+ ActionCable.server.broadcast("state_counts", data: "user left: #{user[:name]}")
21
+ end
16
22
  end
17
23
 
18
24
  let(:identifier) { {channel: channel, name: "chipolino"}.to_json }
19
25
 
26
+ let(:client2) { build_client(ignore: %w[ping welcome]) }
27
+ let(:identifier2) { {channel: channel, name: "chipollone"}.to_json }
28
+
20
29
  before do
21
30
  subscribe_request = {command: "subscribe", identifier: identifier}
22
31
 
@@ -44,4 +53,27 @@ feature "Channel state" do
44
53
 
45
54
  assert_equal msg, client.receive
46
55
  end
56
+
57
+ scenario %(
58
+ Channel state is available in #unsubscribe callbacks
59
+ ) do
60
+ subscribe_request = {command: "subscribe", identifier: identifier2}
61
+
62
+ client2.send(subscribe_request)
63
+
64
+ ack = {
65
+ "identifier" => identifier2, "type" => "confirm_subscription"
66
+ }
67
+
68
+ assert_equal ack, client2.receive
69
+
70
+ client.close
71
+
72
+ msg = {
73
+ "identifier" => identifier2,
74
+ "message" => {"data" => "user left: chipolino"}
75
+ }
76
+
77
+ assert_equal msg, client2.receive
78
+ end
47
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anyt
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anyt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack