diff --git a/capybara.gemspec b/capybara.gemspec index f3efee24..c7db8d7a 100644 --- a/capybara.gemspec +++ b/capybara.gemspec @@ -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"]) diff --git a/lib/capybara/queries/current_path_query.rb b/lib/capybara/queries/current_path_query.rb index 8e7a9927..fb412cea 100644 --- a/lib/capybara/queries/current_path_query.rb +++ b/lib/capybara/queries/current_path_query.rb @@ -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 diff --git a/lib/capybara/spec/session/has_current_path_spec.rb b/lib/capybara/spec/session/has_current_path_spec.rb index a7b714e9..80fdbdde 100644 --- a/lib/capybara/spec/session/has_current_path_spec.rb +++ b/lib/capybara/spec/session/has_current_path_spec.rb @@ -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") diff --git a/lib/capybara/spec/views/with_js.erb b/lib/capybara/spec/views/with_js.erb index 3a94aa0d..1d32d60a 100644 --- a/lib/capybara/spec/views/with_js.erb +++ b/lib/capybara/spec/views/with_js.erb @@ -95,6 +95,8 @@
Change page + Non-escaped query options + Escaped query options