1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Use Addressable in current path matcher to normalize comparisons - Fix #1611

This commit is contained in:
Thomas Walpole 2015-12-28 09:34:26 -08:00
parent 46c334cb8a
commit d6a824c00e
4 changed files with 16 additions and 3 deletions

View file

@ -26,6 +26,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("rack", [">= 1.0.0"])
s.add_runtime_dependency("rack-test", [">= 0.5.4"])
s.add_runtime_dependency("xpath", ["~> 2.0"])
s.add_runtime_dependency("addressable")
s.add_development_dependency("selenium-webdriver", ["~> 2.0"])
s.add_development_dependency("sinatra", [">= 0.9.4"])

View file

@ -15,16 +15,16 @@ module Capybara
session.current_url
else
if options[:only_path]
URI.parse(session.current_url).path
Addressable::URI.parse(session.current_url).path
else
URI.parse(session.current_url).request_uri
Addressable::URI.parse(session.current_url).request_uri
end
end
if @expected_path.is_a? Regexp
@actual_path.match(@expected_path)
else
@expected_path == @actual_path
Addressable::URI.parse(@expected_path) == Addressable::URI.parse(@actual_path)
end
end

View file

@ -12,6 +12,16 @@ Capybara::SpecHelper.spec '#has_current_path?' do
expect(@session).not_to have_current_path(/monkey/)
end
it "should handle non-escaped query options" do
@session.click_link("Non-escaped query options")
expect(@session).to have_current_path("/with_html?options[]=things")
end
it "should handle escaped query options" do
@session.click_link("Escaped query options")
expect(@session).to have_current_path("/with_html?options%5B%5D=things")
end
it "should wait for current_path", :requires => [:js] do
@session.click_link("Change page")
expect(@session).to have_current_path("/with_html")

View file

@ -95,6 +95,8 @@
<p>
<a href="#" id="delayed-page-change">Change page</a>
<a href="/with_html?options[]=things">Non-escaped query options</a>
<a href="/with_html?options%5B%5D=things">Escaped query options</a>
</p>
<p>