1 require File.dirname(__FILE__) + '/spec_helper'
2 require File.dirname(__FILE__) + "/stack"
3 require File.dirname(__FILE__) + '/shared_stack_examples'
5 describe Stack, " (empty)" do
10 # NOTE that this one auto-generates the description "should be empty"
11 it { @stack.should be_empty }
13 it_should_behave_like "non-full Stack"
15 it "should complain when sent #peek" do
16 lambda { @stack.peek }.should raise_error(StackUnderflowError)
19 it "should complain when sent #pop" do
20 lambda { @stack.pop }.should raise_error(StackUnderflowError)
24 describe Stack, " (with one item)" do
31 it_should_behave_like "non-empty Stack"
32 it_should_behave_like "non-full Stack"
36 describe Stack, " (with one item less than capacity)" do
39 (1..9).each { |i| @stack.push i }
43 it_should_behave_like "non-empty Stack"
44 it_should_behave_like "non-full Stack"
47 describe Stack, " (full)" do
50 (1..10).each { |i| @stack.push i }
54 # NOTE that this one auto-generates the description "should be full"
55 it { @stack.should be_full }
57 it_should_behave_like "non-empty Stack"
59 it "should complain on #push" do
60 lambda { @stack.push Object.new }.should raise_error(StackOverflowError)