-
-
Save sr/69374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
module Test | |
module Session | |
attr_reader :last_response | |
attr_reader :last_request | |
alias_method :response, :last_response | |
alias_method :request, :last_request | |
def initialize(app) | |
@app = app | |
end | |
# get "/", :foo => "bar" | |
# post "/", "foobar" | |
# get "/", :foo => "bar", :headers => { "User-Agent" => "Rack::Test" } | |
# get "/", :headers => { "HTTP_ACCEPT" => "text/plain" } | |
# get "/", :env => { "HTTP_ACCEPT" => "text/plain" } # same | |
# post "/", "foo bar", :env => { "rack.sessions" => { "foo" => "bar" } | |
# | |
# :headers is just a sugar for :env which can be used to modify the | |
# Rack env | |
def get(path, data=nil, headers=nil) | |
request!(path, data, headers) | |
end | |
def head | |
def post | |
def put | |
def delete | |
# The four above methods need to call one underlying impl... | |
# dispatch_request, process_request, .. ??? | |
private | |
def request!(path, data=nil, headers=nil) | |
@request = make_request(path, data, headers) | |
@response = Rack::Response.new(@app.call(env)) | |
end | |
def build_request(path, data, headers) | |
# data is either the input or an hash of params | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment