class ActionCable::Connection::TestCase


end
tests ApplicationCable::Connection
class ConnectionTest < ActionCable::Connection::TestCase
class name, you can explicitly set it with tests.
from the test class name. If the channel cannot be inferred from the test
ActionCable::Connection::TestCase will automatically infer the connection under test
== Connection is automatically inferred
end
assert_equal “1”, connection.user_id
connect
# cookies.encrypted = 1
# cookies.signed = 1
# Or signed/encrypted:<br><br>cookies = 1
# Plain cookies:
def test_connect_with_cookies
You can also set up the correct cookies before the connection request:
end
assert_equal “1”, connection.user.id
connect params: { user_id: 1 }
def test_connect_with_params
end
assert_equal “secret-my”, connection.token
assert_equal “1”, connection.user.id
connect params: { user_id: 1 }, headers: { “X-API-TOKEN” => “secret-my” }
def test_connect_with_headers_and_query_string
params, headers, session and Rack env options.
connect accepts additional information about the HTTP request with the
end
end
assert_reject_connection { connect }
def test_rejects_connection_without_proper_cookie
end
assert_equal users(:john).id, connection.user.id
# Assert the connection identifier matches the fixture.<br><br>connect<br><br>cookies = users(:john).id
# Simulate the connection request with a cookie.
def test_connects_with_proper_cookie
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
2. Assert state, e.g. identifiers, has been assigned.
1. Simulate a connection attempt by calling connect.
Unit tests are written as follows:
== Basic example
and that any improper connection requests are rejected.
Useful to check whether a connection’s identified_by gets assigned properly
Unit test Action Cable connections.