From 8f3db1243ca06c0dfbf5fa4e35b54da6ea86a744 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 24 Jan 2013 18:08:21 -0500 Subject: [PATCH] update some documentation --- README.md | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index caaebda..0094478 100644 --- a/README.md +++ b/README.md @@ -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 ``` +