Sha256: 6cec1d962de004d871077ddb162c70fbe4196fc9f0c4e2f615802b7df5ac7b3d

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

require 'stack'

describe Stack do

  before do
    @stack = Stack.new
  end

  it 'should be empty' do
    @stack.should be_empty
  end

  it 'should have no element on top' do
    lambda { @stack.top }.should raise_error(Test::Unit::AssertionFailedError)
  end

  it 'should not be possible to pop an element' do
    lambda { @stack.pop }.should raise_error(Stack::NoPopForEmptyStack)
  end

  it 'a pushed element should be on the top' do
    element = 0
    @stack.push(element)
    @stack.should_not be_empty
    @stack.top.should be_equal(element)
    @stack.pop.should be_equal(element)
    @stack.should be_empty
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
armin-joellenbeck-rdbc-0.0.4 spec/stack_spec.rb
armin-joellenbeck-rdbc-0.0.5 spec/stack_spec.rb