Sha256: e7348e0da53730fd6fe614c84e008356dd289fdd2de1a4161d76779fa097e7e7

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'lite_spec_helper'

describe 'Mongo::Crypt::Binding' do
  require_libmongocrypt

  describe '#mongocrypt_version' do
    let(:version) { Mongo::Crypt::Binding.mongocrypt_version(nil) }

    it 'is a string' do
      expect(version).to be_a_kind_of(String)
    end

    it 'is in the x.y.z-tag format' do
      expect(version).to match(/\A(\d+.){2}(\d+)?(-[A-Za-z\+\d]+)?\z/)
    end
  end

  describe '#validate_version' do
    context 'when not satisfied' do
      let(:older_version) do
        Mongo::Crypt::Binding::MIN_LIBMONGOCRYPT_VERSION.to_s.sub(/^\d+/, '0')
      end

      it 'raises an error' do
        expect do
          Mongo::Crypt::Binding.validate_version(older_version)
        end.to raise_error(LoadError, /libmongocrypt version .* or above is required, but version .* was found./)
      end
    end

    context 'when satisfied' do
      let(:newer_version) do
        Mongo::Crypt::Binding::MIN_LIBMONGOCRYPT_VERSION.bump.to_s
      end
      it 'does not raise and error' do
        expect do
          Mongo::Crypt::Binding.validate_version(newer_version)
        end.not_to raise_error(LoadError, /libmongocrypt version .* or above is required, but version .* was found./)
      end
    end

    context 'when in a non-parsable format' do
      it 'does not raise ArgumentError' do
        expect do
          Mongo::Crypt::Binding.validate_version("1.5.3-dev+20220730git8f8675fa11")
        end.not_to raise_error(ArgumentError, /Malformed version number string/)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongo-2.18.3 spec/mongo/crypt/binding/version_spec.rb
mongo-2.18.2 spec/mongo/crypt/binding/version_spec.rb
mongo-2.18.1 spec/mongo/crypt/binding/version_spec.rb