Skip to content

Commit

Permalink
Ensure self is returned during call to Nodes::Raw#add
Browse files Browse the repository at this point in the history
This bug was introduced by #63.
  • Loading branch information
gonzedge committed Feb 20, 2024
1 parent bd54656 commit bc83db3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rambling/trie/nodes/raw.rb
Expand Up @@ -12,6 +12,7 @@ class Raw < Rambling::Trie::Nodes::Node
def add chars
if chars.empty?
terminal! unless root?
self
else
add_to_children_tree chars
end
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/rambling/trie/nodes/raw_spec.rb
Expand Up @@ -45,6 +45,10 @@ def assign_letter letter
it 'does not mark itself as terminal' do
expect(node).not_to be_terminal
end

it 'returns the node' do
expect(add_word(node, '')).to eq node
end
end
end

Expand Down Expand Up @@ -143,6 +147,10 @@ def assign_letter letter
it 'changes the node to terminal' do
expect(node).to be_terminal
end

it 'returns the node' do
expect(add_word(node, '')).to eq node
end
end

context 'when adding a one letter word' do
Expand Down

0 comments on commit bc83db3

Please sign in to comment.