Skip to content

Commit

Permalink
Merge pull request #2680 from Vagab/allow-using-symbol-in-broadcast-t…
Browse files Browse the repository at this point in the history
…o-matcher

Allow to use symbols for broadcasting target
  • Loading branch information
JonRowe committed May 31, 2023
1 parent d21484b commit ec49d0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit ec49d0e

Please sign in to comment.