Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use symbols for broadcasting target #2680

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb
Expand Up @@ -96,8 +96,11 @@ def from_channel(channel)
private

def stream
@stream ||= if @target.is_a?(String)
@stream ||= case @target
when String
@target
when Symbol
@target.to_s
else
check_channel_presence
@channel.broadcasting_for(@target)
Expand Down
Expand Up @@ -50,6 +50,12 @@ def broadcast(stream, msg)
}.to have_broadcasted_to('stream')
end

it "passes when using symbol target" do
expect {
broadcast(:stream, 'hello')
}.to have_broadcasted_to(:stream)
end

it "passes when using alias" do
expect {
broadcast('stream', 'hello')
Expand Down