From 29ffd8983bd6c6b41f305de02b6be39cd5fb9ac2 Mon Sep 17 00:00:00 2001 From: Steven Anderson Date: Fri, 27 Jun 2014 10:47:15 -0400 Subject: [PATCH] Added LCMPT and AFSET sub-vocabularies to LOC Added LCMPT and AFSET sub-vocabularies to the Library of Congress vocabulary. In addition, fixed a slight name misspelling on the README. --- README.md | 2 +- lib/qa/authorities/loc.rb | 2 + spec/fixtures/loc-response.txt | 1538 +++++++++++++++++++++++++++++- spec/lib/authorities_loc_spec.rb | 250 +++-- 4 files changed, 1718 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index c4402b68..474394f1 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ For help with Questioning Authority, contact . # Original Authors -* [Stephen Anderson](https://github.com/scande3) +* [Steven Anderson](https://github.com/scande3) * [Don Brower](https://github.com/dbrower) * [Jim Coble](https://github.com/coblej) * [Mike Durbin](https://github.com/mikedurbin) diff --git a/lib/qa/authorities/loc.rb b/lib/qa/authorities/loc.rb index b93c0815..156bbc12 100644 --- a/lib/qa/authorities/loc.rb +++ b/lib/qa/authorities/loc.rb @@ -36,10 +36,12 @@ def self.sub_authority_table 'classification' => authority_base_url, 'childrensSubjects' => authority_base_url, 'genreForms' => authority_base_url, + 'performanceMediums' => authority_base_url, 'graphicMaterials' => vocab_base_url, 'organizations' => vocab_base_url, 'relators' => vocab_base_url, 'countries' => vocab_base_url, + 'ethnographicTerms' => vocab_base_url, 'geographicAreas' => vocab_base_url, 'languages' => vocab_base_url, 'iso639-1' => vocab_base_url, diff --git a/spec/fixtures/loc-response.txt b/spec/fixtures/loc-response.txt index 9c4e7d2d..1d0087e6 100644 --- a/spec/fixtures/loc-response.txt +++ b/spec/fixtures/loc-response.txt @@ -1,3 +1,4 @@ + [ "atom:feed", { @@ -16,10 +17,19 @@ "atom:link", { "xmlns:atom" : "http://www.w3.org/2005/Atom", - "href" : "http://id.loc.gov/search/?q=haw* cs:http://id.loc.gov/vocabulary/geographicAreas&start=1&format=atom", + "href" : "http://id.loc.gov/search/?q=s* cs:http://id.loc.gov/vocabulary/geographicAreas&start=1&format=atom", "rel" : "self" } + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "href" : "http://id.loc.gov/search/?q=s* cs:http://id.loc.gov/vocabulary/geographicAreas&start=21&format=atom", + "rel" : "next" + } + ], [ "atom:id", @@ -27,7 +37,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "info:lc/search/?q=haw*+cs:http://id.loc.gov/vocabulary/geographicAreas" + "info:lc/search/?q=s*+cs:http://id.loc.gov/vocabulary/geographicAreas" ], [ "atom:updated", @@ -35,7 +45,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "2013-09-18T23:04:54.726545-04:00" + "2014-06-27T12:59:38.190383-04:00" ], [ "opensearch:totalResults", @@ -43,7 +53,7 @@ "xmlns:opensearch" : "http://a9.com/-/spec/opensearch/1.1/" } , - "2" + "534" ], [ "opensearch:startIndex", @@ -73,14 +83,263 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "Haw, Lily, 1890?-1915" + "West (U.S.)" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usp" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usp.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usp.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/n-usp" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Belarus" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-bw" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-bw.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-bw.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/e-bw" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Russia (Federation)" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ru" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ru.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ru.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/e-ru" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Kazakhstan" ], [ "atom:link", { "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", - "href" : "http://id.loc.gov/authorities/names/n2008008718" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kz" } ], @@ -90,7 +349,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", "type" : "application/rdf+xml", - "href" : "http://id.loc.gov/authorities/names/n2008008718.rdf" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kz.rdf" } ], @@ -100,7 +359,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", "type" : "application/json", - "href" : "http://id.loc.gov/authorities/names/n2008008718.json" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kz.json" } ], @@ -110,7 +369,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "info:lc/authorities/names/n2008008718" + "info:lc/vocabulary/geographicAreas/a-kz" ], [ "atom:author", @@ -133,7 +392,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "2008-03-05T00:00:00-04:00" + "1970-01-01T00:00:00-04:00" ], [ "dcterms:created", @@ -141,10 +400,10 @@ "xmlns:dcterms" : "http://purl.org/dc/terms/" } , - "2008-02-05T00:00:00-04:00" + "1970-01-01T00:00:00-04:00" ] ], - [ + [ "atom:entry", { "xmlns:atom" : "http://www.w3.org/2005/Atom" @@ -156,14 +415,14 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "Hawaii" + "Kyrgyzstan" ], [ "atom:link", { "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", - "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-us-hi" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kg" } ], @@ -173,7 +432,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", "type" : "application/rdf+xml", - "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-us-hi.rdf" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kg.rdf" } ], @@ -183,7 +442,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom", "rel" : "alternate", "type" : "application/json", - "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-us-hi.json" + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-kg.json" } ], @@ -193,7 +452,7 @@ "xmlns:atom" : "http://www.w3.org/2005/Atom" } , - "info:lc/vocabulary/geographicAreas/n-us-hi" + "info:lc/vocabulary/geographicAreas/a-kg" ], [ "atom:author", @@ -226,5 +485,1250 @@ , "1970-01-01T00:00:00-04:00" ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Soviet Union" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ur" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ur.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-ur.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/e-ur" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Moldova" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-mv" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-mv.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/e-mv.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/e-mv" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Tajikistan" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ta" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ta.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ta.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-ta" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Azerbaijan" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-aj" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-aj.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-aj.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-aj" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Uzbekistan" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-uz" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-uz.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-uz.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-uz" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Turkmenistan" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-tk" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-tk.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-tk.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-tk" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Armenia (Republic)" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ai" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ai.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-ai.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-ai" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Georgia (Republic)" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-gs" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-gs.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/a-gs.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/a-gs" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "East (U.S.)" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usr" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usr.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-usr.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/n-usr" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Northeastern States" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-use" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-use.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-use.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/n-use" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Algeria" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-ae" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-ae.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-ae.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/f-ae" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Saskatchewan" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-cn-sn" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-cn-sn.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/n-cn-sn.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/n-cn-sn" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "South Asia" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/az" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/az.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/az.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/az" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Spanish North Africa" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-sh" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-sh.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/f-sh.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/f-sh" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" + ] + ], + [ + "atom:entry", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:title", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Baltic States" + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/eb" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/rdf+xml", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/eb.rdf" + } + + ], + [ + "atom:link", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom", + "rel" : "alternate", + "type" : "application/json", + "href" : "http://id.loc.gov/vocabulary/geographicAreas/eb.json" + } + + ], + [ + "atom:id", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "info:lc/vocabulary/geographicAreas/eb" + ], + [ + "atom:author", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + [ + "atom:name", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "Library of Congress" + ] + ], + [ + "atom:updated", + { + "xmlns:atom" : "http://www.w3.org/2005/Atom" + } + , + "1970-01-01T00:00:00-04:00" + ], + [ + "dcterms:created", + { + "xmlns:dcterms" : "http://purl.org/dc/terms/" + } + , + "1970-01-01T00:00:00-04:00" ] ] + ] \ No newline at end of file diff --git a/spec/lib/authorities_loc_spec.rb b/spec/lib/authorities_loc_spec.rb index 6bc7df55..03f9220d 100644 --- a/spec/lib/authorities_loc_spec.rb +++ b/spec/lib/authorities_loc_spec.rb @@ -3,89 +3,227 @@ describe Qa::Authorities::Loc do before :all do - stub_request(:get, "http://id.loc.gov/search/?format=json&q=haw*&q=cs:http://id.loc.gov/vocabulary/geographicAreas"). - with(:headers => {'Accept'=>'application/json'}). - to_return(:body => webmock_fixture("loc-response.txt"), :status => 200) @authority = Qa::Authorities::Loc.new - @authority.search("haw*", "geographicAreas") end - describe "geographic areas" do - - it "should instantiate with a query and return data" do - expect(@authority).not_to be_nil - @authority.raw_response.to_s.should include("id") - end - - it "should return a sub_authority url" do + describe "verify_configured_sub_authorities" do + before :all do + stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas"). + with(:headers => {'Accept'=>'application/json'}). + to_return(:body => webmock_fixture("loc-response.txt"), :status => 200) + + @authority.search("s", "geographicAreas") + end + + it "should detect invalid authorities" do @authority.should_not be_nil - url = @authority.sub_authorityURL("geographicAreas") - expect(url).not_to be_nil + Qa::Authorities::Loc.authority_valid?("invalid sub_authority").should == false end - + it "should not return a url for an invalid sub_authority" do - @authority.should_not be_nil url = @authority.sub_authorityURL("invalid sub_authority") expect(url).to eq("") end - - it "should return JSON" do + + it "should provide a url for a sub authority" do @authority.should_not be_nil - json = @authority.parse_authority_response(@authority.raw_response) - expect(json).not_to be_empty + url = @authority.sub_authorityURL("geographicAreas") + expect(url).not_to be_nil end - end + it "should detect valid sub authorities and provide correct urls" do + vocab_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F' + authority_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F' + datatype_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F' + vocab_preservation_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F' - describe "subject headings" do + Qa::Authorities::Loc.authority_valid?("subjects").should == true + @authority.sub_authorityURL("subjects").should == "#{authority_base_url}subjects" - before :all do - stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects"). - with(:headers => {'Accept'=>'application/json'}). - to_return(:body => webmock_fixture("loc-subjects-response.txt"), :status => 200) - end + Qa::Authorities::Loc.authority_valid?("names").should == true + @authority.sub_authorityURL("names").should == "#{authority_base_url}names" - it "should be retrieved via search" do - @authority.search("History--", "subjects") - @authority.results.first["label"].should == "History--Philosophy--History--20th century" - end + Qa::Authorities::Loc.authority_valid?("classification").should == true + @authority.sub_authorityURL("classification").should == "#{authority_base_url}classification" - end + Qa::Authorities::Loc.authority_valid?("childrensSubjects").should == true + @authority.sub_authorityURL("childrensSubjects").should == "#{authority_base_url}childrensSubjects" - describe "name headings" do + Qa::Authorities::Loc.authority_valid?("genreForms").should == true + @authority.sub_authorityURL("genreForms").should == "#{authority_base_url}genreForms" - before :all do - stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names"). - with(:headers => {'Accept'=>'application/json'}). - to_return(:body => webmock_fixture("loc-names-response.txt"), :status => 200) - end + Qa::Authorities::Loc.authority_valid?("performanceMediums").should == true + @authority.sub_authorityURL("performanceMediums").should == "#{authority_base_url}performanceMediums" + + Qa::Authorities::Loc.authority_valid?("edtf").should == true + @authority.sub_authorityURL("edtf").should == "#{datatype_base_url}edtf" + + Qa::Authorities::Loc.authority_valid?("organizations").should == true + @authority.sub_authorityURL("organizations").should == "#{vocab_base_url}organizations" + + Qa::Authorities::Loc.authority_valid?("relators").should == true + @authority.sub_authorityURL("relators").should == "#{vocab_base_url}relators" + + Qa::Authorities::Loc.authority_valid?("countries").should == true + @authority.sub_authorityURL("countries").should == "#{vocab_base_url}countries" + + Qa::Authorities::Loc.authority_valid?("ethnographicTerms").should == true + @authority.sub_authorityURL("ethnographicTerms").should == "#{vocab_base_url}ethnographicTerms" + + Qa::Authorities::Loc.authority_valid?("languages").should == true + @authority.sub_authorityURL("languages").should == "#{vocab_base_url}languages" + + Qa::Authorities::Loc.authority_valid?("iso639-1").should == true + @authority.sub_authorityURL("iso639-1").should == "#{vocab_base_url}iso639-1" + + Qa::Authorities::Loc.authority_valid?("iso639-2").should == true + @authority.sub_authorityURL("iso639-2").should == "#{vocab_base_url}iso639-2" + + Qa::Authorities::Loc.authority_valid?("iso639-5").should == true + @authority.sub_authorityURL("iso639-5").should == "#{vocab_base_url}iso639-5" + + Qa::Authorities::Loc.authority_valid?("actionsGranted").should == true + @authority.sub_authorityURL("actionsGranted").should == "#{vocab_base_url}actionsGranted" + + Qa::Authorities::Loc.authority_valid?("agentType").should == true + @authority.sub_authorityURL("agentType").should == "#{vocab_base_url}agentType" + + Qa::Authorities::Loc.authority_valid?("contentLocationType").should == true + @authority.sub_authorityURL("contentLocationType").should == "#{vocab_preservation_base_url}contentLocationType" + + Qa::Authorities::Loc.authority_valid?("copyrightStatus").should == true + @authority.sub_authorityURL("copyrightStatus").should == "#{vocab_preservation_base_url}copyrightStatus" - it "should be retrieved via search" do - @authority.search("Berry", "names") - @authority.results.first["label"].should == "Berry, James W. (James William), 1938-" + Qa::Authorities::Loc.authority_valid?("cryptographicHashFunctions").should == true + @authority.sub_authorityURL("cryptographicHashFunctions").should == "#{vocab_preservation_base_url}cryptographicHashFunctions" + + Qa::Authorities::Loc.authority_valid?("environmentCharacteristic").should == true + @authority.sub_authorityURL("environmentCharacteristic").should == "#{vocab_preservation_base_url}environmentCharacteristic" + + Qa::Authorities::Loc.authority_valid?("environmentPurpose").should == true + @authority.sub_authorityURL("environmentPurpose").should == "#{vocab_preservation_base_url}environmentPurpose" + + Qa::Authorities::Loc.authority_valid?("eventRelatedAgentRole").should == true + @authority.sub_authorityURL("eventRelatedAgentRole").should == "#{vocab_preservation_base_url}eventRelatedAgentRole" + + Qa::Authorities::Loc.authority_valid?("eventRelatedObjectRole").should == true + @authority.sub_authorityURL("eventRelatedObjectRole").should == "#{vocab_preservation_base_url}eventRelatedObjectRole" + + Qa::Authorities::Loc.authority_valid?("eventType").should == true + @authority.sub_authorityURL("eventType").should == "#{vocab_preservation_base_url}eventType" + + Qa::Authorities::Loc.authority_valid?("formatRegistryRole").should == true + @authority.sub_authorityURL("formatRegistryRole").should == "#{vocab_preservation_base_url}formatRegistryRole" + + Qa::Authorities::Loc.authority_valid?("hardwareType").should == true + @authority.sub_authorityURL("hardwareType").should == "#{vocab_preservation_base_url}hardwareType" + + Qa::Authorities::Loc.authority_valid?("inhibitorTarget").should == true + @authority.sub_authorityURL("inhibitorTarget").should == "#{vocab_preservation_base_url}inhibitorTarget" + + Qa::Authorities::Loc.authority_valid?("inhibitorType").should == true + @authority.sub_authorityURL("inhibitorType").should == "#{vocab_preservation_base_url}inhibitorType" + + Qa::Authorities::Loc.authority_valid?("objectCategory").should == true + @authority.sub_authorityURL("objectCategory").should == "#{vocab_preservation_base_url}objectCategory" + + Qa::Authorities::Loc.authority_valid?("preservationLevelRole").should == true + @authority.sub_authorityURL("preservationLevelRole").should == "#{vocab_preservation_base_url}preservationLevelRole" + + Qa::Authorities::Loc.authority_valid?("relationshipSubType").should == true + @authority.sub_authorityURL("relationshipSubType").should == "#{vocab_preservation_base_url}relationshipSubType" + + Qa::Authorities::Loc.authority_valid?("relationshipType").should == true + @authority.sub_authorityURL("relationshipType").should == "#{vocab_preservation_base_url}relationshipType" + + Qa::Authorities::Loc.authority_valid?("rightsBasis").should == true + @authority.sub_authorityURL("rightsBasis").should == "#{vocab_preservation_base_url}rightsBasis" + + Qa::Authorities::Loc.authority_valid?("rightsRelatedAgentRole").should == true + @authority.sub_authorityURL("rightsRelatedAgentRole").should == "#{vocab_preservation_base_url}rightsRelatedAgentRole" + + Qa::Authorities::Loc.authority_valid?("signatureEncoding").should == true + @authority.sub_authorityURL("signatureEncoding").should == "#{vocab_preservation_base_url}signatureEncoding" + + Qa::Authorities::Loc.authority_valid?("signatureMethod").should == true + @authority.sub_authorityURL("signatureMethod").should == "#{vocab_preservation_base_url}signatureMethod" + + Qa::Authorities::Loc.authority_valid?("softwareType").should == true + @authority.sub_authorityURL("softwareType").should == "#{vocab_preservation_base_url}softwareType" + + Qa::Authorities::Loc.authority_valid?("storageMedium").should == true + @authority.sub_authorityURL("storageMedium").should == "#{vocab_preservation_base_url}storageMedium" end - end - describe "#parse_authority_response" do - before :all do - stub_request(:get, "http://id.loc.gov/search/?format=json&q=h&q=cs:http://id.loc.gov/authorities/subjects"). - with(:headers => {'Accept'=>'application/json'}). - to_return(:body => webmock_fixture("loc-response.txt"), :status => 200) - @authority.search("h", "subjects") + + describe "canned_example_searches" do + + describe "geographic_search" do + before :all do + stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas"). + with(:headers => {'Accept'=>'application/json'}). + to_return(:body => webmock_fixture("loc-response.txt"), :status => 200) + + @authority.search("s", "geographicAreas") + end + + it "should instantiate with a query and return data" do + expect(@authority).not_to be_nil + @authority.raw_response.to_s.should include("id") + end + + it "should return JSON" do + @authority.should_not be_nil + json = @authority.parse_authority_response(@authority.raw_response) + expect(json).not_to be_empty + end + + it "should have certain returned elements" do + @authority.results.first["label"].should == "West (U.S.)" + @authority.results.first["id"].should == "info:lc/vocabulary/geographicAreas/n-usp" + @authority.results.last["label"].should == "Baltic States" + @authority.results.last["id"].should == "info:lc/vocabulary/geographicAreas/eb" + @authority.results.size.should == 20 + end + end - let(:parsed_response) { @authority.parse_authority_response(@authority.raw_response) } + describe "subject_search" do + before :all do + stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects"). + with(:headers => {'Accept'=>'application/json'}). + to_return(:body => webmock_fixture("loc-subjects-response.txt"), :status => 200) + + @authority.search("History--", "subjects") + end + + it "should return an array of entries returned in the JSON" do + @parsed_response = @authority.parse_authority_response(@authority.raw_response) + expect(@parsed_response.length).to eq(20) + end + + it "should have a URI for the id and a string label" do + @authority.results.first["label"].should == "History--Philosophy--History--20th century" + @authority.results.first["id"].should == "info:lc/authorities/subjects/sh2008121753" + @authority.results[1]["label"].should == "History--Philosophy--History--19th century" + @authority.results[1]["id"].should == "info:lc/authorities/subjects/sh2008121752" + end - it "should return an array of entries returned in the JSON" do - expect(parsed_response.length).to eq(2) end - it "should have a URI for the id and a string label" do - expect(parsed_response[0]["id"]).to eq("info:lc/authorities/names/n2008008718") - expect(parsed_response[0]["label"]).to eq("Haw, Lily, 1890?-1915") - expect(parsed_response[1]["id"]).to eq("info:lc/vocabulary/geographicAreas/n-us-hi") - expect(parsed_response[1]["label"]).to eq("Hawaii") + describe "name_search" do + before :all do + stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names"). + with(:headers => {'Accept'=>'application/json'}). + to_return(:body => webmock_fixture("loc-names-response.txt"), :status => 200) + end + + it "should retrieve names via search" do + @authority.search("Berry", "names") + @authority.results.first["label"].should == "Berry, James W. (James William), 1938-" + end + end end end