Sha256: 634157a8ec9451892afe982359ba93e66a06d6ea789de3d91e9b4793a93d25e1

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe ThinkingSphinx::ActiveRecord::Column do
  describe '#__name' do
    it "returns the top item" do
      column = ThinkingSphinx::ActiveRecord::Column.new(:content)
      column.__name.should == :content
    end
  end

  describe '#__stack' do
    it "returns all but the top item" do
      column = ThinkingSphinx::ActiveRecord::Column.new(:users, :posts, :id)
      column.__stack.should == [:users, :posts]
    end
  end

  describe '#method_missing' do
    let(:column) { ThinkingSphinx::ActiveRecord::Column.new(:user) }

    it "shifts the current name to the stack" do
      column.email
      column.__stack.should == [:user]
    end

    it "adds the new method call as the name" do
      column.email
      column.__name.should == :email
    end

    it "returns itself" do
      column.email.should == column
    end
  end

  describe '#string?' do
    it "is true when the name is a string" do
      column = ThinkingSphinx::ActiveRecord::Column.new('content')
      column.should be_a_string
    end

    it "is false when the name is a symbol" do
      column = ThinkingSphinx::ActiveRecord::Column.new(:content)
      column.should_not be_a_string
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.0 spec/thinking_sphinx/active_record/column_spec.rb
thinking-sphinx-3.0.0.rc spec/thinking_sphinx/active_record/column_spec.rb
thinking-sphinx-3.0.0.pre spec/thinking_sphinx/active_record/column_spec.rb