Here's an excerpt from prying into a running test to demonstrate the problem:
[1] pry> page.current_path
=> "/dashboard/passwort-vergessen/setzen"
[2] pry> expect(page).to have_current_path("/dashboard/passwort-vergessen/setzen")
RSpec::Expectations::ExpectationNotMetError: expected "/dashboard/passwort-vergessen/setzen?token=a_token" to equal "/dashboard/passwort-vergessen/setzen"
from /package-caches/bundler/gems/rspec-support-3.5.0/lib/rspec/support.rb:87:in `block in <module:Support>'
The matcher being used is indeed from Capybara, not RSpec:
[1] pry(..):1> matcher
=> #<Capybara::RSpecMatchers::HaveCurrentPath:0x0055bfee94ce98
@args=["/dashboard/passwort-vergessen/setzen", {}],
@current_path="/dashboard/passwort-vergessen/setzen">
[2] pry(..):1> matcher.matches?(page)
=> false
[3] pry(..):1> matcher.failure_message
=> "expected \"/dashboard/passwort-vergessen/setzen?token=a_token\" to equal \"/dashboard/passwort-vergessen/setzen\""
[4] pry(..):1> page.current_path
=> "/dashboard/passwort-vergessen/setzen"
Observed with capybara versions 2.12.1 and 2.14.0.
Workaround is to use only_path like this:
have_current_path("/dashboard/passwort-vergessen/setzen", only_path: true)
This is behaving as expected - http://www.rubydoc.info/gems/capybara/Capybara/SessionMatchers#assert_current_path-instance_method - although it looks like the docs for has_current_path? are missing a line (PRs to improve the docs are always considered). The use of only_path is not a "workaround", it's the option specifically meant to produce the behavior you're looking for.
For anyone finding this page, please note that only_path is flagged as deprecated now. Use ignore_query: true instead:
DEPRECATED: The :only_path option is deprecated in favor of the :ignore_query option
Most helpful comment
For anyone finding this page, please note that
only_pathis flagged as deprecated now. Useignore_query: trueinstead: