anyt 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +1 -1
- data/etc/tests/channel_broadcast_test.rb +51 -0
- data/lib/anyt/cli.rb +9 -0
- data/lib/anyt/config.rb +7 -0
- data/lib/anyt/tests.rb +25 -11
- data/lib/anyt/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b518f7b895effeba08e97fd20a64dee5c7e0a09faff5b9df9072ae76cb9f02fa
|
4
|
+
data.tar.gz: fd4f53b7cb1601fa652e1d74d87b79081721ad2e1ed7e18dec93ca976a787a1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ab2923833c1a868ec9cb2e3c6532d9990c43fb95aa58cd1819bd904409e45b753be2ec8497ed23bc5c1e4a18ba6aa9802068852f8ebca08d60fc0c5b683914
|
7
|
+
data.tar.gz: f15eadfbc5f611697ad4bf25f0ec41ddc39e60f7389074a88a6e8ad6aada7de5301e10ba68e512deadb643d6e3b20c0496dbaa6f04d997086520da9c3d1083a6
|
data/Makefile
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
feature "Broadcast data from channel" do
|
4
|
+
channel do
|
5
|
+
def subscribed
|
6
|
+
stream_from "a"
|
7
|
+
end
|
8
|
+
|
9
|
+
def speak(msg)
|
10
|
+
ActionCable.server.broadcast "a", text: msg["msg"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:client2) { build_client(ignore: %w[ping welcome]) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
subscribe_request = { command: "subscribe", identifier: { channel: channel }.to_json }
|
18
|
+
|
19
|
+
client.send(subscribe_request)
|
20
|
+
client2.send(subscribe_request)
|
21
|
+
|
22
|
+
ack = {
|
23
|
+
"identifier" => { channel: channel }.to_json, "type" => "confirm_subscription"
|
24
|
+
}
|
25
|
+
|
26
|
+
assert_equal ack, client.receive
|
27
|
+
assert_equal ack, client2.receive
|
28
|
+
end
|
29
|
+
|
30
|
+
scenario %{
|
31
|
+
Multiple clients receive messages from stream
|
32
|
+
} do
|
33
|
+
perform_request = {
|
34
|
+
command: "message",
|
35
|
+
identifier: { channel: channel }.to_json,
|
36
|
+
"data" => { "action" => "speak", "msg" => "hey there!"}.to_json
|
37
|
+
}
|
38
|
+
|
39
|
+
client.send(perform_request)
|
40
|
+
|
41
|
+
msg = {
|
42
|
+
"identifier" => { channel: channel }.to_json,
|
43
|
+
"message" => {
|
44
|
+
"text" => "hey there!"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
assert_equal msg, client.receive
|
49
|
+
assert_equal msg, client2.receive
|
50
|
+
end
|
51
|
+
end
|
data/lib/anyt/cli.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "logger"
|
4
4
|
require "optparse"
|
5
5
|
|
6
|
+
require "anyt/version"
|
6
7
|
require "anyt/rpc"
|
7
8
|
require "anyt/command"
|
8
9
|
require "anyt/tests"
|
@@ -20,6 +21,8 @@ module Anyt
|
|
20
21
|
ActionCable.server.config.logger = Rails.logger = AnyCable.logger
|
21
22
|
|
22
23
|
result = 1
|
24
|
+
|
25
|
+
$stdout.puts "Starting AnyT v#{Anyt::VERSION} (pid: #{Process.pid})\n"
|
23
26
|
|
24
27
|
begin
|
25
28
|
# Load all test scenarios
|
@@ -92,6 +95,12 @@ module Anyt
|
|
92
95
|
Anyt.config.wait_command = timeout
|
93
96
|
end
|
94
97
|
|
98
|
+
cli.on("-rPATH", "--require=PATH",
|
99
|
+
"Path to additional tests (e.g. features/*.rb") do |path|
|
100
|
+
Anyt.config.tests_relative_path = path
|
101
|
+
ENV["ANYT_TESTS_RELATIVE_PATH"] = path
|
102
|
+
end
|
103
|
+
|
95
104
|
cli.on("--debug", "Enable debug mode.") do
|
96
105
|
AnyCable.config.debug = true
|
97
106
|
end
|
data/lib/anyt/config.rb
CHANGED
@@ -7,9 +7,16 @@ module Anyt
|
|
7
7
|
class Config < Anyway::Config
|
8
8
|
attr_config :command,
|
9
9
|
:only_tests,
|
10
|
+
:tests_relative_path,
|
10
11
|
target_url: "ws://localhost:9292/cable",
|
11
12
|
wait_command: 2
|
12
13
|
|
14
|
+
def tests_path
|
15
|
+
return unless tests_relative_path
|
16
|
+
|
17
|
+
File.expand_path(tests_relative_path, Dir.pwd)
|
18
|
+
end
|
19
|
+
|
13
20
|
def filter_tests?
|
14
21
|
!only_tests.nil?
|
15
22
|
end
|
data/lib/anyt/tests.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "anyt"
|
4
|
+
require "anyt/client"
|
5
|
+
require_relative "ext/minitest"
|
6
|
+
|
3
7
|
module Anyt
|
4
8
|
# Loads and runs test cases
|
5
9
|
module Tests
|
6
|
-
require "anyt/client"
|
7
|
-
require_relative "ext/minitest"
|
8
|
-
|
9
10
|
class << self
|
11
|
+
DEFAULT_PATTERNS = [
|
12
|
+
File.expand_path("tests/**/*.rb", __dir__)
|
13
|
+
].freeze
|
14
|
+
|
10
15
|
# Run all loaded tests
|
11
16
|
def run
|
12
17
|
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
@@ -24,15 +29,16 @@ module Anyt
|
|
24
29
|
def load_tests
|
25
30
|
return load_all_tests unless Anyt.config.filter_tests?
|
26
31
|
|
27
|
-
pattern = File.expand_path("tests/**/*.rb", __dir__)
|
28
32
|
skipped = []
|
29
33
|
filter = Anyt.config.tests_filter
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
test_files_patterns.each do |pattern|
|
36
|
+
Dir.glob(pattern).each do |file|
|
37
|
+
if file.match?(filter)
|
38
|
+
require file
|
39
|
+
else
|
40
|
+
skipped << file.gsub(File.join(__dir__, 'tests/'), '').gsub('_test.rb', '')
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
@@ -41,9 +47,17 @@ module Anyt
|
|
41
47
|
|
42
48
|
# Load all test files
|
43
49
|
def load_all_tests
|
44
|
-
|
50
|
+
test_files_patterns.each do |pattern|
|
51
|
+
Dir.glob(pattern).each { |file| require file }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
45
56
|
|
46
|
-
|
57
|
+
def test_files_patterns
|
58
|
+
@test_files_patterns ||= DEFAULT_PATTERNS.dup.tap do |patterns|
|
59
|
+
patterns << Anyt.config.tests_path if Anyt.config.tests_path
|
60
|
+
end
|
47
61
|
end
|
48
62
|
end
|
49
63
|
end
|
data/lib/anyt/version.rb
CHANGED
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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- bin/console
|
255
255
|
- bin/setup
|
256
256
|
- circle.yml
|
257
|
+
- etc/tests/channel_broadcast_test.rb
|
257
258
|
- lib/anyt.rb
|
258
259
|
- lib/anyt/cli.rb
|
259
260
|
- lib/anyt/client.rb
|