internetee-registry/spec/models/white_ip_spec.rb
2015-05-19 16:47:29 +03:00

54 lines
1.3 KiB
Ruby

require 'rails_helper'
describe WhiteIp do
it { should belong_to(:registrar) }
context 'with invalid attribute' do
before :all do
@white_ip = WhiteIp.new
end
it 'is not valid' do
@white_ip.valid?
@white_ip.errors.full_messages.should match_array([
'IPv4 or IPv6 must be present'
])
end
it 'returns an error with invalid ips' do
@white_ip.ipv4 = 'bla'
@white_ip.ipv6 = 'bla'
@white_ip.valid?
@white_ip.errors[:ipv4].should == ['is invalid']
@white_ip.errors[:ipv6].should == ['is invalid']
end
end
# context 'with valid attributes' do
# before :all do
# @white_ip = Fabricate(:white_ip)
# end
# it 'should be valid' do
# @white_ip.valid?
# @white_ip.errors.full_messages.should match_array([])
# end
# it 'should be valid twice' do
# @white_ip = Fabricate(:white_ip)
# @white_ip.valid?
# @white_ip.errors.full_messages.should match_array([])
# end
# it 'should have one version' do
# with_versioning do
# @white_ip.versions.should == []
# @white_ip.ipv4 = '192.168.1.1'
# @white_ip.save
# @white_ip.errors.full_messages.should match_array([])
# @white_ip.versions.size.should == 1
# end
# end
# end
end