Sha256: ef5660985144729d9bfc324b96e295525fbb2fec4654cc249bb9053658906bae

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require File.join(File.dirname(__FILE__), 'spec_helper')

describe 'raising exceptions' do
  
  describe 'on missing associations' do
    it 'should get AssociationNotFoundException' do
      lambda {
        Post.filter do
          having(:something_that_does_not_exist) do
            with(:something_bad)
          end
        end.inspect
      }.should raise_error(RecordFilter::AssociationNotFoundException)
    end
  end

  describe 'on missing columns' do
    it 'should get ColumnNotFoundException for with' do
      lambda {
        Post.filter do
          with(:this_is_not_there, 2)
        end.inspect
      }.should raise_error(RecordFilter::ColumnNotFoundException)
    end

    it 'should get ColumnNotFoundException for without' do
      lambda {
        Post.filter do
          without(:this_is_not_there, 2)
        end.inspect
      }.should raise_error(RecordFilter::ColumnNotFoundException)
    end

    it 'should get ColumnNotFoundException for order' do
      lambda {
        Post.filter do
          order(:this_is_not_there, :asc)
        end.inspect
      }.should raise_error(RecordFilter::ColumnNotFoundException)
    end

    it 'should get AssociationNotFoundException for orders on bad associations' do
      lambda {
        Post.filter do
          order({ :this_is_not_there => :eh }, :asc)
        end.inspect
      }.should raise_error(RecordFilter::AssociationNotFoundException)
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
aub-record_filter-0.1.2 spec/exception_spec.rb
outoftime-record_filter-0.1.3 spec/exception_spec.rb