1 require File.join(File.dirname(__FILE__), *%w[spec_helper])
3 shared_examples_for "non-empty Stack" do
5 it { @stack.should_not be_empty }
7 it "should return the top item when sent #peek" do
8 @stack.peek.should == @last_item_added
11 it "should NOT remove the top item when sent #peek" do
12 @stack.peek.should == @last_item_added
13 @stack.peek.should == @last_item_added
16 it "should return the top item when sent #pop" do
17 @stack.pop.should == @last_item_added
20 it "should remove the top item when sent #pop" do
21 @stack.pop.should == @last_item_added
23 @stack.pop.should_not == @last_item_added
29 shared_examples_for "non-full Stack" do
31 it { @stack.should_not be_full }
33 it "should add to the top when sent #push" do
34 @stack.push "newly added top item"
35 @stack.peek.should == "newly added top item"