Unfortunately this commit breaks any Rails specs which pass anchor tags. I like the concept, but I'd prefer to work on this post 0.4.1 once I have a bit more time to work out the failures in our referance app.

This reverts commit 4fc2b7eb7e.
This commit is contained in:
Josh Knowles 2009-01-20 20:08:57 -05:00
parent 4fc2b7eb7e
commit 7a59353c78
2 changed files with 17 additions and 10 deletions

View File

@ -65,11 +65,19 @@ module Webrat
@context @context
end end
#now that we are not following external links, do NOT normalize the url and strip it of its host
#once we get here we don't care about stripping out the host because we know
def do_request(http_method, url, data, headers) #:nodoc: def do_request(http_method, url, data, headers) #:nodoc:
update_protocol(url) update_protocol(url)
integration_session.send(http_method, url, data, headers) integration_session.send(http_method, normalize_url(url), data, headers)
end
# remove protocol, host and anchor
def normalize_url(href) #:nodoc:
uri = URI.parse(href)
normalized_url = uri.path
if uri.query
normalized_url += "?" + uri.query
end
normalized_url
end end
def update_protocol(href) #:nodoc: def update_protocol(href) #:nodoc:

View File

@ -6,7 +6,6 @@ describe Webrat::RailsSession do
before :each do before :each do
Webrat.configuration.mode = :rails Webrat.configuration.mode = :rails
@integration_session = mock("integration_session") @integration_session = mock("integration_session")
@integration_session.stub!(:response => mock("response", :body => "<html>", :code => '200'))
end end
it "should delegate response_body to the session response body" do it "should delegate response_body to the session response body" do
@ -44,18 +43,18 @@ describe Webrat::RailsSession do
end end
context "the URL is a full path" do context "the URL is a full path" do
it "should pass the full url" do it "should just pass on the path" do
@integration_session.stub!(:https!) @integration_session.stub!(:https!)
@integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers") @integration_session.should_receive(:get).with("/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("http://www.example.com/url", "data", "headers") rails_session.get("http://www.example.com/url", "data", "headers")
end end
end end
context "the URL is https://" do context "the URL is https://" do
it "should call #https! with true before the request before passing along the full url" do it "should call #https! with true before the request and just pass on the path" do
@integration_session.should_receive(:https!).with(true) @integration_session.should_receive(:https!).with(true)
@integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers") @integration_session.should_receive(:get).with("/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("https://www.example.com/url", "data", "headers") rails_session.get("https://www.example.com/url", "data", "headers")
end end
@ -71,9 +70,9 @@ describe Webrat::RailsSession do
end end
context "the URL include an anchor" do context "the URL include an anchor" do
it "should keep the anchor" do it "should strip out the anchor" do
@integration_session.should_receive(:https!).with(false) @integration_session.should_receive(:https!).with(false)
@integration_session.should_receive(:get).with("http://www.example.com/url#foo", "data", "headers") @integration_session.should_receive(:get).with("/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)
rails_session.get("http://www.example.com/url#foo", "data", "headers") rails_session.get("http://www.example.com/url#foo", "data", "headers")
end end