Last active
October 25, 2016 14:53
-
-
Save FsDevNinja/b88322a75f74e2dacdc16b735b9cd8df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.describe Stack do | |
before :each do | |
@node3 = Node.new(57, nil) | |
@node2 = Node.new(21, @node3) | |
@node1 = Node.new(34, @node2) | |
@stack = Stack.new | |
end | |
describe "initialize a stack" do | |
it "stack.top should eq nil" do | |
expect(@stack.top).to eq nil | |
end | |
end | |
describe "#push method" do | |
it "should set @top to value passed" do | |
@stack.push(@node1) | |
expect(@stack.top).to eq @node1 | |
end | |
end | |
describe "#pop method" do | |
it "should return last pushed node" do | |
@stack.push(@node1) | |
expect(@stack.pop).to eq @node1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work. now look up a "before" block in rspec and use a
@stack
instance variable in that before block to DRY up your tests.