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