Sha256: 422825b09ca407935b0e6af7126decf42d0e71d3348764b84e1387487c0a2be1

Contents?: true

Size: 2 KB

Versions: 11

Compression:

Stored size: 2 KB

Contents

require File.join( File.dirname(__FILE__),  "../spec_helper" )

require 'ruby-fedora'


describe Fedora::Datastream do
  
  before(:each) do
    Fedora::Repository.register(ActiveFedora.fedora_config[:url])
    @test_datastream = Fedora::Datastream.new
  end
  
  it "should track the controlgroup attr" do
    td = Fedora::Datastream.new(:controlGroup=>'M')
    td.control_group.should == 'M'
  end
  
  it "should provide .url" do
    @test_datastream.should respond_to(:url)
    @test_datastream.expects(:pid).returns("_foo_")
    @test_datastream.url.should == 'http://localhost:8983/fedora/objects/_foo_/datastreams/'
  end
  
  describe ".url" do
    it "should return the Repository base_url with /objects/pid appended" do
      Fedora::Repository.instance.expects(:base_url).returns("BASE_URL")
      @test_datastream.expects(:pid).returns("_PID_")
      @test_datastream.expects(:dsid).returns("_DSID_")
      @test_datastream.url.should == "BASE_URL/objects/_PID_/datastreams/_DSID_"
    end
  end
  
  describe ".label" do
    it "should return the dsLabel attribute" do
      @test_datastream.label.should == @test_datastream.attributes[:dsLabel]
    end
  end
  
  describe ".label=" do
    it "should set the dsLabel attribute" do
      @test_datastream.label.should_not == "Foo dsLabel"
      @test_datastream.attributes[:dsLabel].should_not == "Foo dsLabel"
      @test_datastream.label = "Foo dsLabel"
      @test_datastream.label.should == "Foo dsLabel"
      @test_datastream.attributes[:dsLabel].should == "Foo dsLabel"
    end
  end
  
  describe ".mime_type" do
    it "should return the mimeType attribute" do
      @test_datastream.mime_type.should == @test_datastream.attributes["mimeType"]
    end
  end

  describe ".mime_type=" do
    it "should set the mimeType attribute" do
      @test_datastream.mime_type.should_not == "foo/bar"
      @test_datastream.attributes["mimeType"].should_not == "foo/bar"
      @test_datastream.mime_type= "foo/bar"
      @test_datastream.mime_type.should == "foo/bar"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active-fedora-3.0.7 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.6 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.5 spec/unit/rf_datastream_spec.rb
active-fedora-2.3.8 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.4 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.3 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.1 spec/unit/rf_datastream_spec.rb
active-fedora-3.0.0 spec/unit/rf_datastream_spec.rb
active-fedora-2.3.7 spec/unit/rf_datastream_spec.rb
active-fedora-2.3.4 spec/unit/rf_datastream_spec.rb
active-fedora-2.3.3 spec/unit/rf_datastream_spec.rb