actioncable-next 0.1.0 → 0.1.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: a2a646309358247e05b84be4246c044bfae6f289eab7776e5821d6c54e8b1f00
4
- data.tar.gz: d2ec2b1f743af72cdc61a8be7c41e80778cff79d9335baa059fbd791272cf07a
3
+ metadata.gz: 0b463a6b0bafa3fa77350a4ff39ef12798703419107290828e932de40921150e
4
+ data.tar.gz: faf485a9167ab4d82c06fb5193ef8b8d6a17decc3096429e9432c2041a8482b6
5
5
  SHA512:
6
- metadata.gz: 8ff34021af6ec2c0e69676ba92fb64f2f1c9a9141db355eaa1f16fc7e9e7f3e4689b79efd86ebada9fd698e9b76bf95a214969198feb0c4334bbebb86a0597ec
7
- data.tar.gz: aed1822bc56226c76a02f6d9a95f3bc915fe429d3345bd3dbbc964ef6e384337347ed0496427b609788846951409042accb001ca157519f746997d512665b0d3
6
+ metadata.gz: e6686c1a5d31ec5b2867431612557ad4a0a3d13949b8876b42af43b96d87041bbb3a7df453c2b0db5f0231f6b71b0cee9376f1830c58e39aec87ecb52a41f22c
7
+ data.tar.gz: 46c4a80b030a7fc1e81383c8a4fd21fd3197c464965fbc2fb52e6f4a4fcec64b02b3f7d96b3efecaffbec811308d41aa678d0e30df8816743ec388d319d9ff9d
data/CHANGELOG.md CHANGED
@@ -2,4 +2,10 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.1.1
6
+
7
+ - Added RSpec patch.
8
+
9
+ ## 0.1.0
10
+
5
11
  - Initial extraction.
data/README.md CHANGED
@@ -15,3 +15,14 @@ gem "rails", "~> 7.0"
15
15
  ```
16
16
 
17
17
  Then, you can use Action Cable as before. Under the hood, the new implementation would be used.
18
+
19
+ ### RSpec support
20
+
21
+ This gem also includes the corresponding patch for RSpec Rails (see [PR](https://github.com/palkan/rspec-rails/pull/1)). You MUST activate it explicitly
22
+ by adding the following line to your `spec/rails_helper.rb`:
23
+
24
+ ```ruby
25
+ # after rspec-rails is loaded
26
+ require "rspec/rails"
27
+ require "action_cable/next/rspec"
28
+ ```
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # RSpec patches from https://github.com/palkan/rspec-rails/pull/1
4
+
5
+ require "rspec/rails/example/channel_example_group"
6
+
7
+ if defined?(RSpec::Rails::ChannelExampleGroup)
8
+ RSpec::Rails::ChannelExampleGroup.prepend(Module.new do
9
+ def connection_class
10
+ (_connection_class || described_class).then do |klass|
11
+ # Connection class either specified explicitly or is a described class
12
+ next klass if klass && klass <= ::ActionCable::Connection::Base
13
+
14
+ # Otherwise, fallback to the default connection class
15
+ tests_connection ::ActionCable.server.config.connection_class.call
16
+
17
+ _connection_class
18
+ end
19
+ end
20
+ end)
21
+ end
22
+
23
+ RSpec::Rails::Matchers::ActionCable::HaveStream.prepend(Module.new do
24
+ def match(subscription)
25
+ case subscription
26
+ when ::ActionCable::Channel::Base
27
+ @actual = streams_for(subscription)
28
+ no_expected? ? actual.any? : actual.any? { |i| expected === i }
29
+ else
30
+ raise ArgumentError, "have_stream, have_stream_from and have_stream_from support expectations on subscription only"
31
+ end
32
+ end
33
+
34
+ private
35
+ def streams_for(subscription)
36
+ # In Rails 8, subscription.streams returns a real subscriptions hash,
37
+ # not a fake array of stream names like in Rails 6-7.
38
+ # So, we must use #stream_names instead.
39
+ subscription.respond_to?(:stream_names) ? subscription.stream_names : subscription.streams
40
+ end
41
+ end)
data/lib/action_cable.rb CHANGED
@@ -39,6 +39,7 @@ Zeitwerk::Loader.for_gem.tap do |loader|
39
39
  "#{lib}/action_cable/version.rb",
40
40
  "#{lib}/action_cable/deprecator.rb",
41
41
  "#{lib}/actioncable-next.rb",
42
+ "#{lib}/action_cable/next",
42
43
  )
43
44
 
44
45
  loader.do_not_eager_load(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionCableNext
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actioncable-next
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pratik Naik
@@ -125,6 +125,7 @@ files:
125
125
  - lib/action_cable/engine.rb
126
126
  - lib/action_cable/gem_version.rb
127
127
  - lib/action_cable/helpers/action_cable_helper.rb
128
+ - lib/action_cable/next/rspec.rb
128
129
  - lib/action_cable/remote_connections.rb
129
130
  - lib/action_cable/server/base.rb
130
131
  - lib/action_cable/server/broadcasting.rb
@@ -166,7 +167,7 @@ licenses:
166
167
  - MIT
167
168
  metadata:
168
169
  bug_tracker_uri: https://github.com/anycable/actioncable-next
169
- changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.1.0/CHANGELOG.md
170
+ changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.1.1/CHANGELOG.md
170
171
  source_code_uri: https://github.com/anycable/actioncable-next
171
172
  rubygems_mfa_required: 'true'
172
173
  post_install_message: