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

34 lines
1022 B
Ruby

require 'spec_helper'
describe GeoIpBlocks do
#before do
#GeoIpBlocks.delete_all
#GeoIpBlocks.createx(0x01020300, 0x010203ff, 1)
#GeoIpBlocks.createx(0x02030400, 0x020304ff, 2)
#end
#after do
#GeoIpBlocks.delete_all
#GeoIpBlocks.createx(0x00000000, 0xffffffff, 17192)
#end
it "count" do GeoIpBlocks.count.should == 16 end
let(:first) { GeoIpBlocks.lookup(0x01020304) } # 17192
let(:second) { GeoIpBlocks.lookup(0x12030405) } # 667
let(:third) { GeoIpBlocks.lookup(0xffff0001) } # bogus
it "first" do first.should_not be_nil end
it "first.beginip" do first.beginip.should == 0x00000000 end
it "first.endip" do first.endip.should == 0x0fffffff end
it "first.locid" do first.locid.should == 17192 end
it "second" do second.should_not be_nil end
it "second.beginip" do second.beginip.should == 0x10000000 end
it "second.endip" do second.endip.should == 0x1fffffff end
it "second.locid" do second.locid.should == 667 end
it "third" do third.should be_nil end
end