Sha256: 41ae89a41e0250cf4bbfcc862c189146c9a6cb7ea98e7d842c813cd72b38841f

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 Bytes

Contents

require_relative 'spec_helper'

describe Melisa::BytesTrie do
  let(:hash) { {'one' => '1', 'two' => '2', 'onetwo' => '3'} }
  let(:trie) { Melisa::BytesTrie.new(hash) }

  it "stores values" do
    expect(trie['one']).to eq '1'
    expect(trie['two']).to eq '2'
    expect(trie['onetwo']).to eq '3'
  end

  it "sets and gets values" do
    trie['five'] = "5"
    expect(trie['five']).to eq "5"
  end

  it "retreives many values by prefix" do
    expect(trie.get_all('one')).to match_array ['1', '3']
  end

  it "#each iterates alphabetically and yields key/value pairs" do
    expect { |b| trie.each(&b) }.to \
      yield_successive_args(['onetwo', '3'], ['one', '1'], ['two', '2'])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
melisa-0.2.5 spec/bytes_trie_spec.rb
melisa-0.2.4 spec/bytes_trie_spec.rb
melisa-0.2.3 spec/bytes_trie_spec.rb