Last active
December 23, 2015 11:29
-
-
Save epitron/6628722 to your computer and use it in GitHub Desktop.
A very powerful testing library.
This file contains hidden or 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 EpiTest | |
def self.inherited(base) | |
at_exit { base.new.run_my_tests_bitch! } | |
end | |
class Fail < Exception; end | |
def assert(thing) | |
raise Fail.new(caller_locations[0]) unless thing | |
end | |
def run_my_tests_bitch! | |
puts "#{self.class.name}" | |
puts "--------------------------" | |
methods.grep(/^test/).each do |method| | |
puts "testing: #{method}" | |
begin | |
send(method) | |
puts " => PASS" | |
rescue Fail => e | |
puts " => FAIL: #{e}" | |
end | |
end | |
puts | |
end | |
end |
This file contains hidden or 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_relative 'epitest' | |
class Test < EpiTest | |
def test_passage | |
assert true | |
end | |
def test_failure | |
assert false | |
end | |
end | |
This file contains hidden or 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
Test | |
-------------------------- | |
testing: test_passage | |
=> PASS | |
testing: test_failure | |
=> FAIL: /home/epi/code/epitest/test_epitest.rb:10:in `test_failure' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment