mods_display 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +16 -0
  3. data/.rubocop_todo.yml +60 -0
  4. data/.travis.yml +2 -2
  5. data/Rakefile +10 -2
  6. data/lib/mods_display.rb +42 -42
  7. data/lib/mods_display/configuration.rb +69 -67
  8. data/lib/mods_display/configuration/access_condition.rb +17 -13
  9. data/lib/mods_display/configuration/base.rb +27 -24
  10. data/lib/mods_display/configuration/format.rb +8 -4
  11. data/lib/mods_display/configuration/genre.rb +8 -4
  12. data/lib/mods_display/configuration/imprint.rb +12 -7
  13. data/lib/mods_display/configuration/name.rb +8 -4
  14. data/lib/mods_display/configuration/note.rb +8 -4
  15. data/lib/mods_display/configuration/related_item.rb +8 -4
  16. data/lib/mods_display/configuration/subject.rb +11 -9
  17. data/lib/mods_display/configuration/title.rb +8 -4
  18. data/lib/mods_display/controller_extension.rb +24 -24
  19. data/lib/mods_display/country_codes.rb +385 -384
  20. data/lib/mods_display/fields/abstract.rb +7 -6
  21. data/lib/mods_display/fields/access_condition.rb +55 -55
  22. data/lib/mods_display/fields/audience.rb +7 -6
  23. data/lib/mods_display/fields/cartographics.rb +15 -14
  24. data/lib/mods_display/fields/collection.rb +32 -17
  25. data/lib/mods_display/fields/contact.rb +15 -13
  26. data/lib/mods_display/fields/contents.rb +7 -6
  27. data/lib/mods_display/fields/description.rb +21 -21
  28. data/lib/mods_display/fields/field.rb +164 -109
  29. data/lib/mods_display/fields/format.rb +36 -33
  30. data/lib/mods_display/fields/genre.rb +12 -11
  31. data/lib/mods_display/fields/identifier.rb +34 -34
  32. data/lib/mods_display/fields/imprint.rb +258 -214
  33. data/lib/mods_display/fields/language.rb +18 -16
  34. data/lib/mods_display/fields/location.rb +27 -26
  35. data/lib/mods_display/fields/name.rb +113 -118
  36. data/lib/mods_display/fields/note.rb +33 -34
  37. data/lib/mods_display/fields/related_item.rb +64 -66
  38. data/lib/mods_display/fields/resource_type.rb +13 -11
  39. data/lib/mods_display/fields/sub_title.rb +6 -4
  40. data/lib/mods_display/fields/subject.rb +92 -90
  41. data/lib/mods_display/fields/title.rb +54 -49
  42. data/lib/mods_display/fields/values.rb +7 -8
  43. data/lib/mods_display/html.rb +117 -96
  44. data/lib/mods_display/model_extension.rb +17 -16
  45. data/lib/mods_display/relator_codes.rb +269 -267
  46. data/lib/mods_display/version.rb +1 -1
  47. data/mods_display.gemspec +13 -12
  48. data/spec/configuration/access_condition_spec.rb +5 -5
  49. data/spec/configuration/base_spec.rb +24 -24
  50. data/spec/fields/abstract_spec.rb +24 -14
  51. data/spec/fields/access_condition_spec.rb +80 -55
  52. data/spec/fields/audience_spec.rb +15 -12
  53. data/spec/fields/cartographics_spec.rb +17 -18
  54. data/spec/fields/collection_spec.rb +65 -19
  55. data/spec/fields/contact_spec.rb +11 -9
  56. data/spec/fields/contents_spec.rb +15 -12
  57. data/spec/fields/description_spec.rb +40 -22
  58. data/spec/fields/format_spec.rb +28 -18
  59. data/spec/fields/genre_spec.rb +18 -16
  60. data/spec/fields/identifier_spec.rb +46 -34
  61. data/spec/fields/imprint_spec.rb +151 -125
  62. data/spec/fields/language_spec.rb +36 -20
  63. data/spec/fields/location_spec.rb +43 -27
  64. data/spec/fields/name_spec.rb +92 -92
  65. data/spec/fields/note_spec.rb +53 -40
  66. data/spec/fields/related_item_spec.rb +42 -40
  67. data/spec/fields/resource_type_spec.rb +20 -14
  68. data/spec/fields/sub_title_spec.rb +11 -9
  69. data/spec/fields/subject_spec.rb +61 -56
  70. data/spec/fields/title_spec.rb +53 -40
  71. data/spec/fixtures/access_condition_fixtures.rb +50 -0
  72. data/spec/fixtures/cartographics_fixtures.rb +1 -1
  73. data/spec/fixtures/imprint_fixtures.rb +49 -1
  74. data/spec/fixtures/name_fixtures.rb +195 -2
  75. data/spec/fixtures/related_item_fixtures.rb +107 -0
  76. data/spec/fixtures/subjects_fixtures.rb +15 -2
  77. data/spec/fixtures/title_fixtures.rb +101 -0
  78. data/spec/integration/configuration_spec.rb +23 -20
  79. data/spec/integration/html_spec.rb +40 -29
  80. data/spec/integration/installation_spec.rb +14 -14
  81. data/spec/spec_helper.rb +5 -8
  82. metadata +25 -3
