Skip to content

Instantly share code, notes, and snippets.

@smsohan
Created August 10, 2011 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smsohan/1136189 to your computer and use it in GitHub Desktop.
Save smsohan/1136189 to your computer and use it in GitHub Desktop.
what_to_test
#example_code
def search(query, page_number)
third_party_search_library.search("*{query}*").from(page_number * page_size).size(page_size).matched_results
end
#example_unit_test
it "should search for partial match and return paged result" do
third_party_search_library.should_receive(:search).with('*new york*').and_return(cities)
cities.should_receive(:from).with(40).and_return(cities)
cities.should_receive(:size).with(20).and_return(cities)
City.search('new york', 2).should == cities
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment