Sha256: 32775f9e4a9815a90f0051d12c3f096ea75b195d82a5fd3c0bba719930bf8bbf

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jeka-0.2.3 lib/jeka/test_case.rb