Module: Pork::Stat::Imp

Defined in:
lib/pork/stat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stopObject

Returns the value of attribute stop.



11
12
13
# File 'lib/pork/stat.rb', line 11

def stop
  @stop
end

Instance Method Details

#add_error(err) ⇒ Object



29
30
31
32
33
34
# File 'lib/pork/stat.rb', line 29

def add_error err
  mutex.synchronize do
    self.errors += 1
    exceptions << err
  end
end

#add_failure(err) ⇒ Object



22
23
24
25
26
27
# File 'lib/pork/stat.rb', line 22

def add_failure err
  mutex.synchronize do
    self.failures += 1
    exceptions << err
  end
end

#incr_assertionsObject



18
# File 'lib/pork/stat.rb', line 18

def incr_assertions; mutex.synchronize{ self.assertions += 1 }; end

#incr_skipsObject



20
# File 'lib/pork/stat.rb', line 20

def incr_skips     ; mutex.synchronize{ self.skips      += 1 }; end

#incr_testsObject



19
# File 'lib/pork/stat.rb', line 19

def incr_tests     ; mutex.synchronize{ self.tests      += 1 }; end

#initialize(rt = Pork.report_class.new, st = Time.now, mu = Mutex.new, t = 0, a = 0, s = 0, f = 0, e = 0, x = []) ⇒ Object



12
13
14
15
16
# File 'lib/pork/stat.rb', line 12

def initialize rt=Pork.report_class.new,
               st=Time.now, mu=Mutex.new,
               t=0, a=0, s=0, f=0, e=0, x=[]
  super
end

#merge(stat) ⇒ Object



51
52
53
54
# File 'lib/pork/stat.rb', line 51

def merge stat
  self.class.new(reporter, start, mutex,
    *to_a.drop(3).zip(stat.to_a.drop(3)).map{ |(a, b)| a + b })
end

#numbersObject



37
# File 'lib/pork/stat.rb', line 37

def numbers; [tests, assertions, failures, errors, skips]; end

#passed?Boolean

Returns:

  • (Boolean)


36
# File 'lib/pork/stat.rb', line 36

def passed?; exceptions.size == 0                        ; end

#reportObject



46
47
48
49
# File 'lib/pork/stat.rb', line 46

def report
  self.stop = Time.now
  reporter.report(self)
end

#velocityObject



39
40
41
42
43
44
# File 'lib/pork/stat.rb', line 39

def velocity
  time_spent = stop - start
  [time_spent.round(6),
   (tests / time_spent).round(4),
   (assertions / time_spent).round(4)]
end