Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update Specs: #1

Merged
merged 1 commit into from

2 participants

Gary Rennie Sam Dunne
Gary Rennie

I'm not really sure of the goals of this project, I found it on http://24pullrequests.com

Hopefully these specs are or some use to you.

Gary Rennie Gazler Update Specs:
Update the test specs for the RData::Stack class to test each method
and the output.
7f30ca3
Sam Dunne
Owner

Hey,

Project goal is to provide a very clear and concise library of datastructures and algorithms in Ruby. I've only just started development hence why it's still a small project. Thanks for the help :)

Sam Dunne samdunne closed this
Sam Dunne samdunne reopened this
Sam Dunne samdunne merged commit 2f8cef8 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 2, 2012
  1. Gary Rennie

    Update Specs:

    Gazler authored
    Update the test specs for the RData::Stack class to test each method
    and the output.
This page is out of date. Refresh to see the latest.
Showing with 42 additions and 7 deletions.
  1. +42 −7 spec/rdata_spec.rb
49 spec/rdata_spec.rb
View
@@ -1,11 +1,46 @@
require 'spec_helper'
describe RData do
- it "should return data for a stack" do
- element_data = RData.Stack
- #element_data.should be_nil
- element_data.push(1).should == 1
- element_data.pop.should == 1
- element_data.is_empty?.should be_true
+
+ let(:stack) { RData.Stack }
+
+ context "An empty stack" do
+
+ it "should be empty" do
+ stack.is_empty?.should eql("true")
+ end
+
+ it "should push an element" do
+ stack.push(9).should eql(9)
+ stack.top.should eql(9)
+ end
+
+ it "should raise an error when popping from an empty stack" do
+ expect {
+ stack.pop
+ }.to raise_error(StandardError)
+ end
+ end
+
+ context "A stack with elements" do
+ before(:each) do
+ stack.push(5)
+ stack.push(8)
+ end
+
+ it "should not be empty" do
+ stack.is_empty?.should eql("false")
+ end
+
+ it "should reveal the top element" do
+ stack.top.should eql(8)
+ end
+
+ it "should pop the top element" do
+ stack.pop.should eql(8)
+ stack.top.should eql(5)
+ end
+
end
-end
+
+end
Something went wrong with that request. Please try again.