spec/lib/rambling/trie/node_spec.rb in rambling-trie-0.6.1 vs spec/lib/rambling/trie/node_spec.rb in rambling-trie-0.7.0

- old
+ new

@@ -2,35 +2,35 @@ module Rambling module Trie describe Node do it 'delegates `#[]` to its children tree' do - subject.children_tree.should_receive(:[]).with(:key).and_return('value') + expect(subject.children_tree).to receive(:[]).with(:key).and_return('value') expect(subject[:key]).to eq 'value' end it 'delegates `#[]=` to its children tree' do - subject.children_tree.should_receive(:[]=).with(:key, 'value') + expect(subject.children_tree).to receive(:[]=).with(:key, 'value') subject[:key] = 'value' end it 'delegates `#delete` to its children tree' do - subject.children_tree.should_receive(:delete).with(:key).and_return('value') + expect(subject.children_tree).to receive(:delete).with(:key).and_return('value') expect(subject.delete :key).to eq 'value' end it 'delegates `#has_key?` to its children tree' do - subject.children_tree.should_receive(:has_key?).with(:present_key).and_return(true) + expect(subject.children_tree).to receive(:has_key?).with(:present_key).and_return(true) expect(subject).to have_key(:present_key) - subject.children_tree.should_receive(:has_key?).with(:absent_key).and_return(false) + expect(subject.children_tree).to receive(:has_key?).with(:absent_key).and_return(false) expect(subject).not_to have_key(:absent_key) end it 'delegates `#children` to its children tree values' do - children = [double('child 1'), double('child 2')] - subject.children_tree.should_receive(:values).and_return(children) + children = [double(:child_1), double(:child_2)] + expect(subject.children_tree).to receive(:values).and_return(children) expect(subject.children).to eq children end describe '#root?' do it 'returns false' do @@ -45,11 +45,11 @@ it 'does not have any letter' do expect(subject.letter).to be_nil end it 'includes no children' do - expect(subject).to have(0).children + expect(subject.children.size).to eq 0 end it 'is not a terminal node' do expect(subject).to_not be_terminal end @@ -69,11 +69,11 @@ it 'does not have any letter' do expect(subject.letter).to be_nil end it 'includes no children' do - expect(subject).to have(0).children + expect(subject.children.size).to eq 0 end it 'is not a terminal node' do expect(subject).to_not be_terminal end @@ -93,11 +93,11 @@ it 'makes it the node letter' do expect(subject.letter).to eq :a end it 'includes no children' do - expect(subject).to have(0).children + expect(subject.children.size).to eq 0 end it 'is a terminal node' do expect(subject).to be_terminal end @@ -109,11 +109,11 @@ it 'takes the first as the node letter' do expect(subject.letter).to eq :b end it 'includes one child' do - expect(subject).to have(1).children + expect(subject.children.size).to eq 1 end it 'includes a child with the expected letter' do expect(subject.children.first.letter).to eq :a end @@ -198,25 +198,25 @@ end end end describe '#compressed?' do - let(:root) { double 'Root' } + let(:root) { double :root } subject { Node.new '', root } context 'parent is compressed' do before do - root.stub(:compressed?).and_return true + allow(root).to receive(:compressed?).and_return true end it 'returns true' do expect(subject).to be_compressed end end context 'parent is not compressed' do before do - root.stub(:compressed?).and_return false + allow(root).to receive(:compressed?).and_return false end it 'returns false' do expect(subject).to_not be_compressed end