Class: Lemon::CLI::Test

Inherits:
Base
  • Object
show all
Defined in:
lib/lemon/cli/test.rb

Overview

Test Command

Instance Method Summary collapse

Methods inherited from Base

#initialize, #option_coverage, #option_dryrun, #option_format, #option_loadpath, #option_namespaces, #option_output, #option_parser, #option_private, #option_requires, #option_verbose, #option_zealous, #options, run, #run

Constructor Details

This class inherits a constructor from Lemon::CLI::Base

Instance Method Details

#command_parse(argv) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lemon/cli/test.rb', line 33

def command_parse(argv)
  option_parser.banner = "Usage: lemonade test [options] [files ...]"
  #option_parser.separator("Run unit tests.")

  option_format
  option_verbose
  option_namespaces
  option_loadpath
  option_requires

  option_parser.parse!(argv)
end

#command_run(scripts) ⇒ Object

Run unit tests.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lemon/cli/test.rb', line 11

def command_run(scripts)
  require 'lemon/runner'

  loadpath = options[:loadpath] || ['lib']  # + ['lib'] ?
  requires = options[:requires] || []

  loadpath.each{ |path| $LOAD_PATH.unshift(path) }
  requires.each{ |path| require(path) }

  #suite  = Lemon::Test::Suite.new(files, :cover=>cover)
  #runner = Lemon::Runner.new(suite, :format=>format, :cover=>cover, :namespaces=>namespaces)

  runner = Lemon::TestRunner.new(
    scripts, :format=>options[:format], :namespaces=>options[:namespaces]
  )

  success = runner.run

  exit -1 unless success
end