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

52 lines
1.8 KiB
Ruby

require 'spec_helper'
describe JamIsp do
before do
JamIsp.delete_all
JamIsp.make_row(0x01020300, 0x010203ff, 1)
JamIsp.make_row(0x02030400, 0x020304ff, 2)
JamIsp.make_row(0x03040500, 0x030405ff, 3)
JamIsp.make_row(0x04050600, 0x040506ff, 4)
JamIsp.make_row(0xc0A80100, 0xc0A801ff, 5)
JamIsp.make_row(0xfffefd00, 0xfffefdff, 6)
end
after do
JamIsp.delete_all
JamIsp.make_row(0x00000000, 0xffffffff, 1)
end
it "count" do JamIsp.count.should == 6 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(0x02030405) }
let(:third) { JamIsp.lookup(0x03040506) }
let(:fourth) { JamIsp.lookup(0x04050607) }
let(:fifth) { JamIsp.lookup(0xc0A8016b) }
let(:sixth) { JamIsp.lookup(0xfffefdfc) }
let(:seventh) { JamIsp.lookup(0) } # bogus
it "first.coid" do first.coid.should == 1 end
it "second.coid" do second.coid.should == 2 end
it "third.coid" do third.coid.should == 3 end
it "fourth.coid" do fourth.coid.should == 4 end
it "fifth.coid" do fifth.coid.should == 5 end
it "sixth.coid" do sixth.coid.should == 6 end
it "seventh" do seventh.should be_nil end
end