update some documentation

This commit is contained in:
John Bintz 2013-01-24 18:08:21 -05:00
parent ff2202a8f4
commit 8f3db1243c
1 changed files with 39 additions and 3 deletions

View File

@ -1,4 +1,6 @@
Make your Rails Capybara testing even faster and more accurate! Looking for text strings is for the birds.
Make your Rails Capybara testing even faster and more accurate! Looking for hardcoded text strings is for the birds.
A lot of this assumes you're using a form builder to generate forms, like Formtastic. It's faster that way.
## Your Views
@ -7,6 +9,41 @@ This gem does that for you if you link to and refer to things in a certain way.
tests turn from text blob and CSS selector messes to nice, clean, simple references to objects
and attributes.
### Linking to things
Link to things using `link_to_model`, `link_to_model_action`, `link_to_collection`, and `link_to_route`.
Data attributes will be added that Capybara can then find later, and quickly:
``` haml
#menu
= link_to_route :root
= link_to_collection [ :admin, :users ]
= link_to_model current_user
= link_to_model_action current_user, :edit
```
``` ruby
# finding those things
within '#menu' do
find_semantic_link(:root)
find_semantic_link(:users)
find_object(@user)
find_action(:edit)
end
```
### Form fields
Don't worry about tying your field entry with text labels. It's much easier to look for attributes by name:
``` ruby
find_input(:first_name).set("first name")
find_input(:last_name).set("last name")
set_input(:gender, 'male')
find_submit.click
```
### Attributes
Write out attributes using `attributes_for`:
@ -47,6 +84,5 @@ Sometimes the absence of a thing is just as important as the presence of a thing
# selector's not there
dont_find('#user')
# object's not there
```