@@ -1,3 +1,3 @@
1
1
  module ModsDisplay
2
- VERSION = "0.3.3"
2
+ VERSION = '0.3.4'
3
3
  end
data/mods_display.gemspec CHANGED
@@ -4,22 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mods_display/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "mods_display"
7
+ gem.name = 'mods_display'
8
8
  gem.version = ModsDisplay::VERSION
9
- gem.authors = ["Jessie Keck"]
10
- gem.email = ["jessie.keck@gmail.com"]
11
- gem.description = %q{MODS Display is a gem to centralize the display logic of MODS medadata.}
12
- gem.summary = %q{The MODS Display gem allows implementers to configure a customized display of MODS metadata. This display implements the specifications defined at Stanford for how to display MODS.}
13
- gem.homepage = "https://github.com/sul-dlss/mods_display"
9
+ gem.authors = ['Jessie Keck']
10
+ gem.email = ['jessie.keck@gmail.com']
11
+ gem.description = 'MODS Display is a gem to centralize the display logic of MODS medadata.'
12
+ gem.summary = 'The MODS Display gem allows implementers to configure a customized display of MODS metadata. This display implements the specifications defined at Stanford for how to display MODS.'
13
+ gem.homepage = 'https://github.com/sul-dlss/mods_display'
14
14
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(spec)/})
18
- gem.require_paths = ["lib"]
19
-
18
+ gem.require_paths = ['lib']
19
+
20
20
  gem.add_dependency 'stanford-mods'
21
21
  gem.add_dependency 'i18n'
22
-
22
+
23
23
  gem.add_development_dependency 'rake'
24
- gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'rspec', '~> 3.0'
25
+ gem.add_development_dependency 'rubocop'
25
26
  end
@@ -1,10 +1,10 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe ModsDisplay::Configuration::AccessCondition do
4
- it "should default ignore? to true" do
5
- ModsDisplay::Configuration::AccessCondition.new.ignore?.should be_true
4
+ it 'should default ignore? to true' do
5
+ expect(ModsDisplay::Configuration::AccessCondition.new.ignore?).to be true
6
6
  end
7
- it "should set ignore? to false when the display! configuration is set" do
8
- ModsDisplay::Configuration::AccessCondition.new{ display! }.ignore?.should be_false
7
+ it 'should set ignore? to false when the display! configuration is set' do
8
+ expect(ModsDisplay::Configuration::AccessCondition.new { display! }.ignore?).to be false
9
9
  end
10
10
  end
@@ -1,39 +1,39 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe ModsDisplay::Configuration::Base do
4
- it "should set config options w/ a block" do
5
- config = ModsDisplay::Configuration::Base.new do
6
- label_class "testing_label_class"
7
- value_class "testing_value_class"
4
+ it 'should set config options w/ a block' do
5
+ config = ModsDisplay::Configuration::Base.new do
6
+ label_class 'testing_label_class'
7
+ value_class 'testing_value_class'
8
8
  end
9
- config.label_class.should == "testing_label_class"
10
- config.value_class.should == "testing_value_class"
9
+ expect(config.label_class).to eq('testing_label_class')
10
+ expect(config.value_class).to eq('testing_value_class')
11
11
  end
12
- describe "link" do
13
- it "should return an array with a method name and params" do
14
- ModsDisplay::Configuration::Base.new do
12
+ describe 'link' do
13
+ it 'should return an array with a method name and params' do
14
+ expect(ModsDisplay::Configuration::Base.new do
15
15
  link :my_url_generating_method, q: '"%value%"'
16
- end.link.should == [:my_url_generating_method, {:q => '"%value%"'}]
16
+ end.link).to eq([:my_url_generating_method, { q: '"%value%"' }])
17
17
  end
18
18
  end
19
- describe "delmiter" do
20
- it "should override the default delimiter" do
21
- ModsDisplay::Configuration::Base.new do
22
- delimiter "<br/>"
23
- end.delimiter.should == "<br/>"
19
+ describe 'delmiter' do
20
+ it 'should override the default delimiter' do
21
+ expect(ModsDisplay::Configuration::Base.new do
22
+ delimiter '<br/>'
23
+ end.delimiter).to eq('<br/>')
24
24
  end
25
25
  it "should default to ', '" do
26
- ModsDisplay::Configuration::Base.new.delimiter.should == ", "
26
+ expect(ModsDisplay::Configuration::Base.new.delimiter).to eq(', ')
27
27
  end
28
28
  end
29
- describe "ignore" do
30
- it "should be set to true if the #ignore! method is called" do
31
- ModsDisplay::Configuration::Base.new do
29
+ describe 'ignore' do
30
+ it 'should be set to true if the #ignore! method is called' do
31
+ expect(ModsDisplay::Configuration::Base.new do
32
32
  ignore!
33
- end.ignore?.should be_true
33
+ end.ignore?).to be true
34
34
  end
35
- it "should be false by default" do
36
- ModsDisplay::Configuration::Base.new.ignore?.should be_false
35
+ it 'should be false by default' do
36
+ expect(ModsDisplay::Configuration::Base.new.ignore?).to be false
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -1,29 +1,39 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  def mods_display_abstract(mods_record)
4
- ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
4
+ ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
5
5
  end
6
6
 
7
7
  describe ModsDisplay::Abstract do
8
8
  before(:all) do
9
- @link = Stanford::Mods::Record.new.from_str("<mods><abstract>A link to the library (http://library.stanford.edu) should appear here</abstract></mods>", false).abstract
10
- @email = Stanford::Mods::Record.new.from_str("<mods><abstract>A link to an email address jdoe@example.com should appear here</abstract></mods>", false).abstract
9
+ @link = Stanford::Mods::Record.new.from_str(
10
+ '<mods><abstract>A link to the library (http://library.stanford.edu) should appear here</abstract></mods>', false
11
+ ).abstract
12
+ @email = Stanford::Mods::Record.new.from_str(
13
+ '<mods><abstract>A link to an email address jdoe@example.com should appear here</abstract></mods>', false
14
+ ).abstract
11
15
  end
12
-
13
- describe "labels" do
16
+
17
+ describe 'labels' do
14
18
  it "should get a default 'Abstract' label" do
15
19
  fields = mods_display_abstract(@link).fields
16
- fields.length.should == 1
17
- fields.first.label.should == "Abstract:"
20
+ expect(fields.length).to eq(1)
21
+ expect(fields.first.label).to eq('Abstract:')
18
22
  end
19
23
  end
20
24
 
21
- describe "links" do
22
- it "should turn URLs into links" do
23
- mods_display_abstract(@link).to_html.should match(/A link to the library \(<a href='http:\/\/library.stanford.edu'>http:\/\/library.stanford.edu<\/a>\) should appear here/)
25
+ describe 'links' do
26
+ it 'should turn URLs into links' do
27
+ expect(mods_display_abstract(@link).to_html).to match(/A link to the library \(<a href/)
28
+ expect(mods_display_abstract(@link).to_html).to match(
29
+ %r{\(<a href='http://library.stanford.edu'>http://library.stanford.edu</a>\)}
30
+ )
31
+ expect(mods_display_abstract(@link).to_html).to match(%r{</a>\) should appear here})
24
32
  end
25
- it "should turn email addresses into mailto links" do
26
- mods_display_abstract(@email).to_html.should match(/A link to an email address <a href='mailto:jdoe@example.com'>jdoe@example.com<\/a> should appear here/)
33
+ it 'should turn email addresses into mailto links' do
34
+ expect(mods_display_abstract(@email).to_html).to match(
35
+ %r{A link to an email address <a href='mailto:jdoe@example.com'>jdoe@example.com</a> should appear here}
36
+ )
27
37
  end
28
38
  end
29
- end
39
+ end
@@ -1,91 +1,116 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  def mods_display_access_condition(mods_record)
4
- ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new, double("controller"))
4
+ ModsDisplay::AccessCondition.new(
5
+ mods_record,
6
+ ModsDisplay::Configuration::AccessCondition.new,
7
+ double('controller')
8
+ )
5
9
  end
10
+
6
11
  def mods_display_versioned_access_condition(mods_record, version)
7
- ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{cc_license_version version}, double("controller"))
12
+ ModsDisplay::AccessCondition.new(
13
+ mods_record,
14
+ ModsDisplay::Configuration::AccessCondition.new { cc_license_version version },
15
+ double('controller')
16
+ )
8
17
  end
18
+
9
19
  def mods_display_non_ignore_access_condition(mods_record)
10
- ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{display!}, double("controller"))
20
+ ModsDisplay::AccessCondition.new(
21
+ mods_record,
22
+ ModsDisplay::Configuration::AccessCondition.new { display! },
23
+ double('controller')
24
+ )
11
25
  end
12
26
 
13
27
  describe ModsDisplay::AccessCondition do
28
+ include AccessConditionFixtures
14
29
  before :all do
15
- @access_condition = Stanford::Mods::Record.new.from_str("<mods><accessCondition>Access Condition Note</accessCondition></mods>", false).accessCondition
16
- @restrict_condition = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='restrictionOnAccess'>Restrict Access Note1</accessCondition><accessCondition type='restriction on access'>Restrict Access Note2</accessCondition></mods>", false).accessCondition
17
- @copyright_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='copyright'>This is a (c) copyright Note. Single instances of (c) should also be replaced in these notes.</accessCondition></mods>", false).accessCondition
18
- @cc_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>CC by-sa: This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License</accessCondition></mods>", false).accessCondition
19
- @odc_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>ODC pddl: This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)</accessCondition></mods>", false).accessCondition
20
- @no_link_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>Unknown something: This work is licensed under an Unknown License and will not be linked</accessCondition></mods>", false).accessCondition
30
+ @access_condition = Stanford::Mods::Record.new.from_str(simple_access_condition_fixture, false).accessCondition
31
+ @restrict_condition = Stanford::Mods::Record.new.from_str(restricted_access_fixture, false).accessCondition
32
+ @copyright_note = Stanford::Mods::Record.new.from_str(copyright_access_fixture, false).accessCondition
33
+ @cc_license_note = Stanford::Mods::Record.new.from_str(cc_license_fixture, false).accessCondition
34
+ @odc_license_note = Stanford::Mods::Record.new.from_str(odc_license_fixture, false).accessCondition
35
+ @no_link_license_note = Stanford::Mods::Record.new.from_str(no_license_fixture, false).accessCondition
21
36
  end
22
- describe "labels" do
23
- it "should normalize types and assign proper labels" do
37
+ describe 'labels' do
38
+ it 'should normalize types and assign proper labels' do
24
39
  fields = mods_display_access_condition(@restrict_condition).fields
25
- fields.length.should == 1
26
- fields.first.label.should == "Restriction on access:"
40
+ expect(fields.length).to eq(1)
41
+ expect(fields.first.label).to eq('Restriction on access:')
27
42
  fields.first.values.each_with_index do |value, index|
28
- value.should match /^Restrict Access Note#{index+1}/
43
+ expect(value).to match(/^Restrict Access Note#{index + 1}/)
29
44
  end
30
45
  end
31
46
  end
32
- describe "fields" do
33
- describe "copyright" do
47
+ describe 'fields' do
48
+ describe 'copyright' do
34
49
  it "should replace instances of '(c) copyright' with the HTML copyright entity" do
35
50
  fields = mods_display_access_condition(@copyright_note).fields
36
- fields.length.should == 1
37
- fields.first.values.length.should == 1
38
- fields.first.values.first.should == "This is a &copy; Note. Single instances of &copy; should also be replaced in these notes."
51
+ expect(fields.length).to eq(1)
52
+ expect(fields.first.values.length).to eq(1)
53
+ expect(fields.first.values.first).to eq(
54
+ 'This is a &copy; Note. Single instances of &copy; should also be replaced in these notes.'
55
+ )
39
56
  end
40
57
  end
41
- describe "licenses" do
42
- it "should add the appropriate classes to the html around the license" do
58
+ describe 'licenses' do
59
+ it 'should add the appropriate classes to the html around the license' do
43
60
  fields = mods_display_access_condition(@no_link_license_note).fields
44
- fields.length.should == 1
45
- fields.first.values.length.should == 1
46
- fields.first.values.first.should match /^<div class='unknown-something'>.*<\/div>$/
61
+ expect(fields.length).to eq(1)
62
+ expect(fields.first.values.length).to eq(1)
63
+ expect(fields.first.values.first).to match(%r{^<div class='unknown-something'>.*</div>$})
47
64
  end
48
- it "should itentify and link CreativeCommons licenses properly" do
65
+ it 'should itentify and link CreativeCommons licenses properly' do
49
66
  fields = mods_display_access_condition(@cc_license_note).fields
50
- fields.length.should == 1
51
- fields.first.values.length.should == 1
52
- fields.first.values.first.should include("<a href='http://creativecommons.org/licenses/by-sa/3.0/'>This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License</a>")
67
+ expect(fields.length).to eq(1)
68
+ expect(fields.first.values.length).to eq(1)
69
+ expect(fields.first.values.first).to include("<a href='http://creativecommons.org/licenses/by-sa/3.0/'>")
70
+ expect(fields.first.values.first).to include(
71
+ 'This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License'
72
+ )
53
73
  end
54
- it "should itentify and link OpenDataCommons licenses properly" do
74
+ it 'should itentify and link OpenDataCommons licenses properly' do
55
75
  fields = mods_display_access_condition(@odc_license_note).fields
56
- fields.length.should == 1
57
- fields.first.values.length.should == 1
58
- fields.first.values.first.should include("<a href='http://opendatacommons.org/licenses/pddl'>This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)</a>")
76
+ expect(fields.length).to eq(1)
77
+ expect(fields.first.values.length).to eq(1)
78
+ expect(fields.first.values.first).to include("<a href='http://opendatacommons.org/licenses/pddl'>")
79
+ expect(fields.first.values.first).to include(
80
+ 'This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)'
81
+ )
59
82
  end
60
- it "should have a configurable version for CC licenses" do
61
- fields = mods_display_versioned_access_condition(@cc_license_note, "4.0").fields
62
- fields.length.should == 1
63
- fields.first.values.length.should == 1
64
- fields.first.values.first.should include("http://creativecommons.org/licenses/by-sa/4.0/")
65
- fields.first.values.first.should_not include("http://creativecommons.org/licenses/by-sa/3.0/")
83
+ it 'should have a configurable version for CC licenses' do
84
+ fields = mods_display_versioned_access_condition(@cc_license_note, '4.0').fields
85
+ expect(fields.length).to eq(1)
86
+ expect(fields.first.values.length).to eq(1)
87
+ expect(fields.first.values.first).to include('http://creativecommons.org/licenses/by-sa/4.0/')
88
+ expect(fields.first.values.first).not_to include('http://creativecommons.org/licenses/by-sa/3.0/')
66
89
  end
67
- it "should not apply configured version to NON-CC licenses" do
68
- fields = mods_display_versioned_access_condition(@odc_license_note, "4.0").fields
69
- fields.length.should == 1
70
- fields.first.values.length.should == 1
71
- fields.first.values.first.should_not include("/4.0/")
90
+ it 'should not apply configured version to NON-CC licenses' do
91
+ fields = mods_display_versioned_access_condition(@odc_license_note, '4.0').fields
92
+ expect(fields.length).to eq(1)
93
+ expect(fields.first.values.length).to eq(1)
94
+ expect(fields.first.values.first).not_to include('/4.0/')
72
95
  end
73
- it "should not attempt unknown license types" do
96
+ it 'should not attempt unknown license types' do
74
97
  fields = mods_display_access_condition(@no_link_license_note).fields
75
- fields.length.should == 1
76
- fields.first.values.length.should == 1
77
- fields.first.values.first.should include("This work is licensed under an Unknown License and will not be linked")
78
- fields.first.values.first.should_not include("<a.*>")
98
+ expect(fields.length).to eq(1)
99
+ expect(fields.first.values.length).to eq(1)
100
+ expect(fields.first.values.first).to include(
101
+ 'This work is licensed under an Unknown License and will not be linked'
102
+ )
103
+ expect(fields.first.values.first).not_to include('<a.*>')
79
104
  end
80
105
  end
81
106
  end
82
- describe "to_html" do
83
- it "should ignore access conditions by default" do
84
- mods_display_access_condition(@access_condition).to_html.should be_nil
107
+ describe 'to_html' do
108
+ it 'should ignore access conditions by default' do
109
+ expect(mods_display_access_condition(@access_condition).to_html).to be_nil
85
110
  end
86
- it "should not ignore the access condition when ignore is set to false" do
111
+ it 'should not ignore the access condition when ignore is set to false' do
87
112
  html = mods_display_non_ignore_access_condition(@access_condition).to_html
88
- html.should match /<dt.*>Access condition:<\/dt><dd>Access Condition Note<\/dd>/
113
+ expect(html).to match %r{<dt.*>Access condition:</dt><dd>Access Condition Note</dd>}
89
114
  end
90
115
  end
91
- end
116
+ end
@@ -1,21 +1,24 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  def mods_display_audience(mods_record)
4
- ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
4
+ ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
5
5
  end
6
6
 
7
7
  describe ModsDisplay::Contents do
8
8
  before(:all) do
9
- @audience = Stanford::Mods::Record.new.from_str("<mods><targetAudience>Audience Note</targetAudience></mods>", false).targetAudience
10
- @display_label = Stanford::Mods::Record.new.from_str("<mods><targetAudience displayLabel='Special Label'>Audience Note</tableOfContents></mods>", false).targetAudience
9
+ @audience = Stanford::Mods::Record.new.from_str(
10
+ '<mods><targetAudience>Audience Note</targetAudience></mods>', false
11
+ ).targetAudience
12
+ @display_label = Stanford::Mods::Record.new.from_str(
13
+ "<mods><targetAudience displayLabel='Special Label'>Audience Note</tableOfContents></mods>", false
14
+ ).targetAudience
11
15
  end
12
- describe "label" do
13
- it "should have a default label" do
14
- mods_display_audience(@audience).label.should == "Target audience:"
16
+ describe 'label' do
17
+ it 'should have a default label' do
18
+ expect(mods_display_audience(@audience).label).to eq('Target audience:')
15
19
  end
16
- it "should use the displayLabel attribute when one is available" do
17
- mods_display_audience(@display_label).label.should == "Special Label:"
20
+ it 'should use the displayLabel attribute when one is available' do
21
+ expect(mods_display_audience(@display_label).label).to eq('Special Label:')
18
22
  end
19
- end
20
-
21
- end
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
- require "spec_helper"
2
- require "fixtures/cartographics_fixtures"
1
+ require 'spec_helper'
2
+ require 'fixtures/cartographics_fixtures'
3
3
  include CartographicsFixtures
4
4
 
5
5
  def mods_display_cartographics(mods)
6
- ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new, double("controller"))
6
+ ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new, double('controller'))
7
7
  end
