Sha256: 2a73a63505dff3bdf4f2f2eab563793fe79c8dcb6b8fa429db960d25ce626dad

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'
require 'multi_solr/utils'

describe MultiSolr::SolrFilterRange do

  subject{ MultiSolr::SolrFilterSimple.new('test') }

  context 'render_value' do
    it "should return '' if value is nil" do
      subject.render_value(nil).should == ''
    end

    it "should return value as String" do
      subject.render_value(20).should == '20'
    end

    it "should use special renderer if configured" do
      value_script = ->(val, opt) { (val.to_i + 10).to_s }
      subject = MultiSolr::SolrFilterSimple.new('test', :render_value => value_script)
      subject.render_value('30').should == '40'
    end

  end

  context 'build_solr_query' do
    it do
      subject.build_solr_query(nil).should be_nil
    end

    it do
      subject.build_solr_query(10).should == 'test:10'
    end

    it do
      build_script = ->(val) { "-test:#{val}" }
      subject = MultiSolr::SolrFilterSimple.new('test', :solr_query => build_script)
      subject.build_solr_query(50).should == '-test:50'
    end

  end


  context 'label' do
    it do
      subject.label.should == 'test'
    end

    it do
      subject = MultiSolr::SolrFilterSimple.new('test', :label_prefix => 'L2')
      subject.label.should == 'L2-test'
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
multi-solr-01.12.00 spec/multi_solr/solr_filter_simple_spec.rb
multi-solr-01.11.01 spec/multi_solr/solr_filter_simple_spec.rb
multi-solr-01.11.00 spec/multi_solr/solr_filter_simple_spec.rb
multi-solr-01.10.00 spec/multi_solr/solr_filter_simple_spec.rb