Module: Dest

Defined in:
lib/dest/loader.rb,
lib/dest.rb,
lib/dest/parser.rb,
lib/dest/version.rb,
lib/dest/evaluator.rb,
lib/dest/formatter.rb

Overview

The Formatter is responsible for printing the results to the user. At this time it simply prints to the terminal. In future versions there may be options to specify where to print to. Passing tests are represented with a dot (.) Failing tests will print out what line the doctest is on, the expression, what was expected and what the expression actually evaluated to.

Defined Under Namespace

Classes: Evaluator, Formatter, Loader, Parser

Constant Summary collapse

VERSION =
"0.0.1"
@@num_tests =
0

Class Method Summary collapse

Class Method Details

.run_tests(filepaths) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/dest.rb', line 21

def self.run_tests(filepaths)
  start_time = Time.now
  Loader.load_files(filepaths)

  filepaths.each { |path| self.test_file(path) }

  time_taken = Time.now - start_time
  Formatter.print_end_test_message(time_taken, @@num_tests)
end

.test_directory(dir_path) ⇒ Object



16
17
18
19
# File 'lib/dest.rb', line 16

def self.test_directory(dir_path)
  filepaths = Dir.glob("#{dir_path}/**/*.rb")
  self.run_tests(filepaths)
end

.test_file(file_path) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/dest.rb', line 31

def self.test_file(file_path)
  parsed_output = Parser.parse(file_path)
  parsed_output.each do |test| 
    @@num_tests += 1
    result = Evaluator.new(test).evaluate

    result_for_formatting = {:file_path => file_path, :result => result}
    Formatter.new(result_for_formatting).print
  end
end

.test_single(file_path) ⇒ Object



12
13
14
# File 'lib/dest.rb', line 12

def self.test_single(file_path)
  self.run_tests([file_path])
end