Skip to content

Instantly share code, notes, and snippets.

@mikhailov
Created October 2, 2015 18:28
Show Gist options
  • Save mikhailov/d31281172d59a02ae491 to your computer and use it in GitHub Desktop.
Save mikhailov/d31281172d59a02ae491 to your computer and use it in GitHub Desktop.
Basic testing framework
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