Sha256: 3d3be3568847713ef0191f112f1af84f36a79076ab64d47c294f30868163e0a0

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

require 'spec_helper'

describe Rambling::Trie::Nodes::Compressed do
  let(:raw_node) { Rambling::Trie::Nodes::Raw.new }
  let(:compressor) { Rambling::Trie::Compressor.new }
  let(:node) { compressor.compress raw_node }

  it_behaves_like 'a trie node implementation' do
    def add_word_to_tree word
      add_word raw_node, word
    end

    def add_words_to_tree words
      add_words raw_node, words
    end

    def assign_letter letter
      raw_node.letter = letter
    end
  end

  describe '#compressed?' do
    it 'returns true' do
      expect(node).to be_compressed
    end
  end

  describe '#add' do
    it 'raises an error' do
      expect do
        add_word node, 'restaurant'
      end.to raise_error Rambling::Trie::InvalidOperation
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambling-trie-1.0.3 spec/lib/rambling/trie/nodes/compressed_spec.rb