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
2 parents 41720be + 594b3e5 commit 7e61760
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
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

0 comments on commit 7e61760

Please sign in to comment.