Module: Pedant::Test

Defined in:
lib/pedant/test.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize!(args = []) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# 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

Instance Method Details

#check(result, cls, code) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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

#setupObject



43
44
45
# File 'lib/pedant/test.rb', line 43

def setup
  Check.initialize!
end