Class: Raptest::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*targets) ⇒ Test

Returns a new instance of Test.



8
9
10
11
12
# File 'lib/raptest/test.rb', line 8

def initialize(*targets)
  @targets = targets.map { |a|
    ::Raptest::Asset.new(a)
  }
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/raptest/test.rb', line 6

def errors
  @errors
end

#finished_atObject

Returns the value of attribute finished_at.



6
7
8
# File 'lib/raptest/test.rb', line 6

def finished_at
  @finished_at
end

#processedObject

Returns the value of attribute processed.



6
7
8
# File 'lib/raptest/test.rb', line 6

def processed
  @processed
end

#started_atObject

Returns the value of attribute started_at.



6
7
8
# File 'lib/raptest/test.rb', line 6

def started_at
  @started_at
end

#targetsObject

Returns the value of attribute targets.



6
7
8
# File 'lib/raptest/test.rb', line 6

def targets
  @targets
end

Instance Method Details

#durationObject



14
15
16
# File 'lib/raptest/test.rb', line 14

def duration
  @start_time && @end_time ? ( @end_time - @start_time ) : 0
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/raptest/test.rb', line 18

def run          
  @started_at = Time.now
  @errors     = 0
  @processed  = 0

  targets.each do |asset|
    @processed += 1
    
    begin
      asset.test!
    rescue Exception => e
      @errors += 1
      raise e
    end
    
  end

  @finished_at = Time.now
end