Sha256: f4358ebd227c2f174371825a165d66ba822c3914973b34fce21e06de121450c5

Contents?: true

Size: 872 Bytes

Versions: 9

Compression:

Stored size: 872 Bytes

Contents

# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

describe 'Zlib compression' do
  require_zlib_compression

  before do
    authorized_client['test'].drop
  end

  context 'when client has zlib compressor option enabled' do
    it 'compresses the message to the server' do
      # Double check that the client has zlib compression enabled
      expect(authorized_client.options[:compressors]).to include('zlib')

      expect(Mongo::Protocol::Compressed).to receive(:new).twice.and_call_original
      expect(Zlib::Deflate).to receive(:deflate).twice.and_call_original
      expect(Zlib::Inflate).to receive(:inflate).twice.and_call_original

      authorized_client['test'].insert_one(_id: 1, text: 'hello world')
      document = authorized_client['test'].find(_id: 1).first

      expect(document['text']).to eq('hello world')
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/integration/zlib_compression_spec.rb
mongo-2.20.1 spec/integration/zlib_compression_spec.rb
mogno-2.20.0 spec/integration/zlib_compression_spec.rb
mogno-1.0.0 spec/integration/zlib_compression_spec.rb
mongo-2.20.0 spec/integration/zlib_compression_spec.rb
mongo-2.19.3 spec/integration/zlib_compression_spec.rb
mongo-2.19.2 spec/integration/zlib_compression_spec.rb
mongo-2.19.1 spec/integration/zlib_compression_spec.rb
mongo-2.19.0 spec/integration/zlib_compression_spec.rb