Sha256: d4f432f783059abca91a6d79e02cd7c36143b2ad595020b200d1836ef4b32954
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Rambling::Trie::Inspectable do let(:root) { Rambling::Trie::RawNode.new } before do %w(only three words).each { |word| root.add word } end describe '#inspect' do let(:node) { root[:o] } let(:terminal_node) { root[:o][:n][:l][:y] } it 'returns a pretty printed version of the node' do expect(root.inspect).to eq "#<Rambling::Trie::RawNode letter: nil, terminal: nil, children: [:o, :t, :w]>" expect(node.inspect).to eq "#<Rambling::Trie::RawNode letter: :o, terminal: nil, children: [:n]>" expect(terminal_node.inspect).to eq "#<Rambling::Trie::RawNode letter: :y, terminal: true, children: []>" end context 'for a compressed node' do let(:compressor) { Rambling::Trie::Compressor.new } let(:compressed_root) { compressor.compress root } let(:compressed_node) { compressed_root[:only] } it 'returns a pretty printed version of the compressed node' do expect(compressed_root.inspect).to eq "#<Rambling::Trie::CompressedNode letter: nil, terminal: nil, children: [:only, :three, :words]>" expect(compressed_node.inspect).to eq "#<Rambling::Trie::CompressedNode letter: :only, terminal: true, children: []>" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems