# encoding: UTF-8
require 'spec_helper'
describe "Format field from Searchworks mixin for Stanford::Mods::Record" do
before(:all) do
@smods_rec = Stanford::Mods::Record.new
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
end
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
it "Journal/Periodical: typeOfResource 'text', 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 "Image: typeOfResource 'still image'" do
m = "still image"
@smods_rec.from_str(m)
expect(@smods_rec.format).to eq ['Image']
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