changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/examples/pure/stack_spec_with_nested_example_groups.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/spec_helper'
2require File.dirname(__FILE__) + '/stack'
3require File.dirname(__FILE__) + '/shared_stack_examples'
4
5describe Stack do
6
7 before(:each) do
8 @stack = Stack.new
9 end
10
11 describe "(empty)" do
12
13 it { @stack.should be_empty }
14
15 it_should_behave_like "non-full Stack"
16
17 it "should complain when sent #peek" do
18 lambda { @stack.peek }.should raise_error(StackUnderflowError)
19 end
20
21 it "should complain when sent #pop" do
22 lambda { @stack.pop }.should raise_error(StackUnderflowError)
23 end
24
25 end
26
27 describe "(with one item)" do
28
29 before(:each) do
30 @stack.push 3
31 @last_item_added = 3
32 end
33
34 it_should_behave_like "non-empty Stack"
35 it_should_behave_like "non-full Stack"
36
37 end
38
39 describe "(with one item less than capacity)" do
40
41 before(:each) do
42 (1..9).each { |i| @stack.push i }
43 @last_item_added = 9
44 end
45
46 it_should_behave_like "non-empty Stack"
47 it_should_behave_like "non-full Stack"
48 end
49
50 describe "(full)" do
51
52 before(:each) do
53 (1..10).each { |i| @stack.push i }
54 @last_item_added = 10
55 end
56
57 it { @stack.should be_full }
58
59 it_should_behave_like "non-empty Stack"
60
61 it "should complain on #push" do
62 lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
63 end
64
65 end
66
67end