Permalink
Browse files

Initialize Rack::Test::Sessions with Rack::MockSessions instead of apps

  • Loading branch information...
1 parent 62e963f commit bc20a59b2016361905dd43b03a97d0992d502855 @brynary brynary committed Jun 17, 2009
Showing with 10 additions and 7 deletions.
  1. +2 −0 History.txt
  2. +1 −0 lib/rack/mock_session.rb
  3. +3 −3 lib/rack/test.rb
  4. +4 −4 lib/rack/test/methods.rb
View
@@ -2,6 +2,8 @@
* Minor enhancements
+ * Initialize Rack::Test::Sessions with Rack::MockSessions instead of apps.
+ This change should help integration with other Ruby web frameworks (like Merb).
* Support sending bodies for PUT requests (Larry Diehl)
== 0.3.0 / 2009-05-17
@@ -3,6 +3,7 @@ module Rack
class MockSession
attr_writer :cookie_jar
attr_reader :last_response
+ attr_reader :default_host
def initialize(app, default_host = Rack::Test::DEFAULT_HOST)
@app = app
View
@@ -29,10 +29,10 @@ class Session
def_delegators :@rack_mock_session, :clear_cookies, :set_cookie, :last_response, :last_request
# Initialize a new session for the given Rack app
- def initialize(app, default_host = DEFAULT_HOST)
+ def initialize(mock_session)
@headers = {}
- @default_host = default_host
- @rack_mock_session = Rack::MockSession.new(app, default_host)
+ @rack_mock_session = mock_session
+ @default_host = mock_session.default_host
end
# Issue a GET request for the given URI with the given params and Rack
@@ -5,14 +5,14 @@ module Test
module Methods
extend Forwardable
- def rack_test_session
- @_rack_test_session ||= Rack::Test::Session.new(app)
- end
-
def rack_mock_session
@_rack_mock_session ||= Rack::MockSession.new(app)
end
+ def rack_test_session
+ @_rack_test_session ||= Rack::Test::Session.new(rack_mock_session)
+ end
+
METHODS = [
:request,

0 comments on commit bc20a59

Please sign in to comment.