Sha256: 210a95fa6ef665119769c615db47a504cf428645be8a387e29f7fa7eef2398fc

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

require 'ostruct'
require 'deas/runner'

module Deas

  class TestRunner < Runner

    attr_reader :handler, :return_value

    def initialize(handler_class, args = nil)
      args = (args || {}).dup
      @app_settings = OpenStruct.new(args.delete(:app_settings))
      @logger       = args.delete(:logger) || Deas::NullLogger.new
      @params       = args.delete(:params) || {}
      @request      = args.delete(:request)
      @response     = args.delete(:response)
      @session      = args.delete(:session)

      super(handler_class)
      args.each{|key, value| @handler.send("#{key}=", value) }

      @return_value = catch(:halt){ @handler.init; nil }
    end

    def run
      @return_value ||= catch(:halt){ @handler.run }
    end

    # Helpers

    def halt(*args)
      throw(:halt, args)
    end

    def render(*args, &block)
      [ args, block ].compact.flatten
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deas-0.9.0 lib/deas/test_runner.rb
deas-0.8.0 lib/deas/test_runner.rb