Sha256: a153b2ca56d9e015e480ad1afc4fdcb82dde3b7c0d8d1131bef54f00e0870b0e

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe ActiveFedora::Base do
  before(:each) do
    #Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
    class Foo < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"foostream" do|m|
        m.field "foostream", :string
      end
      has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>"dcstream" 
      # do|m|
      #   m.field "fz", :string
      # end
    end
    class Bar  < ActiveFedora::Base
      has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"barstream" do |m|
        m.field "barfield", :string
      end
    end
  end

  it "doesn't overwrite stream specs" do
    f = Foo.new
    f.datastreams.size.should == 3
    streams = f.datastreams.values.map{|x| x.class.to_s}.sort
    streams.pop.should == "ActiveFedora::RelsExtDatastream"
    streams.pop.should == "ActiveFedora::QualifiedDublinCoreDatastream"
    streams.pop.should == "ActiveFedora::MetadataDatastream"
  end

  it "should work for multiple types" do
    b = Foo.new
    f = Bar.new
    b.class.ds_specs.should_not == f.class.ds_specs
  end
  after do
    Object.send(:remove_const, :Bar)
    Object.send(:remove_const, :Foo)
  end

end
  

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active-fedora-4.2.0 spec/unit/inheritance_spec.rb
active-fedora-4.1.0 spec/unit/inheritance_spec.rb
active-fedora-4.0.0 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc20 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc19 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc18 spec/unit/inheritance_spec.rb
active-fedora-4.0.0.rc17 spec/unit/inheritance_spec.rb