# encoding: UTF-8 describe "Format fields (searchworks.rb)" do before(:all) do @smods_rec = Stanford::Mods::Record.new @ns_decl = "xmlns='#{Mods::MODS_NS}'" end 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 it "Archived website: typeOfResource text, genre 'archived website'" do m = "textarchived website" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Archived website'] end context "Book, formerly Article: typeOfResource text, genre" do it "'article'" do m = "textarticle" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "textArticle" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] 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 ['Book'] m = "Book chaptertext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Book Chaptertext" @smods_rec.from_str(m) expect(@smods_rec.format_main).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_main).to eq ['Book'] m = "Issue brieftext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Issue Brieftext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] 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 ['Book'] m = "Project reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Project Reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] end it "'report' isn't valid, so defaults to book", jira: 'GRYP-170', github: 'gdor-indexer/#7' do m = "reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] 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 ['Book'] m = "Student project reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Student Project reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Student Project Reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] end it "'technical report'", jira: 'GRYPHONDOR-207' do m = "technical reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Technical reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Technical Reporttext" @smods_rec.from_str(m) expect(@smods_rec.format_main).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_main).to eq ['Book'] m = "Working papertext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] m = "Working Papertext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] 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, so it defaults to book", jira: 'INDEX-98' do m = "librettotext" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Book'] 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 # https://github.com/sul-dlss/stanford-mods/issues/66 - For geodata, the # resource type should be only Map and not include Software, multimedia. it "typeOfResource 'cartographic' and 'software, multimedia'" do m = "cartographicsoftware, multimedia" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['Map'] 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 ['Book'] end it "mish mash" do m = "textstill imagelibrettosarticle" @smods_rec.from_str(m) expect(@smods_rec.format_main).to eq ['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 "includes values that are not in the prescribed list" do m = "Not on the listtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Not on the list'] end 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 publication', 'Conference proceedings'] m = "Conference publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Conference publication', 'Conference proceedings'] m = "Conference Publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Conference Publication', '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', 'Thesis/Dissertation'] m = "Thesistext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Thesis', 'Thesis/Dissertation'] end it "Government Document: typeOfResource 'text', genre 'government publication'" do m = "government publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document'] m = "Government publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Government publication', 'Government document'] m = "Government Publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Government Publication', 'Government document'] m = "government publicationtext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['government publication', 'Government document'] end it "Technical Report: typeOfResource 'text', genre 'technical report'" do m = "technical reporttext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report'] m = "Technical reporttext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Technical report'] m = "Technical Reporttext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report'] m = "technical reporttext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report'] end it "it does not include Archived website: typeOfResource 'text', genre 'archived website'" do m = "archived websitetext" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).not_to eq ['Archived website'] end it "capitalizes the first letter of a genre value" do m = "texttechnical report" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['technical report', 'Technical report'] m = "textTechnical report" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Technical report'] m = "textTechnical Report" @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['Technical Report', 'Technical report'] end # NOTE: may need to remove plurals and/or trailing punctuation in future it "returns all genre values" do m = " text government publication conference publication thesis " @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['government publication', 'conference publication', 'thesis', 'Thesis/Dissertation', 'Conference proceedings', 'Government document'] end it "doesn't have duplicates" do m = " text conference publication technical report Conference publication " @smods_rec.from_str(m) expect(@smods_rec.sw_genre).to eq ['conference publication', 'technical report', 'Conference publication', 'Conference proceedings', '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