Sha256: d7391ab9877bed28641d51947c6c7926f3c6f67fb81039471c7295eaf5a386ab
Contents?: true
Size: 1.45 KB
Versions: 9
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' describe 'INET related AREL functions' do describe 'quoting IPAddr in sql statement' do it 'properly converts IPAddr to quoted strings when passed as an argument to a where clause' do Person.where(:ip => IPAddr.new('127.0.0.1')).to_sql.should include("'127.0.0.1/32'") end end describe 'contained with (<<) operator' do it 'converts Arel contained_within statements to <<' do arel_table = Person.arel_table arel_table.where(arel_table[:ip].contained_within(IPAddr.new('127.0.0.1/24'))).to_sql.should match /<< '127.0.0.0\/24'/ end end describe 'contained within or equals (<<=) operator' do it 'converts Arel contained_within_or_equals statements to <<=' do arel_table = Person.arel_table arel_table.where(arel_table[:ip].contained_within_or_equals(IPAddr.new('127.0.0.1/24'))).to_sql.should match /<<= '127.0.0.0\/24'/ end end describe 'contains (>>) operator' do it 'converts Arel contains statements to >>' do arel_table = Person.arel_table arel_table.where(arel_table[:ip].contains(IPAddr.new('127.0.0.1/24'))).to_sql.should match />> '127.0.0.0\/24'/ end end describe 'contains or equals (>>=) operator' do it 'converts Arel contains_or_equals statements to >>=' do arel_table = Person.arel_table arel_table.where(arel_table[:ip].contains_or_equals(IPAddr.new('127.0.0.1/24'))).to_sql.should match />>= '127.0.0.0\/24'/ end end end
Version data entries
9 entries across 9 versions & 1 rubygems