Skip to content

Commit

Permalink
Add documentation for have_current_path
Browse files Browse the repository at this point in the history
  • Loading branch information
yozlet committed Dec 23, 2015
1 parent 9d139b3 commit 461b295
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,17 @@ The visit method only takes a single parameter, the request method is **always**
GET.

You can get the [current path](http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Session#current_path-instance_method)
of the browsing session for test assertions:
of the browsing session, and test it using the [`have_current_path`](http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/RSpecMatchers#have_current_path-instance_method) matcher:

```ruby
expect(current_path).to eq(post_comments_path(post))
expect(page).to have_current_path(post_comments_path(post))
```

**Note**: You can also assert the current path by testing the value of
`current_path` directly. However, using the `have_current_path` matcher is
safer since it uses Capybara's [waiting behaviour](#asynchronous-javascript-ajax-and-friends)
to ensure that preceding actions (such as a `click_link`) have completed.
### Clicking links and buttons
*Full reference: [Capybara::Node::Actions](http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions)*
Expand Down

0 comments on commit 461b295

Please sign in to comment.