-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,10 @@ | |
|
||
## main | ||
|
||
## 0.1.1 | ||
|
||
- Added RSpec patch. | ||
|
||
## 0.1.0 | ||
|
||
- Initial extraction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# RSpec patches from https://github.com/palkan/rspec-rails/pull/1 | ||
|
||
require "rspec/rails/example/channel_example_group" | ||
|
||
if defined?(RSpec::Rails::ChannelExampleGroup) | ||
RSpec::Rails::ChannelExampleGroup.prepend(Module.new do | ||
def connection_class | ||
(_connection_class || described_class).then do |klass| | ||
# Connection class either specified explicitly or is a described class | ||
next klass if klass && klass <= ::ActionCable::Connection::Base | ||
|
||
# Otherwise, fallback to the default connection class | ||
tests_connection ::ActionCable.server.config.connection_class.call | ||
|
||
_connection_class | ||
end | ||
end | ||
end) | ||
end | ||
|
||
RSpec::Rails::Matchers::ActionCable::HaveStream.prepend(Module.new do | ||
def match(subscription) | ||
case subscription | ||
when ::ActionCable::Channel::Base | ||
@actual = streams_for(subscription) | ||
no_expected? ? actual.any? : actual.any? { |i| expected === i } | ||
else | ||
raise ArgumentError, "have_stream, have_stream_from and have_stream_from support expectations on subscription only" | ||
end | ||
end | ||
|
||
private | ||
def streams_for(subscription) | ||
# In Rails 8, subscription.streams returns a real subscriptions hash, | ||
# not a fake array of stream names like in Rails 6-7. | ||
# So, we must use #stream_names instead. | ||
subscription.respond_to?(:stream_names) ? subscription.stream_names : subscription.streams | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActionCableNext | ||
VERSION = "0.1.0" | ||
VERSION = "0.1.1" | ||
end |