Sha256: d0a605c9cc1f1764f15700f48c28418a485ee115f4d3e19df78d7238916d1b1e

Contents?: true

Size: 1.45 KB

Versions: 26

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe ActiveFedora::NomDatastream do
  describe "test" do
    subject {
      class MyNomDatastream < ActiveFedora::NomDatastream
       
        set_terminology do |t|
          t.a :path => '//a', :accessor => lambda { |x| x.text }, :index => 'a_s'
          t.b :path => '//b', :index => 'b_s'
        end
      end 

      MyNomDatastream.from_xml '<root><a>123</a><b><c>asdf</c></b></root>'
    }

    it "should work" do
      subject.a.should include("123")
    end

    it "should to_solr" do
      subject.to_solr['a_s'].should include('123')
      subject.to_solr['b_s'].should include('asdf')
    end
  end

  describe "with options for .set_terminology" do
    subject {
      class TerminologyOptions < ActiveFedora::NomDatastream
        set_terminology({
          :namespaces => {
            'dc' => "http://purl.org/dc/elements/1.1/",
            'dcterms' => "http://purl.org/dc/terms/"
          }
        }) do |t|
          t.a :path => 'a', :xmlns => 'dc', :accessor => lambda { |x| x.text }
        end
      end

      TerminologyOptions.from_xml %(
        <root
          xmlns:dc="http://purl.org/dc/elements/1.1/"
          xmlns:dcterms="http://purl.org/dc/terms/"
        >
          <dc:a>123</dc:a>
          <dcterms:a>not-part-of-a</dcterms:a>
          <dcterms:b>abcd</dcterms:b>
        </root>
      )
    }

    it "should scope #a attribute to only the dc namespace" do
      subject.a.should == ["123"]
    end

  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
active-fedora-5.7.1 spec/unit/nom_datastream_spec.rb
active-fedora-5.7.0 spec/unit/nom_datastream_spec.rb
active-fedora-5.6.3 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.rc5 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.rc4 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.rc3 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.rc2 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.rc1 spec/unit/nom_datastream_spec.rb
active-fedora-5.6.2 spec/unit/nom_datastream_spec.rb
active-fedora-5.6.1 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre10 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre9 spec/unit/nom_datastream_spec.rb
active-fedora-5.6.0 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre8 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre7 spec/unit/nom_datastream_spec.rb
active-fedora-5.5.2 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre6 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre5 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre4 spec/unit/nom_datastream_spec.rb
active-fedora-6.0.0.pre3 spec/unit/nom_datastream_spec.rb