]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/examples/pure/shared_stack_examples.rb
fix node relations bug (thanks Dave!)
[rails.git] / vendor / gems / rspec-1.1.2 / examples / pure / shared_stack_examples.rb
1 require File.join(File.dirname(__FILE__), *%w[spec_helper])
2
3 shared_examples_for "non-empty Stack" do
4
5   it { @stack.should_not be_empty }
6   
7   it "should return the top item when sent #peek" do
8     @stack.peek.should == @last_item_added
9   end
10
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
14   end
15   
16   it "should return the top item when sent #pop" do
17     @stack.pop.should == @last_item_added
18   end
19   
20   it "should remove the top item when sent #pop" do
21     @stack.pop.should == @last_item_added
22     unless @stack.empty?
23       @stack.pop.should_not == @last_item_added
24     end
25   end
26   
27 end
28
29 shared_examples_for "non-full Stack" do
30
31   it { @stack.should_not be_full }
32
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"
36   end
37
38 end