RSpec Views: Looking for tags with certain onclick attributes

Thanks to agile on #dallas.rb for helping me get to this. A great resource for all things tag and attribute related in regards to rails http://api.rubyonrails.com/classes/HTML/Selector.html

  
describe "/questions/show that logged in user is not monitoring" do
  it_should_behave_like "/questions/show"
  
  it "should have a link to start monitoring" do
    response.should have_tag('a#monitor_link')
    onclick = "new Ajax.Request('/questions/#{@question.id}/monitored_by/#{@current_user.id}',
                       {asynchronous:true, evalScripts:true, method:'post'});
                       return false;"
    response.should have_tag("a#monitor_link[onclick=\"#{onclick}\"]")
  end
  
end