Created
March 17, 2015 09:44
-
-
Save Sen/194fb19abeb79f9f048a to your computer and use it in GitHub Desktop.
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 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 |
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
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