Sha256: 534528e5e5e2aab5657924b5ed6c90e0c2f2aac5cdef33941ab01a65b87636a4

Contents?: true

Size: 1.66 KB

Versions: 6

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 zip)
      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

6 entries across 6 versions & 1 rubygems

Version Path
rambling-trie-2.3.0 spec/lib/rambling/trie/configuration/properties_spec.rb
rambling-trie-2.2.1 spec/lib/rambling/trie/configuration/properties_spec.rb
rambling-trie-2.2.0 spec/lib/rambling/trie/configuration/properties_spec.rb
rambling-trie-2.1.1 spec/lib/rambling/trie/configuration/properties_spec.rb
rambling-trie-2.1.0 spec/lib/rambling/trie/configuration/properties_spec.rb
rambling-trie-2.0.0 spec/lib/rambling/trie/configuration/properties_spec.rb