-
-
Save jimweirich/3717491 to your computer and use it in GitHub Desktop.
This file contains 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
describe Stack do | |
# Suggested Syntax... | |
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 | |
end | |
# all of the above can be done with existing invariants | |
# (and an imply matcher) | |
Invariant { stack.empty?.should imply(stack.depth == 0) } | |
Invariant { stack.empty?.should imply(stack.pushable?) } | |
Invariant { stack.full?.should imply(stack.depth == stack.max_depth) } | |
Invariant { stack.full?.should imply(! stack.pushable?) } | |
Invariant { (!stack.full? && ! stack.empty?).should imply(stack.depth > 0) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment