Class: Medbay::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, func) ⇒ Test

Returns a new instance of Test.



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

def initialize(label, func)
  @label = label
  @func = func
end

Instance Attribute Details

#funcObject

Returns the value of attribute func.



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

def func
  @func
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/medbay/test.rb', line 10

def call
  passed, elapsed = nil

  if Medbay.configuration.benchmark
    elapsed = Benchmark.realtime do
      passed = @func.call
    end

    return {passed: passed, name: @label, elapsed: elapsed*1000}
  end

  passed = @func.call
  {passed: passed, name: @label}
end