Skip to content

Instantly share code, notes, and snippets.

@jredville
Created September 13, 2012 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jredville/3717061 to your computer and use it in GitHub Desktop.
Save jredville/3717061 to your computer and use it in GitHub Desktop.
describe Stack do
Invariants do
If { stack.empty? }
Then { stack.depth.should == 0 }
Then { stack.should be_pushable }
ElseIf { stack.full? }
Then { stack.depth.should == stack.max_depth }
Then { stack.should_not be_pushable }
Else
Then { stack.depth.should be > 0 } # not wild about this part
# Alternative
When { stack.empty? }
# thens
When { stack.full? }
# thens
Otherwise
Then { stack.depth.should be > 0 } #not wild about this part
# more thens
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment