spec/lib/rambling/trie/comparable_spec.rb in rambling-trie-1.0.2 vs spec/lib/rambling/trie/comparable_spec.rb in rambling-trie-1.0.3
- old
+ new
@@ -1,11 +1,11 @@
require 'spec_helper'
describe Rambling::Trie::Comparable do
describe '#==' do
- let(:node_1) { Rambling::Trie::RawNode.new }
- let(:node_2) { Rambling::Trie::RawNode.new }
+ let(:node_1) { Rambling::Trie::Nodes::Raw.new }
+ let(:node_2) { Rambling::Trie::Nodes::Raw.new }
context 'when the nodes do not have the same letter' do
before do
node_1.letter = :a
node_2.letter = :b
@@ -65,40 +65,31 @@
end
context 'when the nodes have the same letter and the same children' do
before do
node_1.letter = :t
- node_1.add 'hese'
- node_1.add 'hree'
- node_1.add 'hings'
+ add_words node_1, %w(hese hree hings)
node_2.letter = :t
- node_2.add 'hese'
- node_2.add 'hree'
- node_2.add 'hings'
+ add_words node_2, %w(hese hree hings)
end
it 'returns true' do
expect(node_1).to eq node_2
- expect(node_1[:h][:e][:s][:e]).to eq node_2[:h][:e][:s][:e]
end
end
context 'when the nodes have the same letter but different children' do
before do
node_1.letter = :t
- node_1.add 'hese'
- node_1.add 'wo'
+ add_words node_1, %w(hese wo)
node_2.letter = :t
- node_2.add 'hese'
- node_2.add 'hree'
- node_2.add 'hings'
+ add_words node_2, %w(hese hree hings)
end
it 'returns false' do
expect(node_1).not_to eq node_2
- expect(node_1[:h][:e][:s][:e]).to eq node_2[:h][:e][:s][:e]
end
end
end
end