Sha256: 4b388d02710d7ec3e16968a9c2c8e829dfce294b11beaaccea2f6b9094978cc3

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Rambling::Trie::Configuration::Properties do
  let(:properties) { Rambling::Trie::Configuration::Properties.new }

  describe '.new' do
    it 'configures the serializers' do
      serializers = properties.serializers

      expect(serializers.formats).to match_array %i(marshal yaml yml)
      expect(serializers.providers.to_a).to match_array [
        [:marshal, Rambling::Trie::Serializers::Marshal],
        [:yaml, Rambling::Trie::Serializers::Yaml],
        [:yml, Rambling::Trie::Serializers::Yaml],
        # [:zip, Rambling::Trie::Serializers::Zip],
      ]
    end

    it 'configures the readers' do
      readers = properties.readers

      expect(readers.formats).to match_array %i(txt)
      expect(readers.providers.to_a).to match_array [
        [:txt, Rambling::Trie::Readers::PlainText],
      ]
    end

    it 'configures the compressor' do
      compressor = properties.compressor
      expect(compressor).to be_instance_of Rambling::Trie::Compressor
    end

    it 'configures the root_builder' do
      root = properties.root_builder.call
      expect(root).to be_instance_of Rambling::Trie::Nodes::Raw
    end
  end

  describe '#reset' do
    before do
      properties.serializers.add :test, 'test'
      properties.readers.add :test, 'test'
    end

    it 'resets the serializers and readers to initial values' do
      expect(properties.serializers.formats).to include :test
      expect(properties.readers.formats).to include :test

      properties.reset

      expect(properties.serializers.formats).not_to include :test
      expect(properties.readers.formats).not_to include :test
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambling-trie-opal-2.1.1 spec/lib/rambling/trie/configuration/properties_spec.rb