Sha256: 83006ede61049ae96fb66edb67c0960c149a0ad9a25ffb590961c39eaebe08c1

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

shared_examples_for 'a trie data structure' do
  it 'contains all the words previously provided' do
    words.each do |word|
      expect(trie).to include word
      expect(trie.word? word).to be true
    end
  end

  it 'matches the start of all the words from the file' do
    words.each do |word|
      expect(trie.match? word).to be true
      expect(trie.match? word[0..-2]).to be true
      expect(trie.partial_word? word).to be true
      expect(trie.partial_word? word[0..-2]).to be true
    end
  end

  it 'identifies words within larger strings' do
    words.each do |word|
      phrase = "x#{word}y"
      expect(trie.words_within phrase).to include word
      expect(trie.words_within? phrase).to be true
    end
  end

  it 'allows iterating over all the words' do
    expect(trie.to_a.sort).to eq words.sort
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rambling-trie-1.0.3 spec/support/shared_examples/a_trie_data_structure.rb
rambling-trie-1.0.2 spec/support/shared_examples/a_trie_data_structure.rb
rambling-trie-1.0.1 spec/support/shared_examples/a_trie_data_structure.rb
rambling-trie-1.0.0 spec/support/shared_examples/a_trie_data_structure.rb