1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge pull request #1628 from yozlet/have_current_path_doc

Add documentation for have_current_path
This commit is contained in:
Thomas Walpole 2015-12-23 11:02:19 -08:00
commit 5d09f79476

View file

@ -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)*