main
1require "spec_helper"
2
3#Tree data structure
4#each node has at most two children
5#nodes with children are parent nodes.
6describe BinaryTree do
7 subject { BinaryTree.new }
8
9 context "when there are no items in the tree" do
10 it "should have a size of 0" do
11 expect(subject.size).to eq(0)
12 end
13 end
14
15 context "when many items are pushed on to the tree" do
16 before :each do
17 10.times do |n|
18 subject.push(rand(n))
19 end
20 end
21
22 it "should increase the size" do
23 expect(subject.size).to eq(10)
24 end
25
26 it "can iterate through each item" do
27 subject.each do |item|
28 expect(item).not_to be_nil
29 end
30 end
31 end
32end