Skip to content

Instantly share code, notes, and snippets.

@gmaliar
Created February 11, 2019 10:07
Show Gist options
  • Save gmaliar/721c359f41ef6d33691830e8762fde86 to your computer and use it in GitHub Desktop.
Save gmaliar/721c359f41ef6d33691830e8762fde86 to your computer and use it in GitHub Desktop.
def test_broadcasts
assert_broadcasts 'messages', 0
ActionCable.server.broadcast 'messages', { text: 'hello' }
assert_broadcasts 'messages', 1
end
def test_subscribed_with_room_number
subscribe room_number: 1
assert subscription.confirmed?
assert_has_stream "chat_1"
assert_has_stream_for Room.find(1)
end
def test_perform_speak
subscribe room_number: 1
perform :speak, message: "Hello, Rails!"
assert_equal "Hello, Rails!", transmissions.last["text"]
end
def test_connects_with_cookies
connect cookies: { user_id: users[:john].id }
assert_equal "John", connection.user.name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment