Sha256: a362ee65a7a624ebb75aaafebc337e6dfcc7d7c5c8b470cdb7749564a2ccecf1

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

require "spec_helper"

def mods_display_collection(mods_record)
  ModsDisplay::Collection.new(mods_record, ModsDisplay::Configuration::Base.new, mock("controller"))
end

describe ModsDisplay::Collection do
  before(:all) do
    @collection = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title>The Collection</title></titleInfo><typeOfResource collection='yes' /></relatedItem></mods>", false).related_item
    @non_collection = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title>Not a Collection</title></titleInfo></relatedItem></mods>", false).related_item
    @display_label = Stanford::Mods::Record.new.from_str("<mods><relatedItem displayLabel='Special Collection'><titleInfo><title>Not a Collection</title></titleInfo></relatedItem></mods>", false).related_item
  end
  describe "label" do
    it "should default to Collection" do
      mods_display_collection(@collection).label.should == "Collection"
    end
    it "should get the displayLabel if available" do
      mods_display_collection(@display_label).label.should == "Special Collection"
    end
  end
  describe "fields" do
    it "should get a collection title if there is an appropriate typeOfResource field with the collection attribute" do
      fields = mods_display_collection(@collection).fields
      fields.length.should == 1
      fields.first.values.should == ["The Collection"]
    end
    it "should not return anything if the there is not an appropriate typeOfResource field with the collection attribute" do
      mods_display_collection(@non_collection).fields.should == []
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mods_display-0.1.4 spec/fields/collection_spec.rb
mods_display-0.1.3 spec/fields/collection_spec.rb
mods_display-0.1.2 spec/fields/collection_spec.rb
mods_display-0.1.1 spec/fields/collection_spec.rb
mods_display-0.1.0 spec/fields/collection_spec.rb
mods_display-0.0.5 spec/fields/collection_spec.rb
mods_display-0.0.4 spec/fields/collection_spec.rb
mods_display-0.0.3 spec/fields/collection_spec.rb
mods_display-0.0.2 spec/fields/collection_spec.rb
mods_display-0.0.1 spec/fields/collection_spec.rb
mods_display-0.0.1.beta6 spec/fields/collection_spec.rb
mods_display-0.0.1.beta5 spec/fields/collection_spec.rb
mods_display-0.0.1.beta4 spec/fields/collection_spec.rb
mods_display-0.0.1.beta3 spec/fields/collection_spec.rb
mods_display-0.0.1.beta2 spec/fields/collection_spec.rb
mods_display-0.0.1.beta1 spec/fields/collection_spec.rb