Class: Vigilant::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/vigilant/test.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTest

Returns a new instance of Test.



7
8
9
10
11
# File 'lib/vigilant/test.rb', line 7

def initialize()
  @prior_to = ""
  @run = ""
  @after = ""
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



5
6
7
# File 'lib/vigilant/test.rb', line 5

def after
  @after
end

#prior_toObject

Returns the value of attribute prior_to.



3
4
5
# File 'lib/vigilant/test.rb', line 3

def prior_to
  @prior_to
end

#runObject

Returns the value of attribute run.



4
5
6
# File 'lib/vigilant/test.rb', line 4

def run
  @run
end

Class Method Details

.load(file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vigilant/test.rb', line 13

def self.load file
  return unless file
  file = file.dup.untaint
  return unless File.file?(file)

  code = File.read(file).untaint

  begin
    test = eval(code, binding, file)

    if Vigilant::Test === test
      return test
    end

    warn "[#{file}] isn't a Vigilant::Test (#{test.class} instead)."
  rescue SignalException, SystemExit
    raise
  rescue SyntaxError, Exception => e
    warn "Invalid test in [#{file}]: #{e}"
  end

  nil
end