Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created July 23, 2009 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jschementi/153361 to your computer and use it in GitHub Desktop.
Save jschementi/153361 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'test/spec'
require 'mscorlib'
include System::Collections
describe '.NET Stack instantiation' do
it 'can create an empty stack' do
@stack = Stack.new
@stack.should.be.a.kind_of System::Collections::Stack
@stack.count.should == 0
end
it 'can create a stack from an array' do
@stack = Stack.new [1,2,3]
@stack.should.be.a.kind_of System::Collections::Stack
@stack.count.should == 3
end
end
describe '.NET Stack operations' do
before :each do
@stack = Stack.new [1,2,3]
end
it 'can push onto the stack' do
@stack.push 4
@stack.peek.should == 4
end
it 'can pop off of the stack' do
@stack.pop.should == 3
@stack.pop.should == 2
@stack.pop.should == 1
lambda{ @stack.pop }.should.raise TypeError
end
it 'can peek' do
@stack.peek.should == 3
@stack.pop
@stack.peek.should == 2
end
it 'can clear' do
@stack.clear
@stack.count.should == 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment