Class: Auger::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, block) ⇒ Test

Returns a new instance of Test.



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

def initialize(name, block)
  @name = name
  @block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



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

def block
  @block
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#run(response) ⇒ Object

return Auger::Result object with outcome of test



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

def run(response)
  outcome =
    if response.is_a?(Exception) or @block.nil?
      response
    else
      @block.call(response) rescue $! # run the test
    end

  result = outcome.is_a?(Result) ? outcome : Auger::Result.new(outcome)
  result.test = self
  result
end