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

Conversation

Vagab
Copy link
Contributor

@Vagab Vagab commented May 30, 2023

Problem

Test below will not pass:

# some_service.rb

class SomeService
  def call(record)
    record.broadcast_append_to(:some_records)
  end
end

# some_service_spec.rb

it "broadcasts to :some_records" do
  expect { SomeService.call(record) }.to broadcast_to(:some_records)
end

That is because internally rails does String(broadcasting), so test below would actually pass:

it "broadcasts to :some_records" do
  expect { SomeService.call(record) }.to broadcast_to("some_records")
end

Which is a bit counterintuitive.

Proposed solution

Just to_s if the channel passed is a symbol. Can possibly break if someone internally checks for symbolized channel, but the matcher should work.

@JonRowe JonRowe merged commit 7e61760 into rspec:main May 31, 2023
@JonRowe
Copy link
Member

JonRowe commented May 31, 2023

Thanks!

JonRowe added a commit that referenced this pull request May 31, 2023
JonRowe added a commit that referenced this pull request May 31, 2023
…o-matcher

Allow to use symbols for broadcasting target
JonRowe added a commit that referenced this pull request May 31, 2023
@Vagab Vagab deleted the allow-using-symbol-in-broadcast-to-matcher branch May 31, 2023 10:57
@JonRowe
Copy link
Member

JonRowe commented May 31, 2023

Released in 6.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants