Created
October 2, 2015 18:28
-
-
Save mikhailov/d31281172d59a02ae491 to your computer and use it in GitHub Desktop.
Basic testing framework
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
class Object | |
class UnitTestError < StandardError; end | |
def describe(description, &block) | |
if Object.class_eval(&block) | |
print '.' | |
else | |
puts 'FAIL ' + description | |
raise UnitTestError | |
end | |
end | |
def assert(a,b) | |
a == b | |
end | |
end | |
describe "This should should fail, because 1 != 2" do | |
assert 1, 2 | |
end | |
describe "This should should fail, because 1 != 3" do | |
assert 1, 3 | |
end | |
describe "This should should pass, because 2 == 2" do | |
assert 2, 2 | |
end | |
describe "This should should pass, because 5 == 5" do | |
assert 5, 5 | |
end | |
describe "This should should pass, because 10 == 10" do | |
assert 10, 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment