You are currently browsing the tag archive for the ‘Capybara’ tag.

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
Follow

Get every new post delivered to your Inbox.

Join 63 other followers