1 require File.dirname(__FILE__) + '/spec_helper'
2 require File.dirname(__FILE__) + '/stack'
3 require File.dirname(__FILE__) + '/shared_stack_examples'
13 it { @stack.should be_empty }
15 it_should_behave_like "non-full Stack"
17 it "should complain when sent #peek" do
18 lambda { @stack.peek }.should raise_error(StackUnderflowError)
21 it "should complain when sent #pop" do
22 lambda { @stack.pop }.should raise_error(StackUnderflowError)
27 describe "(with one item)" do
34 it_should_behave_like "non-empty Stack"
35 it_should_behave_like "non-full Stack"
39 describe "(with one item less than capacity)" do
42 (1..9).each { |i| @stack.push i }
46 it_should_behave_like "non-empty Stack"
47 it_should_behave_like "non-full Stack"
53 (1..10).each { |i| @stack.push i }
57 it { @stack.should be_full }
59 it_should_behave_like "non-empty Stack"
61 it "should complain on #push" do
62 lambda { @stack.push Object.new }.should raise_error(StackOverflowError)