jam-cloud/web/spec/managers/maxmind_manager_spec.rb

46 lines
1.3 KiB
Ruby

require 'spec_helper'
# these tests avoid the use of ActiveRecord and FactoryGirl to do blackbox, non test-instrumented tests
describe MaxMindManager do
before(:each) do
@maxmind_manager = MaxMindManager.new(:conn => @conn)
MaxMindManager.active_record_transaction do |manager|
manager.create_phony_database()
end
end
it "looks up countries successfully" do
countries = MaxMindManager.countries()
countries.length.should == 1
countries[0] == "US"
end
it "looks up regions successfully" do
regions = MaxMindManager.regions("US")
regions.length.should == 128
regions.first.should == "Region 0"
regions.last.should == "Region 99" # Based on sort order this will be the top.
end
it "looks up cities successfully" do
cities = MaxMindManager.cities("US", "Region 1")
cities.length.should == 2
cities.first.should == "City 2"
cities.last.should == "City 3"
end
it "looks up isp successfully" do
isp = MaxMindManager.lookup_isp("127.0.0.1")
isp.should == "ISP 127"
end
it "looks up isp-by-country succesfully" do
isps = MaxMindManager.isps("US")
isps.length.should == 256 # because the phone_database method creates 256 isps, all in US
end
end