8
8
 
9
9
  describe ModsDisplay::Cartographics do
@@ -13,27 +13,26 @@ describe ModsDisplay::Cartographics do
13
13
  @no_scale = Stanford::Mods::Record.new.from_str(no_scale_cartographic, false).subject
14
14
  @coordinates = Stanford::Mods::Record.new.from_str(coordinates_only, false).subject
15
15
  end
16
- describe "values" do
17
- it "should get the full cartographic note" do
16
+ describe 'values' do
17
+ it 'should get the full cartographic note' do
18
18
  values = mods_display_cartographics(@cart).fields
19
- values.length.should == 1
20
- values.first.values.should == ["The scale ; the projection the coordinates"]
19
+ expect(values.length).to eq(1)
20
+ expect(values.first.values).to eq(['The scale ; the projection the coordinates'])
21
21
  end
22
- it "should put a scale not given note if no scale is present" do
22
+ it 'should put a scale not given note if no scale is present' do
23
23
  values = mods_display_cartographics(@no_scale).fields
24
- values.length.should == 1
25
- values.first.values.should == ["Scale not given ; the projection the coordinates"]
24
+ expect(values.length).to eq(1)
25
+ expect(values.first.values).to eq(['Scale not given ; the projection the coordinates'])
26
26
  end
27
- it "should handle when there is only a scale note" do
27
+ it 'should handle when there is only a scale note' do
28
28
  values = mods_display_cartographics(@scale_only).fields
29
- values.length.should == 1
30
- values.first.values.should == ["The scale"]
29
+ expect(values.length).to eq(1)
30
+ expect(values.first.values).to eq(['The scale'])
31
31
  end
32
- it "should handle when only one post-scale piece of the data is available" do
32
+ it 'should handle when only one post-scale piece of the data is available' do
33
33
  values = mods_display_cartographics(@coordinates).fields
