Permalink
Browse files

Merge pull request #52 from dlibanori/webrat

---

Actually this is a patch for Rack applications redirects.

This patch changes current specs and shows where they fail.

I think it is not so hard coded as forcing mock session to comply with Rack::Test example.org url.
  • Loading branch information...
indirect committed Nov 19, 2011
2 parents 9891e51 + 55c9a99 commit 6b7c4223f4b3e18d949c192d7b56ebf1e03b20e4
Showing with 8 additions and 3 deletions.
  1. +1 −0 lib/webrat/adapters/rack.rb
  2. +6 −2 lib/webrat/core/session.rb
  3. +1 −1 spec/integration/rack/test/webrat_rack_test.rb
@@ -4,6 +4,7 @@ module Webrat
class RackAdapter
extend Forwardable
+ attr :session
def_delegators :@session, :get, :post, :put, :delete
def initialize(session) #:nodoc:
@@ -286,11 +286,15 @@ def response_location
end
def current_host
- URI.parse(current_url).host || @custom_headers["Host"] || "www.example.com"
+ URI.parse(current_url).host || @custom_headers["Host"] || default_current_host
end
def response_location_host
- URI.parse(response_location).host || "www.example.com"
+ URI.parse(response_location).host || default_current_host
+ end
+
+ def default_current_host
+ adapter.session.rack_mock_session.default_host
end
def reset
@@ -8,7 +8,7 @@ class WebratRackTest < Test::Unit::TestCase
include Webrat::HaveTagMatcher
def build_rack_mock_session
- Rack::MockSession.new(app, "www.example.com")
+ Rack::MockSession.new(app, "example.net")
end
def test_visits_pages

0 comments on commit 6b7c422

Please sign in to comment.