Skip to content

Instantly share code, notes, and snippets.

@epitron
Last active December 23, 2015 11:29
Show Gist options
  • Save epitron/6628722 to your computer and use it in GitHub Desktop.
Save epitron/6628722 to your computer and use it in GitHub Desktop.
A very powerful testing library.
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
require_relative 'epitest'
class Test < EpiTest
def test_passage
assert true
end
def test_failure
assert false
end
end
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