Sha256: 8097e9a998ee618c8a1b42343082131b211c990988f954e060f7333ba4a82c7b

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

def mods_display_resource_type(mods_record)
  ModsDisplay::ResourceType.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
end

describe ModsDisplay::ResourceType do
  before(:all) do
    @type = Stanford::Mods::Record.new.from_str(
      '<mods><typeOfResource>Resource Type</typeOfResource></mods>', false
    ).typeOfResource
    @downcase = Stanford::Mods::Record.new.from_str(
      '<mods><typeOfResource>resource type</typeOfResource></mods>', false
    ).typeOfResource
    @display_label = Stanford::Mods::Record.new.from_str(
      "<mods><typeOfResource displayLabel='Special label'>Resource Type</typeOfResource></mods>", false
    ).typeOfResource
  end
  it "should default to a label of 'Type of resource'" do
    fields = mods_display_resource_type(@type).fields
    expect(fields.length).to eq(1)
    expect(fields.first.label).to eq('Type of resource:')
  end
  it 'should use the displayLabel attribute when present' do
    fields = mods_display_resource_type(@display_label).fields
    expect(fields.length).to eq(1)
    expect(fields.first.label).to eq('Special label:')
  end
  it 'should capitalize the first letter of the values' do
    fields = mods_display_resource_type(@downcase).fields
    expect(fields.length).to eq(1)
    expect(fields.first.values).to eq(['Resource type'])
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mods_display-0.10.0 spec/fields/resource_type_spec.rb
mods_display-0.9.1 spec/fields/resource_type_spec.rb
mods_display-0.9.0 spec/fields/resource_type_spec.rb
mods_display-0.8.0 spec/fields/resource_type_spec.rb
mods_display-0.7.1 spec/fields/resource_type_spec.rb
mods_display-0.7.0 spec/fields/resource_type_spec.rb
mods_display-0.6.0 spec/fields/resource_type_spec.rb
mods_display-0.5.1 spec/fields/resource_type_spec.rb
mods_display-0.5.0 spec/fields/resource_type_spec.rb
mods_display-0.4.1 spec/fields/resource_type_spec.rb
mods_display-0.4.0 spec/fields/resource_type_spec.rb
mods_display-0.3.5 spec/fields/resource_type_spec.rb
mods_display-0.3.4 spec/fields/resource_type_spec.rb