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

46 lines
1.5 KiB
Ruby

require 'spec_helper'
describe JamIsp do
#before do
# JamIsp.delete_all
# JamIsp.createx(0x01020300, 0x010203ff, 1)
# JamIsp.createx(0x02030400, 0x020304ff, 2)
# JamIsp.createx(0x03040500, 0x030405ff, 3)
# JamIsp.createx(0x04050600, 0x040506ff, 4)
# JamIsp.createx(0xc0A80100, 0xc0A801ff, 5)
# JamIsp.createx(0xfffefd00, 0xfffefdff, 6)
#end
#after do
# JamIsp.delete_all
# JamIsp.createx(0x00000000, 0xffffffff, 1)
#end
it "count" do JamIsp.count.should == 16 end
let(:first_addr) { JamIsp.ip_to_num('1.2.3.4') }
let(:second_addr) { JamIsp.ip_to_num('2.3.4.5') }
let(:third_addr) { JamIsp.ip_to_num('3.4.5.6') }
let(:fourth_addr) { JamIsp.ip_to_num('4.5.6.7') }
let(:fifth_addr) { JamIsp.ip_to_num('192.168.1.107') }
let(:sixth_addr) { JamIsp.ip_to_num('255.254.253.252') }
it "first_addr" do first_addr.should == 0x01020304 end
it "second_addr" do second_addr.should == 0x02030405 end
it "third_addr" do third_addr.should == 0x03040506 end
it "fourth_addr" do fourth_addr.should == 0x04050607 end
it "fifth_addr" do fifth_addr.should == 0xc0A8016b end
it "sixth_addr" do sixth_addr.should == 0xfffefdfc end
let(:first) { JamIsp.lookup(0x01020304) }
let(:second) { JamIsp.lookup(0x12030405) }
let(:third) { JamIsp.lookup(0x43040506) }
let(:seventh) { JamIsp.lookup(0xffff0123) } # bogus
it "first.coid" do first.coid.should == 2 end
it "second.coid" do second.coid.should == 3 end
it "third.coid" do third.coid.should == 4 end
it "seventh" do seventh.should be_nil end
end