Sha256: 0b6bc828c8b54da11bf748dfcc440070f2e92aae2df1f05a9e91d4dee1ba293a

Contents?: true

Size: 834 Bytes

Versions: 18

Compression:

Stored size: 834 Bytes

Contents

require 'spec_helper'

describe 'INET column' do
  let!(:column) { ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new 'field', nil, 'inet'}
  let!(:adapter) { ActiveRecord::Base.connection }

  describe '#type_class_code' do
    it 'returns code for converting strings to IPAddr' do
      column.type_cast_code('v').should eq 'ActiveRecord::ConnectionAdapters::PostgreSQLColumn.string_to_cidr_address(v)'
    end
  end

  describe 'inet type casting' do
    it 'converts ip strings to NetAddr::CIDR objects' do
      column.type_cast('127.0.0.1').should be_a_kind_of IPAddr
    end
  end

  describe 'inet value conversion for SQL statments' do
    it 'returns the string value of the IPAddr address' do
      value = column.type_cast('127.0.0.1')
      adapter.type_cast(value, column).should eq '127.0.0.1/32'
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
postgres_ext-1.0.0 spec/columns/inet_spec.rb
postgres_ext-0.4.0 spec/columns/inet_spec.rb
postgres_ext-0.3.1 spec/columns/inet_spec.rb
postgres_ext-0.3.0 spec/columns/inet_spec.rb
postgres_ext-0.2.2 spec/columns/inet_spec.rb
postgres_ext-0.2.1 spec/columns/inet_spec.rb
postgres_ext-0.2.0 spec/columns/inet_spec.rb
postgres_ext-0.1.0 spec/columns/inet_spec.rb
postgres_ext-0.0.10 spec/columns/inet_spec.rb
postgres_ext-0.0.9 spec/columns/inet_spec.rb
postgres_ext-0.0.8 spec/columns/inet_spec.rb
postgres_ext-0.0.7 spec/columns/inet_spec.rb
postgres_ext-0.0.6 spec/columns/inet_spec.rb
postgres_ext-0.0.5 spec/columns/inet_spec.rb
postgres_ext-0.0.4 spec/columns/inet_spec.rb
postgres_ext-0.0.3 spec/columns/inet_spec.rb
postgres_ext-0.0.2 spec/columns/inet_spec.rb
postgres_ext-0.0.1 spec/columns/inet_spec.rb