Class: Setup::Tester

Inherits:
Base
  • Object
show all
Defined in:
lib/setup/tester.rb

Overview

Complexities arise in trying to figure out what test framework is used, and how to run tests. To simplify the process, this class simply looks for a special Ruby script at either ‘.setup/test.rb` or a shell script at `.setup/test.sh` and runs the such script accordingly. The Ruby script has priority if both exist.

Constant Summary collapse

RUBYSCRIPT =
META_EXTENSION_DIR + '/test.rb'
SHELLSCRIPT =
META_EXTENSION_DIR + '/test.sh'
DEPRECATED_RUBYSCRIPT =
META_EXTENSION_DIR + '/testrc.rb'

Instance Attribute Summary

Attributes inherited from Base

#config, #force, #io, #project, #quiet, #trace, #trial

Instance Method Summary collapse

Methods inherited from Base

#bash, #force?, #force_remove_file, #initialize, #initialize_hooks, #quiet?, #remove_file, #rm_f, #rmdir, #rootdir, #ruby, #trace?, #trace_off, #trial?

Constructor Details

This class inherits a constructor from Setup::Base

Instance Method Details

#testObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/setup/tester.rb', line 32

def test
  return true unless testable?

  if File.exist?(RUBYSCRIPT)
    test_rubyscript
  elsif File.exist?(SHELLSCRIPT)
    test_shellscript
  else
    true
  end
end

#test_rubyscriptObject



50
51
52
# File 'lib/setup/tester.rb', line 50

def test_rubyscript
  ruby(RUBYSCRIPT)
end

#test_shellscriptObject



45
46
47
# File 'lib/setup/tester.rb', line 45

def test_shellscript
  bash(SHELLSCRIPT)
end

#testable?Boolean

Returns:

  • (Boolean)


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

def testable?
  if File.exist?(DEPRECATED_RUBYSCRIPT)
    warn "Must use `.setup/test.rb' instead or `.setup/testrc.rb' to support testing."
  end

  return false if config.no_test
  return true  if File.exist?(RUBYSCRIPT)
  return true  if File.exist?(SHELLSCRIPT)
  false
end