Module: ActionCable::Connection::Assertions

Included in:
TestCase::Behavior
Defined in:
lib/action_cable/connection/test_case.rb

Instance Method Summary collapse

Instance Method Details

#assert_reject_connection(&block) ⇒ Object

Asserts that the connection is rejected (via reject_unauthorized_connection).

# Asserts that connection without user_id fails
assert_reject_connection { connect cookies: { user_id: '' } }


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/action_cable/connection/test_case.rb', line 24

def assert_reject_connection(&block)
  res =
    begin
      block.call
      false
    rescue ActionCable::Connection::Authorization::UnauthorizedError
      true
    end

  assert res, "Expected to reject connection but no rejection were made"
end