# encoding: UTF-8
require 'spec_helper'
describe "Format fields (searchworks.rb)" do
before(:all) do
@smods_rec = Stanford::Mods::Record.new
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
end
context "format" do
context "Book:" do
context "typeOfResource text," do
it 'originInfo/issuance monographic' do
m = "textmonographic"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
context "genre" do
it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "book chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Book chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Book Chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "issue brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Issue brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Issue Brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
it "'librettos'", :jira => 'INDEX-98' do
m = "librettostext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Librettostext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
it "'libretto' isn't valid", :jira => 'INDEX-98' do
m = "librettotext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq []
end
it "'project report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
m = "project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Project Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
it "'report' isn't valid", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
m = "reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq []
end
it "'technical report'", :jira => 'GRYPHONDOR-207' do
m = "technical reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Technical reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Technical Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "working papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Working papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
m = "Working Papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
end
end
end # 'Book'
context "Computer File: typeOfResource 'software, multimedia'" do
it "no genre (e.g. Dataset)" do
m = "software, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Computer File']
end
it "genre 'game'", :jira => 'GRYPHONDOR-207' do
m = "gamesoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Computer File']
m = "Gamesoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Computer File']
end
end
it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", :jira => 'GRYPHONDOR-207' do
m = "conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Conference Proceedings']
m = "Conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Conference Proceedings']
m = "Conference Publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Conference Proceedings']
end
context "Journal/Periodical: typeOfResource 'text'," do
it "genre 'article" do
m = "textarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Journal/Periodical']
m = "textArticle"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Journal/Periodical']
end
it "originInfo/issuance 'continuing'" do
m = "textcontinuing"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Journal/Periodical']
end
end
it "Image: typeOfResource 'still image'" do
m = "still image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Image']
end
it "Manuscript/Archive: typeOfResource 'mixed material'" do
m = "mixed material"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Manuscript/Archive']
end
it "Map/Globe: typeOfResource 'cartographic'" do
m = "cartographic"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Map/Globe']
end
it "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
m = "sound recording-musical"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Music - Recording']
end
it "Music - Score: typeOfResource 'notated music'" do
m = "notated music"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Music - Score']
end
it "Other: typeOfResource 'text', genre 'student project report'", :email => 'from Vitus, August 16, 2013' do
m = "student project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Other']
m = "Student project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Other']
m = "Student Project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Other']
m = "Student Project Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Other']
end
context "Sound Recording:" do
it "typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
m = "soundsound recording-nonmusical"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Sound Recording']
m = "Soundsound recording-nonmusical"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Sound Recording']
end
it "typeOfResource 'sound recording', genre 'sound", :jira => 'INDEX-94' do
m = "soundsound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Sound Recording']
m = "Soundsound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Sound Recording']
end
end
it "Thesis: typeOfResource 'text', genre 'thesis'" do
m = "textthesis"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Thesis']
m = "textThesis"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Thesis']
end
context "Video: typeOfResource 'moving image'" do
it "no genre" do
m = "moving image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Video']
end
it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
m = "motion picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Video']
m = "Motion Picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Video']
m = "Motion Picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Video']
end
end
context "multiple format values", :jira => 'INDEX-32' do
it "multiple typeOfResource elements" do
m = "moving imagesound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Video', 'Sound Recording']
end
it "multiple genre elements, single typeOfResource" do
m = "textlibrettosarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical']
end
it "mish mash" do
m = "textstill imagelibrettosarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical', 'Image']
end
it "doesn't give duplicate values" do
m = "textlibrettosissue brief"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Book']
end
end
it "empty Array if no typeOfResource field" do
m = "
1904
"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq []
end
it "empty Array if weird typeOfResource value" do
m = "
foo
"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq []
end
end # format
context "format_main" do
it "3D object: typeOfResource 'three dimensional object'" do
m = "three dimensional object"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Object']
end
it "Archive/Manuscript: typeOfResource 'mixed material'" do
m = "mixed material"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Archive/Manuscript']
end
context "Article: typeOfResource text, genre" do
it "'article'" do
m = "textarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "textArticle"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "book chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Book chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Book Chaptertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "issue brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Issue brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Issue Brieftext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'project report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
m = "project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Project Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'report' isn't valid", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
m = "reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq []
end
it "'student project report'", :consul => '/NGDE/Format 2014-05-28' do
m = "student project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Student project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Student Project reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Student Project Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'technical report'", :jira => 'GRYPHONDOR-207' do
m = "technical reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Technical reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Technical Reporttext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
m = "working papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Working papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
m = "Working Papertext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article']
end
end # Article
context "Book" do
context "typeOfResource text," do
it 'originInfo/issuance monographic' do
m = "textmonographic"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
context "genre" do
it "'conference publication'", :jira => 'GRYPHONDOR-207' do
m = "conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
m = "Conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
m = "Conference Publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
it "'instruction'", :consul => '/NGDE/Format 2014-05-28' do
# Hydrus 'textbook'
m = "instructiontext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
m = "Instructiontext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
it "'libretto' isn't valid", :jira => 'INDEX-98' do
m = "librettotext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq []
end
it "'librettos'", :jira => 'INDEX-98' do
m = "librettostext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
m = "Librettostext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
it "'thesis'" do
m = "thesistext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
m = "Thesistext"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
end
end
end # Book
context "Dataset: typeOfResource 'software, multimedia'" do
it "genre 'dataset'" do
m = "datasetsoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Dataset']
m = "Datasetsoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Dataset']
end
end
it "Image: typeOfResource 'still image'" do
m = "still image"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Image']
end
it "Journal/Periodical: typeOfResource 'text', originInfo/issuance 'continuing'" do
m = "textcontinuing"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Journal/Periodical']
end
it "Map: typeOfResource 'cartographic'" do
m = "cartographic"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Map']
end
context "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
it "no genre" do
m = "sound recording-musical"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Music recording']
end
it "genre 'sound'" do
m = "sound recording-musicalsound"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Music recording']
m = "sound recording-musicalSound"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Music recording']
end
end
it "Music - Score: typeOfResource 'notated music'" do
m = "notated music"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Music score']
end
context "Software/Multimedia: typeOfResource 'software, multimedia'" do
it "no genre" do
m = "software, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Software/Multimedia']
end
it "genre 'game'", :jira => 'GRYPHONDOR-207' do
m = "gamesoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Software/Multimedia']
m = "Gamesoftware, multimedia"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Software/Multimedia']
end
end
context "Sound Recording:" do
it "typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
m = "soundsound recording-nonmusical"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Sound recording']
m = "Soundsound recording-nonmusical"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Sound recording']
end
it "typeOfResource 'sound recording', genre 'sound", :jira => 'INDEX-94' do
m = "soundsound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Sound recording']
m = "Soundsound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Sound recording']
end
end
context "Video: typeOfResource 'moving image'" do
it "no genre" do
m = "moving image"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Video']
end
it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
m = "motion picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Video']
m = "Motion picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Video']
m = "Motion Picturemoving image"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Video']
end
end
context "multiple values", :jira => 'INDEX-32' do
it "multiple typeOfResource elements" do
m = "moving imagesound recording"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Video', 'Sound recording']
end
it "multiple genre elements, single typeOfResource" do
m = "textlibrettosarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article', 'Book']
end
it "mish mash" do
m = "textstill imagelibrettosarticle"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Article', 'Book', 'Image']
end
it "doesn't give duplicate values" do
m = "textlibrettosthesis"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq ['Book']
end
end
it "empty Array if no typeOfResource field" do
m = "
1904
"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq []
end
it "empty Array if weird typeOfResource value" do
m = "
foo
"
@smods_rec.from_str(m)
expect(@smods_rec.format_main).to eq []
end
end #format_main
context "sw_genre" do
it "Conference proceedings: typeOfResource 'text', genre 'conference publication'" do
m = "conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
m = "Conference publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
m = "Conference Publicationtext"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
end
it "Thesis/Dissertation: typeOfResource 'text', genre 'thesis'" do
m = "thesistext"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
m = "Thesistext"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
end
it "capitalizes the first letter of a genre value" do
m = "student project report"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Student project report']
m = "Student project report"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Student project report']
m = "Student Project report"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Student project report']
m = "Student Project Report"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Student project report']
end
# NOTE: may need to remove plurals and/or trailing punctuation in future
it "returns all genre values" do
m = "
game
foo
technical report
"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Game', 'Foo', 'Technical report']
end
it "doesn't have duplicates" do
m = "
game
technical report
Game
"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq ['Game', 'Technical report']
end
it "empty Array if no genre values" do
m = "
text
"
@smods_rec.from_str(m)
expect(@smods_rec.sw_genre).to eq []
end
end # sw_genre
end