Sha256: be351b1a1d47c18d6521931115d5e6728b748d3bf285ba20a7a8100b896c5f08

Contents?: true

Size: 1.34 KB

Versions: 12

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe 'Contains queries' do
  let(:contained_within_regex)        { %r{\"people\"\.\"ip\" << '127.0.0.1/24'} }
  let(:contained_within_equals_regex) { %r{\"people\"\.\"ip\" <<= '127.0.0.1/24'} }
  let(:contains_regex)                { %r{\"people\"\.\"ip\" >> '127.0.0.1'} }
  let(:contains_equals_regex)         { %r{\"people\"\.\"ip\" >>= '127.0.0.1'} }

  describe '.where.contained_within(:column, value)' do
    it 'generates the appropriate where clause' do
      query = Person.where.contained_within(:ip => '127.0.0.1/24')
      query.to_sql.should match contained_within_regex
    end
  end

  describe '.where.contained_within_or_equals(:column, value)' do
    it 'generates the appropriate where clause' do
      query = Person.where.contained_within_or_equals(:ip => '127.0.0.1/24')
      query.to_sql.should match contained_within_equals_regex
    end
  end

  describe '.where.contains(:column, value)' do
    it 'generates the appropriate where clause' do
      query = Person.where.contains(:ip => '127.0.0.1')
      query.to_sql.should match contains_regex
    end
  end

  describe '.where.contained_within_or_equals(:column, value)' do
    it 'generates the appropriate where clause' do
      query = Person.where.contains_or_equals(:ip => '127.0.0.1')
      query.to_sql.should match contains_equals_regex
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
postgres_ext-2.1.3 spec/queries/contains_querie_spec.rb
postgres_ext-2.1.2 spec/queries/contains_querie_spec.rb
postgres_ext-2.1.1 spec/queries/contains_querie_spec.rb
postgres_ext-2.1.0 spec/queries/contains_querie_spec.rb
postgres_ext-2.0.0 spec/queries/contains_querie_spec.rb
postgres_ext-1.0.0 spec/queries/contains_querie_spec.rb
postgres_ext-0.4.0 spec/queries/contains_querie_spec.rb
postgres_ext-0.3.1 spec/queries/contains_querie_spec.rb
postgres_ext-0.3.0 spec/queries/contains_querie_spec.rb
postgres_ext-0.2.2 spec/queries/contains_querie_spec.rb
postgres_ext-0.2.1 spec/queries/contains_querie_spec.rb
postgres_ext-0.2.0 spec/queries/contains_querie_spec.rb