Sha256: cb9b04f83bd3e9436ff4a9f663ba6fd230b357709ef7890c385d6ad93b4ffb0d

Contents?: true

Size: 740 Bytes

Versions: 4

Compression:

Stored size: 740 Bytes

Contents

module Raisin
  module UnitHelper
    extend ActiveSupport::Concern

    module ClassMethods
      def controller_class
        metadata = self.metadata[:example_group]
        klass    = nil

        until metadata.nil? || klass.respond_to?(:new)
          klass    = metadata[:description_args].first
          metadata = metadata[:example_group]
        end

        klass.respond_to?(:new) ? klass : super
      end
    end

    def controller
      self.class.controller_class.new.tap do |c|
        c.request   = request
        c.response  = response
      end
    end

    def request
      @request ||= ActionDispatch::TestRequest.new
    end

    def response
      @response ||= ActionDispatch::TestResponse.new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
raisin-0.0.5 lib/raisin/testing/rspec/unit_helper.rb
raisin-0.0.4 lib/raisin/testing/rspec/unit_helper.rb
raisin-0.0.2 lib/raisin/testing/rspec/unit_helper.rb
raisin-0.0.1 lib/raisin/testing/rspec/unit_helper.rb