Sha256: 1df4027afdffa2f4e3f1acfa8df77aca006d161212704059ed1a1552fef8aa67

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

RSpec.describe RSolr::Document do
  describe RSolr::Field do
    describe ".instance" do
      subject { RSolr::Field }

      it "uses the class name of the field value" do
        expect(subject.instance({}, Time.new)).to be_a_kind_of(RSolr::TimeField)
      end

      it "uses the provided type option when it is a class" do
        expect(subject.instance({:type => RSolr::TimeField}, nil)).to be_a_kind_of(RSolr::TimeField)
      end

      it "uses the provided type option when it is a string" do
        expect(subject.instance({:type => 'Time'}, nil)).to be_a_kind_of(RSolr::TimeField)
      end

      it "falls back to the base Field class" do
        expect(subject.instance({:type => 'UndefinedType'}, nil)).to be_a_kind_of(RSolr::Field)
      end

      it "defaults to the base Field class" do
        expect(subject.instance({}, nil)).to be_a_kind_of(RSolr::Field)
      end
    end
  end

  describe RSolr::TimeField do
    it "convert value to string" do
      time_value = Time.utc(2013, 9, 11, 18, 10, 0)
      expect(RSolr::Field.instance({}, time_value).value).to eq '2013-09-11T18:10:00Z'
    end

    it "convert time to UTC" do
      time_value = Time.new(2013, 9, 11, 18, 10, 0, '+02:00')
      expect(RSolr::Field.instance({}, time_value).value).to eq '2013-09-11T16:10:00Z'
    end
  end

  describe RSolr::DateField do
    it "convert value to string" do
      date_value = Date.new(2013, 9, 11)
      expect(RSolr::Field.instance({}, date_value).value).to eq '2013-09-11T00:00:00Z'
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rsolr-2.6.0/spec/api/document_spec.rb
rsolr-2.6.0 spec/api/document_spec.rb
rsolr-2.5.0 spec/api/document_spec.rb
rsolr-2.4.0 spec/api/document_spec.rb
rsolr-2.3.0 spec/api/document_spec.rb
telvue-rsolr-2.2.2 spec/api/document_spec.rb
rsolr-2.2.1 spec/api/document_spec.rb
rsolr-2.2.0 spec/api/document_spec.rb
rsolr-2.1.0 spec/api/document_spec.rb
rsolr-2.0.2 spec/api/document_spec.rb
rsolr-2.0.1 spec/api/document_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rsolr-2.0.0/spec/api/document_spec.rb
rsolr-2.0.0 spec/api/document_spec.rb
rsolr-2.0.0.rc1 spec/api/document_spec.rb
rsolr-2.0.0.pre3 spec/api/document_spec.rb
rsolr-2.0.0.pre2 spec/api/document_spec.rb
rsolr-2.0.0.pre1 spec/api/document_spec.rb