[rspec-users] have_tag and img's
phlip2005 at gmail.com
Fri Mar 20 21:34:03 EDT 2009
BJ Clark wrote:
> I'm specing some xhtml (which I don't normally do, so forgive me if this
> is basic).
> I've got the following spec:
> it "should build xhtml form pieces" do
> @captcha.should_receive(:request_image).and_return @image
> @captcha.vidoop_captcha().should have_tag "div.captcha" do
> with_tag "input[type=hidden][name=captcha_id]"
> with_tag "input[name=captcha]"
I suspect the XPath predicate should be [@name='captcha'], but I don't know
You might also try (>cough<) my assert_xhtml:
div :id => :captcha do
img :src => 'http://api.vidoop.com/vs/captchas/cpt123/image'
input :type => :hidden, :name => :captcha_id
input :name => :captcha
I invented it specifically to solve the verbosity problem you encountered. gem
install nokogiri assert2, and require 'assert2/xhtml'.
If it fails, it prints out the HTML pattern it sought, and the sample HTML from
your production code.
More information about the rspec-users