Skip to content

Instantly share code, notes, and snippets.

@mikhailov

mikhailov/tests.rb

Created Oct 2, 2015
Embed
What would you like to do?
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