Sha256: 8fbfbca6b5fd28d02e83077335b1074892cd097131a040b455a8c0e4d70afdd2

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

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

# require 'solrizer'
# require 'solrizer/field_name_mapper'

class FieldNameMapperTest
  include Solrizer::FieldNameMapper
end

def helper
  @test_instance
end

describe Solrizer::FieldNameMapper do
  
  before(:each) do
    @test_instance = FieldNameMapperTest.new
  end
  
  after(:all) do
    # Revert to default mappings after running tests
    Solrizer::FieldNameMapper.load_mappings
  end
  
  describe ".solr_name" do
    it "should generate solr field names from settings in solr_mappings" do
      helper.solr_name(:system_create, :date).should == :system_create_dt
    end
    it "should format the response based on the class of the input" do
      helper.solr_name(:system_create, :date).should == :system_create_dt
      helper.solr_name("system_create", :date).should == "system_create_dt"
    end
    it "should rely on whichever mappings have been loaded into the SolrService" do
      helper.solr_name(:system_create, :date).should == :system_create_dt
      helper.solr_name(:foo, :text).should == :foo_t
      Solrizer::FieldNameMapper.load_mappings(File.join(File.dirname(__FILE__), "..", "fixtures", "solr_mappings_af_0.1.yml"))
      helper.solr_name(:system_create, :date).should == :system_create_date
      helper.solr_name(:foo, :text).should == :foo_field
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solrizer-0.2.0 spec/units/field_name_mapper_spec.rb