Sha256: 48c964f32caa1761ce020b8ad3bfc37d8cc38b5898938645c5a25139f71a9cc3

Contents?: true

Size: 1.32 KB

Versions: 17

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

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
    allow(column).to receive_messages :to_a => [column]
  end

  describe '#columns' do
    it 'returns the provided Column object' do
      expect(field.columns).to eq([column])
    end

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

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

  describe '#file?' do
    it "defaults to false" do
      expect(field).not_to be_file
    end

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

  describe '#with_attribute?' do
    it "defaults to false" do
      expect(field).not_to be_with_attribute
    end

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.5.1 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.5.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.4.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.3.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.2.1 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.2.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.1.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-5.0.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.4.1 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.4.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.3.2 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.3.1 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.3.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.2.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.1.0 spec/thinking_sphinx/active_record/field_spec.rb
thinking-sphinx-4.0.0 spec/thinking_sphinx/active_record/field_spec.rb