Created
July 11, 2011 05:41
-
-
Save mariovisic/1075360 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| context 'geo finding' do | |
| before :all do | |
| @location_one = Factory.build(:location, :lat => 42.000000, :lng => 0.000000) | |
| @location_two = Factory.create(:location, :lat => 42.000000, :lng => 0.050000) # 4.14km's from location one | |
| @location_three = Factory.create(:location, :lat => 42.000000, :lng => 0.100000) # 8.29km's from location one | |
| end | |
| after :all do | |
| Location.delete_all | |
| end | |
| it 'should match multiple locations given a range' do | |
| Location.within(10, :origin => @location_one).size.should == 2 | |
| end | |
| it 'should only match locations that are closer than the range given' do | |
| Location.within(5, :origin => @location_one).should include @location_two | |
| Location.within(5, :origin => @location_one).should_not include @location_three | |
| end | |
| it 'should return zero reults if no locations are within range' do | |
| Location.within(4, :origin => @location_one).should be_blank | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment