spec/lib/rambling/trie/stringifyable_spec.rb in rambling-trie-1.0.2 vs spec/lib/rambling/trie/stringifyable_spec.rb in rambling-trie-1.0.3

- old
+ new

@@ -1,36 +1,36 @@ require 'spec_helper' describe Rambling::Trie::Stringifyable do describe '#as_word' do - let(:node) { Rambling::Trie::RawNode.new } + let(:node) { Rambling::Trie::Nodes::Raw.new } context 'for an empty node' do before do - node.add '' + add_word node, '' end it 'returns nil' do expect(node.as_word).to be_empty end end context 'for one letter' do before do node.letter = :a - node.add '' + add_word node, '' end it 'returns the expected one letter word' do expect(node.as_word).to eq 'a' end end context 'for a small word' do before do node.letter = :a - node.add 'll' + add_word node, 'll' end it 'returns the expected small word' do expect(node[:l][:l].as_word).to eq 'all' end @@ -41,20 +41,20 @@ end context 'for a long word' do before do node.letter = :b - node.add 'eautiful' + add_word node, 'eautiful' end it 'returns the expected long word' do expect(node[:e][:a][:u][:t][:i][:f][:u][:l].as_word).to eq 'beautiful' end end context 'for a node with nil letter' do - let(:node) { Rambling::Trie::RawNode.new nil } + let(:node) { Rambling::Trie::Nodes::Raw.new nil } it 'returns nil' do expect(node.as_word).to be_empty end end @@ -63,11 +63,10 @@ let(:compressor) { Rambling::Trie::Compressor.new } let(:compressed_node) { compressor.compress node } before do node.letter = :a - node.add 'm' - node.add 'dd' + add_words node, %w(m dd) end it 'returns the words for the terminal nodes' do expect(compressed_node[:m].as_word).to eq 'am' expect(compressed_node[:dd].as_word).to eq 'add'