Skip to content

Instantly share code, notes, and snippets.

@thoughtbot
Created August 4, 2009 22:29
Show Gist options
  • Save thoughtbot/162347 to your computer and use it in GitHub Desktop.
Save thoughtbot/162347 to your computer and use it in GitHub Desktop.
class HouseSearchTest < ActiveSupport::TestCase
should "produce only houses with the keyword in the description when sent #results for such a search" do
matching_house = Factory(:house, :description => 'foo')
nonmatching_house = Factory(:house, :description => 'bar')
results = HouseSearch.new('keyword' => 'fo').results
assert_all(results) {|house| house.description =~ /fo/}
end
should "produce only houses within the price range when sent #results for such a search" do
matching_house = Factory(:house, :price => 10)
nonmatching_house = Factory(:house, :price => 50)
results = HouseSearch.new('price' => '30-100').results
assert_all(results) {|house| 30 <= house.price && house.price <= 100}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment