jam-cloud/ruby/spec/jam_ruby/models/geo_ip_locations_spec.rb

37 lines
1.0 KiB
Ruby

require 'spec_helper'
describe GeoIpLocations do
before do
GeoIpLocations.delete_all
GeoIpLocations.createx(17192, 'US', 'TX', 'Austin', '78749', 30.2076, -97.8587, 635, '512')
GeoIpLocations.createx(48086, 'MX', '28', 'Matamoros', '', 25.8833, -97.5000, nil, '')
end
it "count" do GeoIpLocations.count.should == 2 end
let(:first) { GeoIpLocations.lookup(17192) }
let(:second) { GeoIpLocations.lookup(48086) }
let(:third) { GeoIpLocations.lookup(999999) } # bogus
it "first" do
first.locid.should == 17192
first.countrycode.should eql('US')
first.region.should eql('TX')
first.city.should eql('Austin')
first.latitude.should == 30.2076
first.longitude.should == -97.8587
end
it "second" do
second.locid.should == 48086
second.countrycode.should eql('MX')
second.region.should eql('28')
second.city.should eql('Matamoros')
second.latitude.should == 25.8833
second.longitude.should == -97.5000
end
it "third" do third.should be_nil end
end