Sha256: 120d9c2223722b56198c83853f6b3749cca1dfbb509d15ba20fa7650dc2189b0

Contents?: true

Size: 1.44 KB

Versions: 27

Compression:

Stored size: 1.44 KB

Contents

require 'examples/passing/stack'
require 'examples/passing/shared_stack_examples'

describe Stack, " (empty)" do
  before(:each) do
    @stack = Stack.new
  end
  
  # This uses @stack (because the described class is Stack) auto-generates the
  # description "should be empty"
  it { should be_empty }
  
  it_should_behave_like "non-full Stack"
  
  it "should complain when sent #peek" do
    lambda { @stack.peek }.should raise_error(StackUnderflowError)
  end
  
  it "should complain when sent #pop" do
    lambda { @stack.pop }.should raise_error(StackUnderflowError)
  end
end

describe Stack, " (with one item)" do
  before(:each) do
    @stack = Stack.new
    @stack.push 3
    @last_item_added = 3
  end

  it_should_behave_like "non-empty Stack"
  it_should_behave_like "non-full Stack"

end

describe Stack, " (with one item less than capacity)" do
  before(:each) do
    @stack = Stack.new
    (1..9).each { |i| @stack.push i }
    @last_item_added = 9
  end
  
  it_should_behave_like "non-empty Stack"
  it_should_behave_like "non-full Stack"
end

describe Stack, " (full)" do
  before(:each) do
    @stack = Stack.new
    (1..10).each { |i| @stack.push i }
    @last_item_added = 10
  end

  # NOTE that this one auto-generates the description "should be full"
  it { @stack.should be_full }  

  it_should_behave_like "non-empty Stack"

  it "should complain on #push" do
    lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
  end
  
end

Version data entries

27 entries across 27 versions & 10 rubygems

Version Path
rspec-instructure-1.3.3 examples/passing/stack_spec.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-1.3.2/examples/passing/stack_spec.rb
rspec-1.3.2 examples/passing/stack_spec.rb
rspec-1.3.1 examples/passing/stack_spec.rb
rspec-1.3.1.rc examples/passing/stack_spec.rb
rspec-1.3.0 examples/passing/stack_spec.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/examples/passing/stack_spec.rb
media-path-0.1.2 vendor/rspec/examples/passing/stack_spec.rb
simple-templater-0.0.1.3 vendor/rspec/examples/passing/stack_spec.rb
pupu-0.0.2.pre vendor/rspec/examples/passing/stack_spec.rb
media-path-0.1.1.pre vendor/rspec/examples/passing/stack_spec.rb
simple-templater-0.0.1.2 vendor/rspec/examples/passing/stack_spec.rb
media-path-0.1.1 vendor/rspec/examples/passing/stack_spec.rb
simple-templater-0.0.1.1 vendor/rspec/examples/passing/stack_spec.rb
pupu-0.0.2 vendor/rspec/examples/passing/stack_spec.rb
rango-0.0.6 vendor/rspec/examples/passing/stack_spec.rb
rango-0.1.pre vendor/rspec/examples/passing/stack_spec.rb
pupu-0.0.1 vendor/rspec/examples/passing/stack_spec.rb
media-path-0.1 vendor/rspec/examples/passing/stack_spec.rb
simple-templater-0.0.1 vendor/rspec/examples/passing/stack_spec.rb