File: server_75_spec.rb

package info (click to toggle)
ruby-websocket 1.2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 464 kB
  • sloc: ruby: 2,669; makefile: 4
file content (35 lines) | stat: -rw-r--r-- 1,044 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Server draft 75 handshake' do
  let(:handshake) { WebSocket::Handshake::Server.new }

  let(:version) { 75 }
  let(:client_request) { client_handshake_75(@request_params || {}) }
  let(:server_response) { server_handshake_75(@request_params || {}) }

  it_behaves_like 'all server drafts'

  context 'protocol header specified' do
    let(:handshake) { WebSocket::Handshake::Server.new(protocols: %w[binary]) }

    context 'supported' do
      it 'returns with the same protocol' do
        @request_params = { headers: { 'WebSocket-Protocol' => 'binary' } }
        handshake << client_request

        expect(handshake.to_s).to match('WebSocket-Protocol: binary')
      end
    end

    context 'unsupported' do
      it 'returns with an empty protocol header' do
        @request_params = { headers: { 'WebSocket-Protocol' => 'xmpp' } }
        handshake << client_request

        expect(handshake.to_s).to match("WebSocket-Protocol: \r\n")
      end
    end
  end
end