main
 1require "spec_helper"
 2
 3describe LinkedListStack do
 4  subject { LinkedListStack.new }
 5
 6  context "when no items are pushed on to the stack" do
 7    let(:result) { subject.pop }
 8
 9    it "should pop nil if there is nothing on the stack" do
10      expect(result).to be_nil
11    end
12  end
13
14  context "when a multiple items are pushed on to the stack" do
15    let(:n) { 10 }
16
17    before :each do
18      (1..n).each do |n|
19        subject.push(n)
20      end
21    end
22    it "should pop the last item pushed on to the stack" do
23      expect(subject.pop).to eq(n)
24    end
25
26    it "should pop off each item in reverse order of how they were put on" do
27      (n..1).each do |n|
28        expect(subject.pop).to eq(n)
29      end
30    end
31
32    it "should have the correct number of items" do
33      expect(subject.count).to eq(n)
34    end
35  end
36end