[rspec-users] have_tag and img's

BJ Clark bj at aboutus.org
Fri Mar 20 18:27:45 EDT 2009

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 "img[src=http://api.vidoop.com/vs/captchas/cpt123/image 
           with_tag "input[type=hidden][name=captcha_id]"
           with_tag "input[name=captcha]"

@captcha.vidoop_captcha is returning the following html:
<div class="captcha"><input value="cpt123" name="captcha_id"/><image  
src="http://api.vidoop.com/vs/captchas/cpt123/image" alt="VidoopSecure  
Captcha Image"/><div class="instructions"><p>foo bar</p><input  
type="text" autocomplete="off" maxlength="2" name="captcha"  

And my error is:
'Vidoop::Captcha::Helper rendering a catpcha should build xhtml form  
pieces' FAILED
Expected at least 1 element matching "img[src='http://api.vidoop.com/vs/captchas/cpt123/image' 
]", found 0.
<false> is not true.

I've tried with_tag as simple as "img" but even that isn't matching.  
The rest of the spec passes.

Any ideas?
BJ Clark

More information about the rspec-users mailing list