mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
DRY in assert_broadcasts
Test `assert_no_broadcasts` failure
This commit is contained in:
parent
d2ccf0c6f7
commit
86e7de7968
2 changed files with 13 additions and 2 deletions
|
@ -47,11 +47,12 @@ module ActionCable
|
||||||
original_count = broadcasts_size(stream)
|
original_count = broadcasts_size(stream)
|
||||||
yield
|
yield
|
||||||
new_count = broadcasts_size(stream)
|
new_count = broadcasts_size(stream)
|
||||||
assert_equal number, new_count - original_count, "#{number} broadcasts to #{stream} expected, but #{new_count - original_count} were sent"
|
actual_count = new_count - original_count
|
||||||
else
|
else
|
||||||
actual_count = broadcasts_size(stream)
|
actual_count = broadcasts_size(stream)
|
||||||
assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that no messages have been sent to the stream.
|
# Asserts that no messages have been sent to the stream.
|
||||||
|
|
|
@ -62,6 +62,16 @@ class TransmissionsTest < ActionCable::TestCase
|
||||||
|
|
||||||
assert_match(/1 .* but 2/, error.message)
|
assert_match(/1 .* but 2/, error.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_assert_no_broadcasts_failure
|
||||||
|
error = assert_raises Minitest::Assertion do
|
||||||
|
assert_no_broadcasts "test" do
|
||||||
|
ActionCable.server.broadcast "test", "hello"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_match(/0 .* but 1/, error.message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TransmitedDataTest < ActionCable::TestCase
|
class TransmitedDataTest < ActionCable::TestCase
|
||||||
|
|
Loading…
Reference in a new issue