Sha256: 90efadc2c03a9b4c2ea7c21ada037968b94a0c0ffd90dc40e0a1fbf2fc806b38

Contents?: true

Size: 1.94 KB

Versions: 9

Compression:

Stored size: 1.94 KB

Contents

require "spec_helper"

def mods_display_description(mods)
  ModsDisplay::Description.new(mods, ModsDisplay::Configuration::Base.new, mock("controller"))
end

describe ModsDisplay::Description do
  before(:all) do
    @form = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><form>Form Note</form></physicalDescription></mods>", false).physical_description
    @display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription displayLabel='SpecialLabel'><form>Form Note</form></physicalDescription></mods>", false).physical_description
    @child_display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><form displayLabel='Form Label'>Form Note</form></physicalDescription></mods>", false).physical_description
    @mixed = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><form>Form Note</form><extent>Extent Note</extent></physicalDescription></mods>", false).physical_description
  end
  describe "labels" do
    it "should use the displayLabel if one is provided" do
      mods_display_description(@display_label).fields.first.label.should == "SpecialLabel"
    end
    it "should get the default label for a child element" do
      mods_display_description(@form).fields.first.label.should == "Form"
    end
    it "should get multiple lables for mixed content" do
      mods_display_description(@mixed).fields.map{|v| v.label }.should == ["Form", "Extent"]
    end
    it "should get the display label from child elements" do
      mods_display_description(@child_display_label).fields.map{|f| f.label }.should == ["Form Label"]
    end
  end
  
  describe "fields" do
    it "should get the value from a field in physicalDescription" do
      mods_display_description(@form).fields.first.values.should == ["Form Note"]
    end
    it "should get multiple values for mixed content" do
      mods_display_description(@mixed).fields.map{|v| v.values }.should == [["Form Note"], ["Extent Note"]]
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mods_display-0.1.3 spec/fields/description_spec.rb
mods_display-0.1.2 spec/fields/description_spec.rb
mods_display-0.1.1 spec/fields/description_spec.rb
mods_display-0.1.0 spec/fields/description_spec.rb
mods_display-0.0.5 spec/fields/description_spec.rb
mods_display-0.0.4 spec/fields/description_spec.rb
mods_display-0.0.3 spec/fields/description_spec.rb
mods_display-0.0.2 spec/fields/description_spec.rb
mods_display-0.0.1 spec/fields/description_spec.rb