34
- values.length.should == 1
35
- values.first.values.should == ["Scale not given ; the coordinates"]
34
+ expect(values.length).to eq(1)
35
+ expect(values.first.values).to eq(['Scale not given ; the coordinates'])
36
36
  end
37
37
  end
38
-
39
- end
38
+ end
@@ -1,31 +1,77 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  def mods_display_collection(mods_record)
4
- ModsDisplay::Collection.new(mods_record, ModsDisplay::Configuration::Base.new, double("controller"))
4
+ ModsDisplay::Collection.new(
5
+ mods_record,
6
+ ModsDisplay::Configuration::Base.new,
7
+ double('controller')
8
+ )
5
9
  end
6
10
 
7
11
  describe ModsDisplay::Collection do
8
- before(:all) do
9
- @collection = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title>The Collection</title></titleInfo><typeOfResource collection='yes' /></relatedItem></mods>", false).related_item
10
- @non_collection = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title>Not a Collection</title></titleInfo></relatedItem></mods>", false).related_item
11
- @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
12
+ let(:collection) do
13
+ Stanford::Mods::Record.new.from_str(
14
+ '<mods>
15
+ <relatedItem>
16
+ <titleInfo><title>The Collection</title></titleInfo><typeOfResource collection="yes" />
17
+ </relatedItem>
18
+ </mods>',
19
+ false
20
+ ).related_item
12
21
  end
13
- describe "label" do
14
- it "should default to Collection" do
15
- mods_display_collection(@collection).label.should == "Collection:"
22
+ let(:non_collection) do
23
+ Stanford::Mods::Record.new.from_str(
24
+ '<mods><relatedItem><titleInfo><title>Not a Collection</title></titleInfo></relatedItem></mods>',
25
+ false
26
+ ).related_item
27
+ end
28
+ let(:display_label) do
29
+ Stanford::Mods::Record.new.from_str(
30
+ '<mods>
31
+ <relatedItem displayLabel="Special Collection">
32
+ <titleInfo><title>Not a Collection</title></titleInfo>
33
+ </relatedItem>
34
+ </mods>',
35
+ false
36
+ ).related_item
37
+ end
38
+ let(:multiple_related_items) do
39
+ Stanford::Mods::Record.new.from_str(
40
+ '<mods>
41
+ <relatedItem displayLabel="Special Collection">
42
+ <titleInfo><title>Not a Collection</title></titleInfo>
43
+ </relatedItem>
44
+ <relatedItem>
45
+ <titleInfo><title>The Collection</title></titleInfo><typeOfResource collection="yes" />
46
+ </relatedItem>
47
+ </mods>',
48
+ false
49
+ ).related_item
50
+ end
51
+
52
+ describe 'label' do
53
+ it 'should default to Collection' do
54
+ expect(mods_display_collection(collection).fields.first.label).to eq('Collection:')
55
+ end
56
+
57
+ it 'should get the displayLabel if available' do
58
+ expect(mods_display_collection(display_label).label).to eq('Special Collection:')
16
59
  end
17
- it "should get the displayLabel if available" do
18
- mods_display_collection(@display_label).label.should == "Special Collection:"
60
+
61
+ it 'should get the proper titles of all items when there is a displayLabel present' do
62
+ expect(mods_display_collection(multiple_related_items).fields.first.label).to eq 'Collection:'
19
63
  end
20
64
  end
21
- describe "fields" do
22
- it "should get a collection title if there is an appropriate typeOfResource field with the collection attribute" do
23
- fields = mods_display_collection(@collection).fields
24
- fields.length.should == 1
25
- fields.first.values.should == ["The Collection"]
65
+
66
+ describe 'fields' do
67
+ it 'should get a collection title if there is an appropriate typeOfResource field with the collection attribute' do
68
+ fields = mods_display_collection(collection).fields
69
+ expect(fields.length).to eq(1)
70
+ expect(fields.first.values).to eq(['The Collection'])
26
71
  end
27
- it "should not return anything if the there is not an appropriate typeOfResource field with the collection attribute" do
28
- mods_display_collection(@non_collection).fields.should == []
72
+
73
+ it 'should be blank if the there is not an appropriate typeOfResource field with the collection attribute' do
74
+ expect(mods_display_collection(non_collection).fields).to eq([])
29
75
  end
30
76
  end
31
- end
77
+ end