Capybara has current_url, which returns an url that is unmatcheable since it includes a randomized port, and current_path with contains neither query nor fragment(aka hash/anchor) and is therefore rather useless.
Behold the perfect current_path_info, which returns the full path and query + fragment.
Code
def current_path_info current_url.sub(%r{.*?://},'')[%r{[/\?\#].*}] || '/' end
That was helpful.
thanks!
Thanks for this… I went with:
“`
def current_url_fragment
URI.parse(current_url).fragment
end
“`
which I think is a little bit more elegant, perhaps?
that just returns the fragment, not the path, .split(‘#’).last would also do the trick 🙂