anyt-core 1.3.1 → 1.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5abc6a66da48cd93e93f47f95c6e9611856c19e470cc8342934c1d9b7582214
4
- data.tar.gz: 2bf91947847c7b71ccb44b4c3988e237309eb5c063f74201bb71be3d41a2f5b9
3
+ metadata.gz: 926764e1377b6d46fecd5ac2027327e22e1641b74b6de7a6c8d46ad0f8aa2926
4
+ data.tar.gz: 924c6b0ba6db8853a2fbb48d1f2710651c08fb7126292037e633182a7d4b9066
5
5
  SHA512:
6
- metadata.gz: cad2ec2427b323b82e97f1a4a8894cb04f1db45034880007b7b120db401af929b738ac0b8274f4dcfe462dee136bbafd3996afe45230135f567a2c2c97c55c65
7
- data.tar.gz: 3b92c26e7c2347e8e3452928e17a85c7a70d1b9ed862f25513cd15e3ffafb1665ac9d9fdd9bdf041b51df0a0360742d0351680136a9cab2b0f1105d6c3beacca
6
+ metadata.gz: 7720b7b1c5855e11d091e2591d59656e6c0659a898e8590e9eb190254b8498a09a67b08d592b718ad364a1e180667e6e526c6c6e4669c3b62f16ad849bac85cd
7
+ data.tar.gz: d96f721e762200f4e4e247e718cd5e6da73cca4cdc487fe02aabd778dc52e5c7a36c2357b4d905a183df625a238865069946a2b85111e3d3f4d0aa94b1805d98
data/lib/anyt/cli.rb CHANGED
@@ -25,6 +25,12 @@ module Anyt
25
25
  def run(args = ARGV)
26
26
  parse_options!(args)
27
27
 
28
+ if Anyt.config.list_tests
29
+ Tests.load_tests
30
+ Tests.list
31
+ return 0
32
+ end
33
+
28
34
  ActionCable.server.config.logger = Rails.logger = AnyCable.logger
29
35
 
30
36
  result = 1
@@ -128,12 +134,22 @@ module Anyt
128
134
  configure_rails_command!
129
135
  end
130
136
 
137
+ cli.on("-l", "--list", TrueClass, "List test scenarios") do
138
+ Anyt.config.list_tests = true
139
+ @skip_rpc = true
140
+ end
141
+
131
142
  cli.on("--self-check", "Run tests again Action Cable itself") do
132
143
  @skip_rpc = true
133
144
 
134
145
  configure_rails_command!
135
146
  end
136
147
 
148
+ cli.on("--rails-command=COMMAND", "A custom command to run Rails server") do |cmd|
149
+ configure_rails_command!(cmd)
150
+ Anyt.config.custom_action_cable = true
151
+ end
152
+
137
153
  cli.on("--only test1,test2,test3", Array, "Run only specified tests") do |only_tests|
138
154
  Anyt.config.only_tests = only_tests
139
155
  end
@@ -142,6 +158,10 @@ module Anyt
142
158
  Anyt.config.except_tests = except_tests
143
159
  end
144
160
 
161
+ cli.on("-e filter", "Run only tests matching the descripton") do |filter_tests|
162
+ Anyt.config.filter_tests = filter_tests
163
+ end
164
+
145
165
  cli.on("--wait-command=TIMEOUT", Integer,
146
166
  "Number of seconds to wait for WS server initialization") do |timeout|
147
167
  Anyt.config.wait_command = timeout
@@ -181,8 +201,8 @@ module Anyt
181
201
  exit 1
182
202
  end
183
203
 
184
- def configure_rails_command!
185
- Anyt.config.command = RAILS_COMMAND
204
+ def configure_rails_command!(cmd = RAILS_COMMAND)
205
+ Anyt.config.command = cmd % {config: DUMMY_ROOT}
186
206
  Anyt.config.use_action_cable = true
187
207
  end
188
208
 
data/lib/anyt/command.rb CHANGED
@@ -59,6 +59,7 @@ module Anyt
59
59
  AnyCable.logger.debug "Restarting command PID: #{process.pid}"
60
60
 
61
61
  stop
62
+
62
63
  process.wait
63
64
 
64
65
  run
data/lib/anyt/config.rb CHANGED
@@ -8,9 +8,12 @@ module Anyt
8
8
  attr_config :command,
9
9
  :only_tests,
10
10
  :except_tests,
11
+ :filter_tests,
12
+ :list_tests,
11
13
  :tests_relative_path,
12
14
  remote_control_port: 8919,
13
15
  use_action_cable: false,
16
+ custom_action_cable: false,
14
17
  target_url: "ws://localhost:9292/cable",
15
18
  wait_command: 2,
16
19
  timeout_multiplier: 1
@@ -37,5 +40,11 @@ module Anyt
37
40
  (except_rxp.nil? || !except_rxp.match?(path))
38
41
  end
39
42
  end
43
+
44
+ def example_filter
45
+ return unless filter_tests
46
+
47
+ /#{filter_tests}/i
48
+ end
40
49
  end
41
50
  end
@@ -55,8 +55,10 @@ class BenchmarkChannel < ApplicationCable::Channel
55
55
  end
56
56
 
57
57
  def echo(data)
58
- if ECHO_DELAY > 0
59
- sleep ECHO_DELAY
58
+ puts "ECHO: #{data.inspect}" if data["verbose"]
59
+ delay = data.fetch("delay", ECHO_DELAY).to_f
60
+ if delay > 0
61
+ sleep delay
60
62
  end
61
63
  transmit data
62
64
  end
@@ -21,7 +21,7 @@ module Anyt
21
21
  end
22
22
 
23
23
  def restart_server!
24
- if Anyt.config.use_action_cable
24
+ if Anyt.config.use_action_cable && !Anyt.config.custom_action_cable
25
25
  remote_client.restart_action_cable
26
26
  else
27
27
  Command.restart
@@ -84,8 +84,8 @@ end
84
84
  # Kernel extensions
85
85
  module Kernel
86
86
  ## Wraps `describe` and include shared helpers
87
- private def feature(*args, &block)
88
- cls = describe(*args, &block)
87
+ private def feature(...)
88
+ cls = describe(...)
89
89
  cls.include Anyt::TestHelpers
90
90
  cls
91
91
  end
@@ -96,6 +96,9 @@ module Minitest::Spec::DSL
96
96
  # Simplified version of `it` which doesn't care
97
97
  # about unique method names
98
98
  def scenario(desc, &block)
99
+ full_desc = "#{name.gsub("\n", " ").strip} #{desc.gsub("\n", " ").strip}"
100
+ return if Anyt.config.example_filter && !Anyt.config.example_filter.match?(full_desc)
101
+
99
102
  block ||= proc { skip "(no tests defined)" }
100
103
 
101
104
  define_method "test_ #{desc}", &block
@@ -105,12 +108,12 @@ module Minitest::Spec::DSL
105
108
 
106
109
  # Generates Channel class dynamically and
107
110
  # add memoized helper to access its name
108
- def channel(id = nil, &block)
111
+ def channel(id = nil, &)
109
112
  class_name = @name.gsub(/\s+/, "_")
110
113
  class_name += "_#{id}" if id
111
114
  class_name += "_channel"
112
115
 
113
- cls = Class.new(ApplicationCable::Channel, &block)
116
+ cls = Class.new(ApplicationCable::Channel, &)
114
117
 
115
118
  Anyt::TestChannels.const_set(class_name.classify, cls)
116
119
 
@@ -120,8 +123,8 @@ module Minitest::Spec::DSL
120
123
  end
121
124
 
122
125
  # Add new #connect handler
123
- def connect_handler(tag, &block)
124
- Anyt::ConnectHandlers.add(tag, &block)
126
+ def connect_handler(tag, &)
127
+ Anyt::ConnectHandlers.add(tag, &)
125
128
  end
126
129
  end
127
130
 
data/lib/anyt/tests.rb CHANGED
@@ -17,9 +17,29 @@ module Anyt
17
17
  Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
18
18
 
19
19
  AnyCable.logger.debug "Run tests against: #{Anyt.config.target_url}"
20
+
20
21
  Minitest.run
21
22
  end
22
23
 
24
+ def list
25
+ printer = Object.new
26
+ printer.extend include ANSI::Code
27
+
28
+ Minitest::Runnable.runnables.each do |runnable|
29
+ def runnable.test_order
30
+ :sorted
31
+ end
32
+ next unless runnable.runnable_methods.any?
33
+
34
+ $stdout.puts(runnable.name)
35
+
36
+ runnable.runnable_methods.each do |method|
37
+ test_name = method.gsub(/^test_/, "").strip
38
+ $stdout.puts(printer.magenta { " #{test_name}" })
39
+ end
40
+ end
41
+ end
42
+
23
43
  # Load tests code (filtered if present)
24
44
  #
25
45
  # NOTE: We should run this before launching RPC server
data/lib/anyt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anyt
4
- VERSION = "1.3.1"
4
+ VERSION = "1.4.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anyt-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-08 00:00:00.000000000 Z
11
+ date: 2024-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -153,14 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="
155
155
  - !ruby/object:Gem::Version
156
- version: 2.6.0
156
+ version: 3.1.0
157
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  requirements:
159
159
  - - ">="
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  requirements: []
163
- rubygems_version: 3.4.20
163
+ rubygems_version: 3.5.18
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Action Cable / AnyCable conformance testing tool