module Pedant::Test

Public Class Methods

initialize!(args=[]) click to toggle source
# File lib/pedant/test.rb, line 31
def self.initialize!(args=[])
  # Run all tests by default.
  args = ['unit/**/*'] if args.empty?

  # Run each test or category of tests specified on the command line.
  args.each do |path|
    Dir.glob(Pedant.test + (path + '.rb')).each { |f| load(f) }
  end

  Check.initialize!
end

Public Instance Methods

check(result, cls, code) click to toggle source
# File lib/pedant/test.rb, line 47
def check(result, cls, code)
  # Create a knowledge base.
  kb = KnowledgeBase.new(:test_mode)

  # Put test code into the knowledge base.
  kb[:codes] = {}
  kb[:codes][kb[:main]] = code

  # Create a new instance of the check, which will execute all dependencies.
  chk = Pedant.const_get(cls).new(kb)

  # Run the test and ensure we got the expected result.
  chk.run
  assert_equal(result, chk.result)
end
setup() click to toggle source
# File lib/pedant/test.rb, line 43
def setup
  Check.initialize!
end