Skip to content

Instantly share code, notes, and snippets.

@vladvinnikov
Created August 19, 2011 07:36
Show Gist options
  • Save vladvinnikov/1156266 to your computer and use it in GitHub Desktop.
Save vladvinnikov/1156266 to your computer and use it in GitHub Desktop.
Changes in syntax
Selectors for the content of an element
before:
response.should have_selector("title", :content => "My Title")
after:
?
response.body.should have_selector("head title", :text => "My Title")
Value of an input field
before:
?
response.should have_selector("input", :value => "input field value")
after:
?
response.body.should have_selector("input[value='input field value']")
Link with url and content
before:
?
response.should have_selector("a", :href => "/url/path", :content => "Link text"
after:
?
response.body.should have_link("Link text", :href => "/url/path")
Selectors cannot be nested
Instead you can use
?
within("div.container") do
response.body.should have_link("Link text")
end
or just combine selectors one after the other in one big string
?
response.body.should have_selector("div.container a[href='/url/path']")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment