diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-08-31 22:11:50 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-31 22:11:50 +0100 |
commit | bae00bb1cc392e1cf408369809b9cf85468bef42 (patch) | |
tree | 17103af6eeb5de96c72beda1debce28950cc7fea /actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb | |
parent | 93c76b2fb08668bc4b8364cc8051476e6d1d15ba (diff) | |
parent | ffd2cf167040b60c26d97c01598560c87bd4b2d3 (diff) | |
download | rails-bae00bb1cc392e1cf408369809b9cf85468bef42.tar.gz rails-bae00bb1cc392e1cf408369809b9cf85468bef42.tar.bz2 rails-bae00bb1cc392e1cf408369809b9cf85468bef42.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb b/actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb deleted file mode 100644 index eba6226538..0000000000 --- a/actionpack/lib/action_dispatch/vendor/rack-test/rack/mock_session.rb +++ /dev/null @@ -1,50 +0,0 @@ -module Rack - - class MockSession - attr_writer :cookie_jar - attr_reader :last_response - - def initialize(app, default_host = Rack::Test::DEFAULT_HOST) - @app = app - @default_host = default_host - end - - def clear_cookies - @cookie_jar = Rack::Test::CookieJar.new([], @default_host) - end - - def set_cookie(cookie, uri = nil) - cookie_jar.merge(cookie, uri) - end - - def request(uri, env) - env["HTTP_COOKIE"] ||= cookie_jar.for(uri) - @last_request = Rack::Request.new(env) - status, headers, body = @app.call(@last_request.env) - @last_response = MockResponse.new(status, headers, body, env["rack.errors"].flush) - cookie_jar.merge(last_response.headers["Set-Cookie"], uri) - - @last_response - end - - # Return the last request issued in the session. Raises an error if no - # requests have been sent yet. - def last_request - raise Rack::Test::Error.new("No request yet. Request a page first.") unless @last_request - @last_request - end - - # Return the last response received in the session. Raises an error if - # no requests have been sent yet. - def last_response - raise Rack::Test::Error.new("No response yet. Request a page first.") unless @last_response - @last_response - end - - def cookie_jar - @cookie_jar ||= Rack::Test::CookieJar.new([], @default_host) - end - - end - -end |