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:
parent
46c334cb8a
commit
d6a824c00e
4 changed files with 16 additions and 3 deletions
|
@ -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"])
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue