Sha256: 7ec4b065e359c70ea3389ba7b0b64ecbd22b03e3e3ea6867be23a67993462351

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

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

describe 'search with dynamic fields' do
  it 'returns dynamic string facet' do
    stub_facet(:"custom_string:test_ss", 'two' => 2, 'one' => 1)
    result = session.search(Post) { dynamic(:custom_string) { facet(:test) }}
    result.facet(:custom_string, :test).rows.map { |row| row.value }.should == ['two', 'one']
  end

  it 'returns query facet specified in dynamic call' do
    stub_query_facet(
      'custom_string\:test_ss:(foo OR bar)' => 3
    )
    search = session.search(Post) do
      dynamic :custom_string do
        facet :test do
          row :foo_bar do
            with :test, %w(foo bar)
          end
        end
      end
    end
    facet = search.facet(:test)
    facet.rows.first.value.should == :foo_bar
    facet.rows.first.count.should == 3
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sunspot-1.0.5 spec/api/search/dynamic_fields_spec.rb
sunspot-1.0.4 spec/api/search/dynamic_fields_spec.rb
sunspot-1.0.3 spec/api/search/dynamic_fields_spec.rb
sunspot-1.0.2 spec/api/search/dynamic_fields_spec.rb
sunspot-1.0.1 spec/api/search/dynamic_fields_spec.rb
sunspot-1.0.0 spec/api/search/dynamic_fields_spec.rb