Sha256: 2440c97e49b1ee0b7d1eb5a6f459b0955338ca1ae9ac990dd7ccb00e0d9a586d

Contents?: true

Size: 1.55 KB

Versions: 65

Compression:

Stored size: 1.55 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

    it "should be a managed datastream" do
      subject.controlGroup.should == 'M'
    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

65 entries across 65 versions & 1 rubygems

Version Path
active-fedora-7.3.1 spec/unit/nom_datastream_spec.rb
active-fedora-7.3.0 spec/unit/nom_datastream_spec.rb
active-fedora-8.2.1 spec/unit/nom_datastream_spec.rb
active-fedora-8.2.0 spec/unit/nom_datastream_spec.rb
active-fedora-7.2.0 spec/unit/nom_datastream_spec.rb
active-fedora-8.1.0 spec/unit/nom_datastream_spec.rb
active-fedora-8.0.1 spec/unit/nom_datastream_spec.rb
active-fedora-8.0.0 spec/unit/nom_datastream_spec.rb
active-fedora-8.0.0.rc3 spec/unit/nom_datastream_spec.rb
active-fedora-8.0.0.rc2 spec/unit/nom_datastream_spec.rb
active-fedora-8.0.0.rc1 spec/unit/nom_datastream_spec.rb
active-fedora-7.1.2 spec/unit/nom_datastream_spec.rb
active-fedora-7.1.1 spec/unit/nom_datastream_spec.rb
active-fedora-7.1.0 spec/unit/nom_datastream_spec.rb
active-fedora-6.7.8 spec/unit/nom_datastream_spec.rb
active-fedora-7.0.4 spec/unit/nom_datastream_spec.rb
active-fedora-7.0.3 spec/unit/nom_datastream_spec.rb
active-fedora-7.0.2 spec/unit/nom_datastream_spec.rb
active-fedora-7.0.1 spec/unit/nom_datastream_spec.rb
active-fedora-7.0.0 spec/unit/nom_datastream_spec.rb