jam-cloud/spec/managers/maxmind_manager_spec.rb

37 lines
961 B
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)
end
it "looks up regions successfully" do
MaxMindManager.active_record_transaction do |manager|
manager.create_phony_database()
end
regions = MaxMindManager.regions("Country")
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
MaxMindManager.active_record_transaction do |manager|
manager.create_phony_database()
end
cities = MaxMindManager.cities("Country", "Region 1")
cities.length.should == 2
cities.first.should == "City 2"
cities.last.should == "City 3"
end
end