Created
December 1, 2009 15:10
-
-
Save somebox/246345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example tests | |
test "geocoder is used when new point is saved" do | |
geocoder_should_be_used | |
p = Point.new(:address => ..., :city => ... ) | |
assert p.save | |
end | |
test "point will re-geocode if the address changes" do | |
gecoder_should_be_used # only once! | |
p = Point.create( ... ) | |
p.title = "new" | |
p.save # 2nd save | |
end | |
test "point won't re-geocode unless the address changes" do | |
gecoder_should_be_used(2) # twice! | |
p = Point.create( ... ) | |
p.address = "new address" | |
p.save # 2nd save, 2nd geocode due to new address | |
end | |
test "a validation error is raised when a point is saved with an invalid address" do | |
geocoder_should_fail | |
p = Point.new(.. :address => 'xxxxxxx', :city => 'yyyyy') | |
assert !p.save | |
assert_match /invalid address/i, p.errors[:address] | |
end | |
test "points know when they are east or west" do | |
mock_geocoder_returns(:lat => -40.77, :lng => -73.33) # NYC | |
p = Point.new( ... ) | |
assert p.east_coast? | |
assert !p.west_coast? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment