Created
April 10, 2012 23:17
-
-
Save brixen/2355525 to your computer and use it in GitHub Desktop.
git show 958a0e9b1a06 in the Rubinius repo
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
| # minispec | |
| # | |
| # Very minimal set of features to support specs like this: | |
| # | |
| # context "Array" do | |
| # specify "should respond to new" do | |
| # Array.new.should == [] | |
| # end | |
| # end | |
| class PostiveSpec | |
| def initialize(obj) | |
| @obj = obj | |
| end | |
| def ==(other) | |
| if @obj != other | |
| raise Exception.new("equality expected") | |
| end | |
| end | |
| end | |
| class NegativeSpec | |
| def initialize(obj) | |
| @obj = obj | |
| end | |
| def ==(other) | |
| if @obj == other | |
| raise Exception.new("inequality expected") | |
| end | |
| end | |
| end | |
| class Object | |
| def should | |
| PostiveSpec.new(self) | |
| end | |
| def should_not | |
| NegativeSpec.new(self) | |
| end | |
| end | |
| def specify(msg) | |
| print '.' | |
| begin | |
| yield | |
| rescue Exception => e | |
| print msg | |
| print " FAILED\n" | |
| print e.message | |
| print "\n" | |
| end | |
| end | |
| def context(msg) | |
| yield | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment