Class: Auger::Request

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Request

Returns a new instance of Request.



12
13
14
15
# File 'lib/auger/request.rb', line 12

def initialize(arg)
  @arg = arg
  @tests = []
end

Instance Attribute Details

#argObject

Returns the value of attribute arg.



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

def arg
  @arg
end

#before_tests_procObject

Returns the value of attribute before_tests_proc.



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

def before_tests_proc
  @before_tests_proc
end

#testsObject

Returns the value of attribute tests.



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

def tests
  @tests
end

Class Method Details

.load(arg, &block) ⇒ Object



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

def self.load(arg, &block)
  request = new(arg)
  request.instance_eval(&block)
  request
end

Instance Method Details

#before_tests(&block) ⇒ Object

callback to be run after request, but before tests



27
28
29
# File 'lib/auger/request.rb', line 27

def before_tests(&block)
  @before_tests_proc = block
end

#do_run(conn) ⇒ Object

call plugin run() and return plugin-specfic response object or exception



32
33
34
35
36
37
38
39
40
41
# File 'lib/auger/request.rb', line 32

def do_run(conn)
  return conn if conn.is_a? Exception
  begin
    response = self.run(conn)
    response = self.before_tests_proc.call(response) if self.before_tests_proc
    response
  rescue => e
    e
  end
end

#Result(*args) ⇒ Object

called within test block to return a Result object



22
23
24
# File 'lib/auger/request.rb', line 22

def Result(*args)
  Auger::Result.new(*args)
end

#test(name, &block) ⇒ Object



17
18
19
# File 'lib/auger/request.rb', line 17

def test(name, &block)
  @tests << Test.new(name, block)
end