Sha256: 68db916bc25611b00578954d4292c0de921faa04677dd089c2f248cec4fef0f8
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
Contents
require "uri" require "rack/app" require "rack/mock" module Rack::App::Test require 'rack/app/test/utils' require 'rack/app/test/singleton_methods' def self.included(klass) klass.__send__(:extend, self::SingletonMethods) end attr_reader :last_response def __send_rack_app_request__(request_method, *args) properties = args.select { |e| e.is_a?(Hash) }.reduce({}, &:merge!) url = args.detect { |e| e.is_a?(String) } || properties.delete(:url) mock_request = Rack::MockRequest.new(rack_app) request_env = Rack::App::Test::Utils.env_by(url, properties) return @last_response = mock_request.request(request_method.to_s.upcase, url, request_env) end Rack::App::Constants::HTTP::METHODS.each do |request_method_type| define_method(request_method_type.to_s.downcase) do |*args| self.__send_rack_app_request__(request_method_type, *args) end end def rack_app(&block) @rack_app ||= lambda do if defined?(__rack_app_class__) __rack_app_class__ elsif defined?(described_class) && described_class.respond_to?(:call) described_class else raise('missing class definition') end end.call block.is_a?(Proc) ? @rack_app.instance_exec(&block) : @rack_app end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rack-app-6.3.2 | lib/rack/app/test.rb |
rack-app-6.3.1 | lib/rack/app/test.rb |
rack-app-6.3.0 | lib/rack/app/test.rb |
rack-app-6.2.0 | lib/rack/app/test.rb |
rack-app-6.1.0 | lib/rack/app/test.rb |