1
0
Fork 0
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:
bogdanvlviv 2018-08-23 12:39:03 +03:00
parent d2ccf0c6f7
commit 86e7de7968
No known key found for this signature in database
GPG key ID: E4ACD76A6DB6DFDD
2 changed files with 13 additions and 2 deletions

View file

@ -47,11 +47,12 @@ module ActionCable
original_count = broadcasts_size(stream)
yield
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
actual_count = broadcasts_size(stream)
assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent"
end
assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent"
end
# Asserts that no messages have been sent to the stream.

View file

@ -62,6 +62,16 @@ class TransmissionsTest < ActionCable::TestCase
assert_match(/1 .* but 2/, error.message)
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
class TransmitedDataTest < ActionCable::TestCase