Class: Sanford::TestRunner

Inherits:
Object
  • Object
show all
Includes:
Runner::HaltMethods
Defined in:
lib/sanford/test_runner.rb

Defined Under Namespace

Modules: Helpers

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Runner::HaltMethods

#catch_halt, #halt

Constructor Details

#initialize(handler_class, params = {}, logger = nil) ⇒ TestRunner

Returns a new instance of TestRunner.



13
14
15
16
17
18
19
20
# File 'lib/sanford/test_runner.rb', line 13

def initialize(handler_class, params = {}, logger = nil)
  @handler_class  = handler_class
  @request        = params.kind_of?(Sanford::Protocol::Request) ? params : test_request(params)
  @logger         = logger || Sanford::NullLogger.new

  @handler  = @handler_class.new(self)
  @response = build_response catch(:halt){ @handler.init; nil }
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



11
12
13
# File 'lib/sanford/test_runner.rb', line 11

def handler
  @handler
end

#loggerObject (readonly)

Returns the value of attribute logger.



11
12
13
# File 'lib/sanford/test_runner.rb', line 11

def logger
  @logger
end

#requestObject (readonly)

Returns the value of attribute request.



11
12
13
# File 'lib/sanford/test_runner.rb', line 11

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



11
12
13
# File 'lib/sanford/test_runner.rb', line 11

def response
  @response
end

Instance Method Details

#runObject



22
23
24
# File 'lib/sanford/test_runner.rb', line 22

def run
  @response ||= build_response catch_halt{ @handler.run }
end