require 'hpricot' require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe GoogleCustomSearch::SearchResultItem do MOCK_XML =<<-xml 0.129014Wicked Cultural District Search Engine 33 /custom?q=Wicked&hl=en&safe=off&client=google-csbe&cx=004905679161489350096:rymp5afccji&boostcse=0&site=culturaldistrict.org&output=xml_no_dtd&ie=UTF-8&oe=UTF-8&ei=wFH_TdLGI8fKgQfGpMXwCg&start=10&sa=N http://pgharts.culturaldistrict.org/production/26485http://pgharts.culturaldistrict.org/production/26485<b>Wicked</b> Pittsburgh Benedum Center Tickets0<b>Wicked</b> Pittsburgh Benedum Center Tickets Entertainment Weekly calls <b>WICKED</b> &quot;the <br> best musical of the decade,” and when it first played Pittsburgh in 2006, <b>...</b>en xml def item_xml results = Hpricot(MOCK_XML) (results/"r").first end it "should return the title of search item" do item = GoogleCustomSearch::SearchResultItem.new item_xml item.title.should == "Wicked Pittsburgh Benedum Center Tickets" end it "should return the url of search item" do item = GoogleCustomSearch::SearchResultItem.new item_xml item.url.should == "http://pgharts.culturaldistrict.org/production/26485" end it "should return the content of search item" do item = GoogleCustomSearch::SearchResultItem.new item_xml item.content.should_not be_nil end end