class ActionCable::Connection::TestCase

Public Instance Methods

assert_reject_connection() click to toggle source

Asserts that the connection is rejected (via reject_unauthorized_connection).

class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
  def test_connects_with_proper_cookie
    # Simulate the connection request with a cookie.
    cookies["user_id"] = users(:john).id

    connect

    # Assert the connection identifier matches the fixture.
    assert_equal users(:john).id, connection.user.id
  end

  def test_rejects_connection_without_proper_cookie
    assert_reject_connection { connect }
  end
end

See also Minitest::Rails::Expectations::ActionCable#must_reject_connection See api.rubyonrails.org/v7.0/classes/ActionCable/Connection/Assertions.html#method-i-assert_reject_connection

# File lib/minitest/rails/assertions/action_cable.rb, line 231