Skip to content

Instantly share code, notes, and snippets.

@Sen
Created March 17, 2015 09:44
Show Gist options
  • Save Sen/194fb19abeb79f9f048a to your computer and use it in GitHub Desktop.
Save Sen/194fb19abeb79f9f048a to your computer and use it in GitHub Desktop.
class MyTestError < StandardError; end
class MyTest
attr_accessor :test
def initialize
@test = {}
end
def self.test(description, &block)
$mytest ||= self.new
$mytest.test = { description: description, block: block }
$mytest.execute!
end
def assert(r)
if r == true
true
else
raise MyTestError
end
end
def execute!
begin
puts @test[:description]
self.instance_eval(&@test[:block])
puts " --- success"
rescue MyTestError
puts " --- failed"
end
end
end
require './my_test'
class SomeTests < MyTest
test "this is a simple test" do
assert 1 == 1
end
test "another simple test" do
assert 1 != 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment