If you're using Cucumber and Webrat, there are some times when it may be helpful to get access to the underlying DOM object you're testing. It's easy to test that a tag has a specific attribute: response.should have_selector("img.photo", :src => photo_path(@photo)) However, it's a lot harder if you want to get access to the img tag, get its src attribute, and test something about that src attribute without hard coding the exact value: within("img.photo") do |img| # Using ".dom" is the key. url = img.dom["src"] # Now, do more tests against the URL itself. end
Ad maiorem Dei gloriam inque hominum salutem.