Sha256: 366ff4e4723265137cddb910b761e22a22a2537068dc291e94c3d4f0344b6c5a
Contents?: true
Size: 1.98 KB
Versions: 9
Compression:
Stored size: 1.98 KB
Contents
require File.join( File.dirname(__FILE__), "../spec_helper" ) require 'active_fedora' require "rexml/document" require 'ftools' describe ActiveFedora::Datastream do before(:each) do @test_object = ActiveFedora::Base.new @test_object.save end after(:each) do @test_object.delete end it "should be able to access Datastreams using datastreams method" do dc = @test_object.datastreams["DC"] dc.should be_an_instance_of(ActiveFedora::Datastream) dc.attributes.should be_an_instance_of(Hash) dc.attributes["dsid"].to_s.should eql("DC") dc.attributes[:pid].should_not be_nil # dc.control_group.should == "X" end it "should be able to access Datastream content using content method" do dc = @test_object.datastreams["DC"].content dc.should_not be_nil end it "should be able to update XML Datastream content and save to Fedora" do xml_content =REXML::Document.new(@test_object.datastreams["DC"].content) title = REXML::Element.new "dc:title" title.text = "Test Title" xml_content.root.elements << title @test_object.datastreams["DC"].content = xml_content.to_s @test_object.datastreams["DC"].save @test_object.datastreams["DC"].content.should eql(Fedora::Repository.instance.fetch_custom(@test_object.pid, "datastreams/DC/content")) end it "should be able to update Blob Datastream content and save to Fedora" do dsid = "ds#{Time.now.to_i}" ds = ActiveFedora::Datastream.new(:dsID => dsid, :dsLabel => 'hello', :altIDs => '3333', :controlGroup => 'M', :blob => fixture('dino.jpg').read) ds.blob.should == fixture('dino.jpg').read @test_object.add_datastream(ds).should be_true @test_object.save to = ActiveFedora::Base.load_instance(@test_object.pid) to.should_not be_nil to.datastreams[dsid].should_not be_nil # to.datastreams[dsid].control_group.should == "M" to.datastreams[dsid].content.should == fixture('dino.jpg').read end end
Version data entries
9 entries across 9 versions & 1 rubygems