File: protocol.rb

package info (click to toggle)
ruby-mongo 2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,020 kB
  • sloc: ruby: 110,810; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 841 bytes parent folder | download
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
36
# frozen_string_literal: true
# rubocop:todo all

shared_examples 'message with a header' do
  let(:collection_name) { 'test' }

  describe 'header' do
    describe 'length' do
      let(:field) { bytes.to_s[0..3] }
      it 'serializes the length' do
        expect(field).to be_int32(bytes.length)
      end
    end

    describe 'request id' do
      let(:field) { bytes.to_s[4..7] }
      it 'serializes the request id' do
        expect(field).to be_int32(message.request_id)
      end
    end

    describe 'response to' do
      let(:field) { bytes.to_s[8..11] }
      it 'serializes the response to' do
        expect(field).to be_int32(0)
      end
    end

    describe 'op code' do
      let(:field) { bytes.to_s[12..15] }
      it 'serializes the op code' do
        expect(field).to be_int32(opcode)
      end
    end
  end
end