Sha256: 651918c3d7c948d46e817ed73a59236d35d10c994a4d866607170af595528c1a

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe ThinkingSphinx::ActiveRecord::Field do
  let(:field)        { ThinkingSphinx::ActiveRecord::Field.new model, column }
  let(:column)       { double('column', :__name => :title, :__stack => [],
    :string? => false) }
  let(:model)        { double('model') }

  before :each do
    column.stub! :to_a => [column]
  end

  describe '#columns' do
    it 'returns the provided Column object' do
      field.columns.should == [column]
    end

    it 'translates symbols to Column objects' do
      ThinkingSphinx::ActiveRecord::Column.should_receive(:new).with(:title).
        and_return(column)

      ThinkingSphinx::ActiveRecord::Field.new model, :title
    end
  end

  describe '#file?' do
    it "defaults to false" do
      field.should_not be_file
    end

    it "is true if file option is set" do
      field = ThinkingSphinx::ActiveRecord::Field.new model, column,
        :file => true
      field.should be_file
    end
  end

  describe '#with_attribute?' do
    it "defaults to false" do
      field.should_not be_with_attribute
    end

    it "is true if the field is sortable" do
      field = ThinkingSphinx::ActiveRecord::Field.new model, column,
        :sortable => true
      field.should be_with_attribute
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinking-sphinx-3.2.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.1.4 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.1.3 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.1.2 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.1.1 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.1.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-3.0.6 spec/thinking_sphinx/active_record/field_spec.rb