Last active
December 19, 2015 04:19
-
-
Save delba/5896301 to your computer and use it in GitHub Desktop.
Capybara DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert_selector 'article', count: Article.count | |
| assert_selector 'article', exact: Article.count | |
| assert find_button('Save article', disabled: true).disabled? | |
| assert has_link?('New article', href: new_article_path) | |
| # assert that a link with text 'New article' and href new_article_path exists | |
| # not necessarily good to track bugs | |
| assert_equal new_article_path, find('a', text: 'New article')[:href] | |
| # assert selector and href value | |
| assert_selector 'p.notice', text: 'Article created!' | |
| # => asserts that a p.notice with text 'Article created!' is on the page | |
| assert_equal 'Article created!', find('p.notice').text | |
| # => assert that a p.notice exists *and* that its content is 'Article created!' | |
| assert_equal 'Lorem Ipsum', title | |
| # delegates `title` to `page` | |
| assert_match %r(/articles/\d+), current_path | |
| # no need to escape forward slashes with %r(...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment