Sha256: 8e807833a988f0b771c53e359eb2900b72a2195b53502bc7a49012e61632e3c8

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

require 'spec_helper'

describe UniversalValidators::IpValidator do
  describe '.valid?' do
    context 'with valid ip address' do
      it "return true" do
        ip = UniversalValidators::IpValidator.new('127.0.0.1')
        expect(ip).to be_valid

        ip = UniversalValidators::IpValidator.new('127.0.0.1/32', true)
        expect(ip).to be_valid
      end
    end

    context 'with invalid ip address' do
      it "return false" do
        ip = UniversalValidators::IpValidator.new('256.0.0.1')
        expect(ip).to_not be_valid

        ip = UniversalValidators::IpValidator.new('127.0.0.1', true)
        expect(ip).to_not be_valid

        ip = UniversalValidators::IpValidator.new('127.0.0.1/33', true)
        expect(ip).to_not be_valid
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
universal_validators-1.0.0 spec/ip_validator_spec.rb