main
 1require "spec_helper"
 2
 3describe DynamicArrayStack do
 4  subject { DynamicArrayStack.new }
 5
 6  context "when there is nothing on the stack" do
 7    it "should be able to pop off nil" do
 8      expect(subject.pop).to be_nil
 9    end
10  end
11
12  context "when there is one item on the stack" do
13    it "should be able to pop it off" do
14      n = rand
15      subject.push(n)
16      expect(subject.pop).to eq(n)
17    end
18  end
19
20  context "when there are multiple items on the stack" do
21    it "should pop each one off in the right order" do
22      (0..10).each do |n|
23        subject.push(n)
24      end
25      (10..0).each do |n|
26        expect(subject.pop).to eq(n)
27      end
28    end
29  end
30end