[rspec-users] Specifying Ajax hyperlinks

Ashley Moran work at ashleymoran.me.uk
Mon Feb 26 11:37:14 EST 2007

I was about to put this as a feature request but I wasn't sure if  
anyone would consider it useful so I thought I'd ask here.  I'm not  
sure what the feeling on specifying links is - it strikes me as  
something that needs doing because it's generated code at the end of  
the day.

I've got a few lines now along the lines of:

     response.should_have ".moo #quack > a[href='#'][onclick^='new  

part of the problem is that the CSS selector parser for should_have  
barfs on an embedded quote.  ie, even this selector doesn't work  
(note extra trailing quote in attribute):

       %q{a[href='#'][onclick^="new Ajax.Updater('"]}

But that's by the by.  Another (known) issue is the inability to put  
the controller name in spec, because specs run in ViewSpecController,

Either way, it'd be nice to have an easier way to spec link_to_remote  
etc, eg (I'm not using the 0.8 RC yet...)

     response.should_have_link_to_remote ".moo #quack >", :url => "/ 
product_info/rti", :update => "blah"

or something along those lines.

Anyone else consider this a good idea? I get the feeling I'm alone  
almost in using should_have (we've only got one should_have_tag left  
I think, to specify an attribute must be missing).


More information about the rspec-users mailing list