module Jeka class TestCase attr_reader :database def tests methods.select {|m| m =~ /^test_/}.map {|m| send(m)} end def self.test(name) t = Test.new(name) yield t define_method("test_#{name}".to_sym) do return t end end def self.reset @@test_suites = {} end def self.inherited(klass) @@test_suites ||= {} @@test_suites[klass] = true end def self.test_suites @@test_suites ||= {} @@test_suites.keys.sort_by { |ts| ts.name }.collect{|ts| ts.new} end def jekafy @database = Jeka::Analysis::TestCase.create!( name: self.class.to_s, tests: tests.collect {|t| t.jekafy} ) end end end