qa 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +12 -2
  3. data/app/controllers/qa/terms_controller.rb +14 -16
  4. data/app/models/qa/mesh_tree.rb +3 -5
  5. data/app/models/qa/subject_mesh_term.rb +15 -15
  6. data/config/routes.rb +1 -1
  7. data/lib/generators/qa/install/install_generator.rb +2 -3
  8. data/lib/generators/qa/local/tables/mysql/mysql_generator.rb +3 -5
  9. data/lib/generators/qa/local/tables/tables_generator.rb +4 -6
  10. data/lib/qa/authorities/assign_fast/generic_authority.rb +16 -19
  11. data/lib/qa/authorities/assign_fast_subauthority.rb +3 -5
  12. data/lib/qa/authorities/authority_with_sub_authority.rb +1 -2
  13. data/lib/qa/authorities/base.rb +2 -3
  14. data/lib/qa/authorities/geonames.rb +11 -12
  15. data/lib/qa/authorities/getty.rb +7 -8
  16. data/lib/qa/authorities/getty/aat.rb +11 -12
  17. data/lib/qa/authorities/getty/tgn.rb +15 -15
  18. data/lib/qa/authorities/getty/ulan.rb +15 -16
  19. data/lib/qa/authorities/loc/generic_authority.rb +32 -33
  20. data/lib/qa/authorities/loc_subauthority.rb +17 -20
  21. data/lib/qa/authorities/local.rb +41 -40
  22. data/lib/qa/authorities/local/file_based_authority.rb +18 -19
  23. data/lib/qa/authorities/local/mysql_table_based_authority.rb +8 -6
  24. data/lib/qa/authorities/local/registry.rb +5 -5
  25. data/lib/qa/authorities/local/table_based_authority.rb +26 -19
  26. data/lib/qa/authorities/mesh.rb +8 -16
  27. data/lib/qa/authorities/mesh_tools.rb +5 -5
  28. data/lib/qa/authorities/mesh_tools/mesh_data_parser.rb +4 -6
  29. data/lib/qa/authorities/mesh_tools/mesh_importer.rb +11 -13
  30. data/lib/qa/authorities/oclcts.rb +0 -1
  31. data/lib/qa/authorities/oclcts/generic_oclc_authority.rb +16 -16
  32. data/lib/qa/authorities/tgnlang.rb +7 -12
  33. data/lib/qa/version.rb +1 -1
  34. data/spec/controllers/terms_controller_spec.rb +44 -54
  35. data/spec/lib/authorities/assign_fast_spec.rb +25 -27
  36. data/spec/lib/authorities/file_based_authority_spec.rb +25 -26
  37. data/spec/lib/authorities/geonames_spec.rb +5 -6
  38. data/spec/lib/authorities/getty/aat_spec.rb +6 -10
  39. data/spec/lib/authorities/getty/tgn_spec.rb +6 -10
  40. data/spec/lib/authorities/getty/ulan_spec.rb +6 -10
  41. data/spec/lib/authorities/getty_spec.rb +4 -5
  42. data/spec/lib/authorities/loc_spec.rb +30 -36
  43. data/spec/lib/authorities/local_spec.rb +5 -7
  44. data/spec/lib/authorities/mesh_spec.rb +9 -9
  45. data/spec/lib/authorities/mysql_table_based_authority_spec.rb +13 -5
  46. data/spec/lib/authorities/oclcts_spec.rb +17 -21
  47. data/spec/lib/authorities/table_based_authority_spec.rb +21 -12
  48. data/spec/lib/authorities/tgnlang_spec.rb +4 -6
  49. data/spec/lib/authorities_loc_subauthorities.rb +50 -54
  50. data/spec/lib/mesh_data_parser_spec.rb +73 -79
  51. data/spec/lib/services/rdf_authority_parser_spec.rb +2 -7
  52. data/spec/lib/tasks/mesh.rake_spec.rb +16 -12
  53. data/spec/models/subject_mesh_term_spec.rb +4 -4
  54. data/spec/routing/route_spec.rb +13 -15
  55. data/spec/spec_helper.rb +3 -4
  56. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -1
  57. metadata +45 -17
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Loc do
4
-
5
4
  describe "#new" do
6
5
  context "without a sub-authority" do
7
- it "should raise an exception" do
6
+ it "raises an exception" do
8
7
  expect { described_class.new }.to raise_error RuntimeError, "Initializing with as sub authority is removed. use Module.subauthority_for(nil) instead"
9
8
  end
10
9
  end
@@ -12,24 +11,24 @@ describe Qa::Authorities::Loc do
12
11
 
13
12
  describe "#subauthority_for" do
14
13
  context "with an invalid sub-authority" do
15
- it "should raise an exception" do
16
- expect { Qa::Authorities::Loc.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
14
+ it "raises an exception" do
15
+ expect { described_class.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
17
16
  end
18
17
  end
19
18
  context "with a valid sub-authority" do
20
- it "should create the authority" do
21
- expect(Qa::Authorities::Loc.subauthority_for("subjects")).to be_kind_of Qa::Authorities::Loc::GenericAuthority
19
+ it "creates the authority" do
20
+ expect(described_class.subauthority_for("subjects")).to be_kind_of Qa::Authorities::Loc::GenericAuthority
22
21
  end
23
22
  end
24
23
  end
25
24
 
26
25
  describe "urls" do
27
26
  let :authority do
28
- Qa::Authorities::Loc.subauthority_for("subjects")
27
+ described_class.subauthority_for("subjects")
29
28
  end
30
29
 
31
30
  context "for searching" do
32
- it "should return a url" do
31
+ it "returns a url" do
33
32
  url = 'http://id.loc.gov/search/?q=foo&q=cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json'
34
33
  expect(authority.build_query_url("foo")).to eq(url)
35
34
  end
@@ -44,46 +43,43 @@ describe Qa::Authorities::Loc do
44
43
  end
45
44
 
46
45
  describe "#search" do
47
-
48
46
  context "any LOC authorities" do
49
47
  let :authority do
50
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas").
51
- with(:headers => {'Accept'=>'application/json'}).
52
- to_return(:body => webmock_fixture("loc-response.txt"), :status => 200)
53
- Qa::Authorities::Loc.subauthority_for("geographicAreas")
48
+ stub_request(:get, "http://id.loc.gov/search/?format=json&q=s&q=cs:http://id.loc.gov/vocabulary/geographicAreas")
49
+ .with(headers: { 'Accept' => 'application/json' })
50
+ .to_return(body: webmock_fixture("loc-response.txt"), status: 200)
51
+ described_class.subauthority_for("geographicAreas")
54
52
  end
55
53
 
56
- it "should retain the raw respsonse from the LC service in JSON" do
57
- expect { authority.search("s") }.to change { authority.raw_response }.
58
- from(nil).
59
- to(JSON.parse(webmock_fixture("loc-response.txt").read))
54
+ it "retains the raw respsonse from the LC service in JSON" do
55
+ expect { authority.search("s") }.to change { authority.raw_response }
56
+ .from(nil)
57
+ .to(JSON.parse(webmock_fixture("loc-response.txt").read))
60
58
  end
61
59
 
62
60
  describe "the returned results" do
63
-
64
61
  let :results do
65
62
  authority.search("s")
66
63
  end
67
64
 
68
- it "should have :id and :label elements" do
65
+ it "has :id and :label elements" do
69
66
  expect(results.first["label"]).to eq("West (U.S.)")
70
67
  expect(results.first["id"]).to eq("info:lc/vocabulary/geographicAreas/n-usp")
71
68
  expect(results.last["label"]).to eq("Baltic States")
72
69
  expect(results.last["id"]).to eq("info:lc/vocabulary/geographicAreas/eb")
73
70
  expect(results.size).to eq(20)
74
71
  end
75
-
76
72
  end
77
73
  end
78
74
 
79
75
  context "subject terms" do
80
76
  let :results do
81
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects").
82
- with(:headers => {'Accept'=>'application/json'}).
83
- to_return(:body => webmock_fixture("loc-subjects-response.txt"), :status => 200)
84
- Qa::Authorities::Loc.subauthority_for("subjects").search("History--")
77
+ stub_request(:get, "http://id.loc.gov/search/?format=json&q=History--&q=cs:http://id.loc.gov/authorities/subjects")
78
+ .with(headers: { 'Accept' => 'application/json' })
79
+ .to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
80
+ described_class.subauthority_for("subjects").search("History--")
85
81
  end
86
- it "should have a URI for the id and a string label" do
82
+ it "has a URI for the id and a string label" do
87
83
  expect(results.count).to eq(20)
88
84
  expect(results.first["label"]).to eq("History--Philosophy--History--20th century")
89
85
  expect(results.first["id"]).to eq("info:lc/authorities/subjects/sh2008121753")
@@ -94,25 +90,24 @@ describe Qa::Authorities::Loc do
94
90
 
95
91
  context "name terms" do
96
92
  let :results do
97
- stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names").
98
- with(:headers => {'Accept'=>'application/json'}).
99
- to_return(:body => webmock_fixture("loc-names-response.txt"), :status => 200)
100
- Qa::Authorities::Loc.subauthority_for("names").search("Berry")
93
+ stub_request(:get, "http://id.loc.gov/search/?format=json&q=Berry&q=cs:http://id.loc.gov/authorities/names")
94
+ .with(headers: { 'Accept' => 'application/json' })
95
+ .to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
96
+ described_class.subauthority_for("names").search("Berry")
101
97
  end
102
- it "should retrieve names via search" do
98
+ it "retrieves names via search" do
103
99
  expect(results.first["label"]).to eq("Berry, James W. (James William), 1938-")
104
100
  end
105
101
  end
106
-
107
102
  end
108
103
 
109
104
  describe "#find" do
110
105
  context "using a subject id" do
111
106
  let :results do
112
- stub_request(:get, "http://id.loc.gov/authorities/subjects/sh2002003586.json").
113
- with(:headers => {'Accept'=>'application/json'}).
114
- to_return(:status => 200, :body => webmock_fixture("loc-subject-find-response.txt"), :headers => {})
115
- Qa::Authorities::Loc.subauthority_for("subjects").find("sh2002003586")
107
+ stub_request(:get, "http://id.loc.gov/authorities/subjects/sh2002003586.json")
108
+ .with(headers: { 'Accept' => 'application/json' })
109
+ .to_return(status: 200, body: webmock_fixture("loc-subject-find-response.txt"), headers: {})
110
+ described_class.subauthority_for("subjects").find("sh2002003586")
116
111
  end
117
112
  it "returns the complete record for a given subject" do
118
113
  expect(results.count).to eq(20)
@@ -120,5 +115,4 @@ describe Qa::Authorities::Loc do
120
115
  end
121
116
  end
122
117
  end
123
-
124
118
  end
@@ -1,9 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Local do
4
-
5
4
  describe "new" do
6
- it "should raise an error" do
5
+ it "raises an error" do
7
6
  expect { described_class.new }.to raise_error RuntimeError, "Initializing with as sub authority is removed. use Module.subauthority_for(nil) instead"
8
7
  end
9
8
  end
@@ -40,7 +39,7 @@ describe Qa::Authorities::Local do
40
39
  context "when the path doesn't exist" do
41
40
  before do
42
41
  @original_path = described_class.config[:local_path]
43
- described_class.config[:local_path] = '/foo/bar'
42
+ described_class.config[:local_path] = '/foo/bar'
44
43
  end
45
44
  after { described_class.config[:local_path] = @original_path }
46
45
 
@@ -50,20 +49,19 @@ describe Qa::Authorities::Local do
50
49
  end
51
50
  end
52
51
 
53
-
54
52
  describe ".subauthority_for" do
55
53
  context "without a sub-authority" do
56
- it "should raise an error is the sub-authority is not provided" do
54
+ it "raises an error is the sub-authority is not provided" do
57
55
  expect { described_class.subauthority_for }.to raise_error ArgumentError
58
56
  end
59
- it "should raise an error is the sub-authority does not exist" do
57
+ it "raises an error is the sub-authority does not exist" do
60
58
  expect { described_class.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
61
59
  end
62
60
  end
63
61
 
64
62
  context "with a sub authority" do
65
63
  subject { described_class.subauthority_for("authority_A") }
66
- it "should return a file authority" do
64
+ it "returns a file authority" do
67
65
  expect(subject).to be_kind_of Qa::Authorities::Local::FileBasedAuthority
68
66
  end
69
67
  end
@@ -10,9 +10,9 @@ describe Qa::Authorities::Mesh do
10
10
  File.open(webmock_fixture('mesh.txt').path) do |f|
11
11
  m.import_from_file(f)
12
12
  end
13
- where_unique_record(Qa::SubjectMeshTerm, {term_lower: "malaria"})
14
- where_unique_record(Qa::SubjectMeshTerm, {term: "Malaria"})
15
- where_unique_record(Qa::SubjectMeshTerm, {term_id: "D008288"})
13
+ where_unique_record(Qa::SubjectMeshTerm, term_lower: "malaria")
14
+ where_unique_record(Qa::SubjectMeshTerm, term: "Malaria")
15
+ where_unique_record(Qa::SubjectMeshTerm, term_id: "D008288")
16
16
  expect(Qa::SubjectMeshTerm.all.length).to eq(11)
17
17
  end
18
18
 
@@ -27,24 +27,24 @@ describe Qa::Authorities::Mesh do
27
27
  Qa::SubjectMeshTerm.delete_all
28
28
  end
29
29
 
30
- let(:m) { Qa::Authorities::Mesh.new }
30
+ let(:m) { described_class.new }
31
31
 
32
32
  it "handles queries" do
33
33
  results = m.search('mr ')
34
34
  expect(results.length).to eq(2)
35
- expect(results).to include( {id: '1', label: 'Mr Plow'} )
36
- expect(results).to include( {id: '2', label: 'Mr Snow'} )
37
- expect(results).not_to include( {id: '3', label: 'Mrs Fields'} )
35
+ expect(results).to include(id: '1', label: 'Mr Plow')
36
+ expect(results).to include(id: '2', label: 'Mr Snow')
37
+ expect(results).not_to include(id: '3', label: 'Mrs Fields')
38
38
  end
39
39
 
40
40
  it "returns individual records" do
41
41
  result = m.find('2')
42
- expect(result).to eq({id: '2', label: 'Mr Snow', synonyms: []})
42
+ expect(result).to eq(id: '2', label: 'Mr Snow', synonyms: [])
43
43
  end
44
44
 
45
45
  it "returns all records" do
46
46
  expect(m.all.count).to eq(3)
47
- expect(m.all).to include({:id=>"2", :label=>"Mr Snow"})
47
+ expect(m.all).to include(id: "2", label: "Mr Snow")
48
48
  end
49
49
  end
50
50
  end
@@ -8,6 +8,16 @@ describe Qa::Authorities::Local::MysqlTableBasedAuthority do
8
8
  Qa::Authorities::Local.register_subauthority('language', described_class.to_s)
9
9
  end
10
10
 
11
+ describe "::table_name" do
12
+ subject { described_class.table_name }
13
+ it { is_expected.to eq("qa_local_authority_entries") }
14
+ end
15
+
16
+ describe "::table_index" do
17
+ subject { described_class.table_index }
18
+ it { is_expected.to eq("index_qa_local_authority_entries_on_lower_label_and_authority") }
19
+ end
20
+
11
21
  describe "#check_for_index" do
12
22
  let(:connection) { ActiveRecord::Base.connection }
13
23
  before do
@@ -15,7 +25,7 @@ describe Qa::Authorities::Local::MysqlTableBasedAuthority do
15
25
  end
16
26
  context "with no index" do
17
27
  before do
18
- #allow(connection).to receive(:index_name_exists?).and_return(nil)
28
+ # allow(connection).to receive(:index_name_exists?).and_return(nil)
19
29
  end
20
30
  it "outputs an error message" do
21
31
  expect(Rails.logger).to receive(:error)
@@ -36,7 +46,7 @@ describe Qa::Authorities::Local::MysqlTableBasedAuthority do
36
46
  describe "#search" do
37
47
  context "with an empty query string" do
38
48
  let(:expected) { [] }
39
- it "should return no results" do
49
+ it "returns no results" do
40
50
  expect(Qa::LocalAuthorityEntry).not_to receive(:where)
41
51
  expect(language.search("")).to eq(expected)
42
52
  end
@@ -44,12 +54,10 @@ describe Qa::Authorities::Local::MysqlTableBasedAuthority do
44
54
  context "with at least one matching entry" do
45
55
  it "is case insensitive by using lower_lable column" do
46
56
  expect(Qa::LocalAuthorityEntry).to receive(:where).with(local_authority: language_auth).and_return(base_relation)
47
- expect(base_relation).to receive(:where).with("lower_label like ?","fre%").and_return(base_relation)
57
+ expect(base_relation).to receive(:where).with("lower_label like ?", "fre%").and_return(base_relation)
48
58
  expect(base_relation).to receive(:limit).and_return([])
49
59
  language.search("fRe")
50
60
  end
51
61
  end
52
-
53
62
  end
54
-
55
63
  end
@@ -1,50 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Oclcts do
4
-
5
- before :each do
6
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22ball*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1").
7
- to_return(:body => webmock_fixture("oclcts-response-mesh-1.txt"), :status => 200)
8
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22alph*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1").
9
- to_return(:body => webmock_fixture("oclcts-response-mesh-2.txt"), :status => 200)
10
- stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=dc.identifier%20exact%20%22D031329Q000821%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1").
11
- to_return(:body => webmock_fixture("oclcts-response-mesh-3.txt"), :status => 200)
12
-
13
- @first_query = Qa::Authorities::Oclcts.subauthority_for("mesh")
4
+ before do
5
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22ball*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
6
+ .to_return(body: webmock_fixture("oclcts-response-mesh-1.txt"), status: 200)
7
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=oclcts.rootHeading%20exact%20%22alph*%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
8
+ .to_return(body: webmock_fixture("oclcts-response-mesh-2.txt"), status: 200)
9
+ stub_request(:get, "http://tspilot.oclc.org/mesh/?maximumRecords=10&operation=searchRetrieve&query=dc.identifier%20exact%20%22D031329Q000821%22&recordPacking=xml&recordSchema=http://zthes.z3950.org/xml/1.0/&recordXPath=&resultSetTTL=300&sortKeys=&startRecord=1&version=1.1")
10
+ .to_return(body: webmock_fixture("oclcts-response-mesh-3.txt"), status: 200)
11
+
12
+ @first_query = described_class.subauthority_for("mesh")
14
13
  @terms = @first_query.search("ball")
15
14
  @term_record = @first_query.find(@terms.first["id"])
16
- @second_query = Qa::Authorities::Oclcts.subauthority_for("mesh")
15
+ @second_query = described_class.subauthority_for("mesh")
17
16
  @second_query.search("alph")
18
17
  end
19
18
 
20
19
  describe "a query for terms" do
21
-
22
- it "should have an array of hashes that match the query" do
20
+ it "has an array of hashes that match the query" do
23
21
  expect(@terms).to be_kind_of Array
24
22
  expect(@terms.first).to be_kind_of Hash
25
23
  expect(@terms.first["label"]).to be_kind_of String
26
24
  expect(@terms.first["label"]).to include "Ballota"
27
25
  end
28
26
 
29
- it "should have an array of hashes containing unique id and label" do
27
+ it "has an array of hashes containing unique id and label" do
30
28
  expect(@terms.first).to have_key("id")
31
29
  expect(@terms.first).to have_key("label")
32
30
  end
33
-
34
31
  end
35
32
 
36
33
  describe "a query for a single item" do
37
- it "should have a hash of values that represent the item requested" do
34
+ it "has a hash of values that represent the item requested" do
38
35
  expect(@term_record).to be_kind_of Hash
39
- expect(@term_record.values).to include @terms.first["id"]
36
+ expect(@term_record.values).to include @terms.first["id"]
40
37
  expect(@term_record.values).to include @terms.first["label"]
41
38
  end
42
-
43
- it "should succeed for valid ids, even if the id is not in the initial list of responses" do
39
+
40
+ it "succeeds for valid ids, even if the id is not in the initial list of responses" do
44
41
  record = @second_query.find(@terms.first["id"])
45
42
  expect(record.values).to include @terms.first["id"]
46
43
  expect(record.values).to include @terms.first["label"]
47
44
  end
48
45
  end
49
-
50
- end
46
+ end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Local::TableBasedAuthority do
4
-
5
4
  let(:language) { Qa::Authorities::Local.subauthority_for("language") }
6
5
  let(:subj) { Qa::Authorities::Local.subauthority_for("subject") }
7
6
 
@@ -15,28 +14,38 @@ describe Qa::Authorities::Local::TableBasedAuthority do
15
14
  Qa::LocalAuthorityEntry.create(local_authority: alternate_auth, label: 'French', uri: 'http://example.com/french')
16
15
  end
17
16
 
17
+ describe "::table_name" do
18
+ subject { described_class.table_name }
19
+ it { is_expected.to eq("qa_local_authority_entries") }
20
+ end
21
+
22
+ describe "::table_index" do
23
+ subject { described_class.table_index }
24
+ it { is_expected.to eq("index_qa_local_authority_entries_on_lower_label") }
25
+ end
26
+
18
27
  describe "#all" do
19
- let(:expected) { [ { 'id'=> "A1", 'label' => "Abc Term A1" },
20
- { 'id' => "A2", 'label'=> "Term A2" },
21
- { 'id' => "A3", 'label' => "Abc Term A3" } ] }
22
- it "should return all the entries" do
28
+ let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
29
+ { 'id' => "A2", 'label' => "Term A2" },
30
+ { 'id' => "A3", 'label' => "Abc Term A3" }] }
31
+ it "returns all the entries" do
23
32
  expect(language.all).to eq [
24
- {"id"=>"http://id.loc.gov/vocabulary/languages/fre", "label"=>"French"},
25
- {"id"=>"http://id.loc.gov/vocabulary/languages/uig", "label"=>"Uighur"}]
26
-
33
+ { "id" => "http://id.loc.gov/vocabulary/languages/fre", "label" => "French" },
34
+ { "id" => "http://id.loc.gov/vocabulary/languages/uig", "label" => "Uighur" }
35
+ ]
27
36
  end
28
37
  end
29
38
 
30
39
  describe "#search" do
31
40
  context "with an empty query string" do
32
41
  let(:expected) { [] }
33
- it "should return no results" do
42
+ it "returns no results" do
34
43
  expect(language.search("")).to eq(expected)
35
44
  end
36
45
  end
37
46
  context "with at least one matching entry" do
38
47
  it "is case insensitive" do
39
- expect(language.search("fRe")).to eq [{"id"=>"http://id.loc.gov/vocabulary/languages/fre", "label"=>"French"}]
48
+ expect(language.search("fRe")).to eq [{ "id" => "http://id.loc.gov/vocabulary/languages/fre", "label" => "French" }]
40
49
  end
41
50
  end
42
51
 
@@ -49,7 +58,7 @@ describe Qa::Authorities::Local::TableBasedAuthority do
49
58
 
50
59
  describe "#find" do
51
60
  context "term exists" do
52
- it "should return the full term record" do
61
+ it "returns the full term record" do
53
62
  record = language.find('http://id.loc.gov/vocabulary/languages/fre')
54
63
  expect(record).to be_a HashWithIndifferentAccess
55
64
  expect(record).to eq('id' => "http://id.loc.gov/vocabulary/languages/fre",
@@ -59,7 +68,7 @@ describe Qa::Authorities::Local::TableBasedAuthority do
59
68
  context "term does not exist" do
60
69
  let(:id) { "NonID" }
61
70
  let(:expected) { {} }
62
- it "should return an empty hash" do
71
+ it "returns an empty hash" do
63
72
  expect(language.find('http://id.loc.gov/vocabulary/languages/eng')).to be_nil
64
73
  end
65
74
  end
@@ -1,16 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Tgnlang do
4
-
5
- let(:subject) { @terms = Qa::Authorities::Tgnlang.new }
4
+ let(:subject) { @terms = described_class.new }
6
5
 
7
6
  describe "#search" do
8
- it "should return unique record with query of Tibetan" do
9
- expect(subject.search("Tibetan")).to eq([{"id"=>"75446", "label"=>"Tibetan"}])
7
+ it "returns unique record with query of Tibetan" do
8
+ expect(subject.search("Tibetan")).to eq([{ "id" => "75446", "label" => "Tibetan" }])
10
9
  end
11
- it "should return type Array" do
10
+ it "returns type Array" do
12
11
  expect(subject.search("Tibetan")).to be_kind_of(Array)
13
12
  end
14
13
  end
15
-
16
14
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::LocSubauthority do
4
-
5
4
  let(:subject) do
6
5
  class TestAuthority
7
6
  include Qa::Authorities::LocSubauthority
@@ -10,7 +9,7 @@ describe Qa::Authorities::LocSubauthority do
10
9
  end
11
10
 
12
11
  context "with a valid subauthority" do
13
- it "should return a url" do
12
+ it "returns a url" do
14
13
  subauthority_table.keys.each do |authority|
15
14
  expect(subject.get_url_for_authority(authority)).to eq(subauthority_table[authority])
16
15
  end
@@ -18,7 +17,7 @@ describe Qa::Authorities::LocSubauthority do
18
17
  end
19
18
 
20
19
  context "with a non-existent subauthority" do
21
- it "should return nil" do
20
+ it "returns nil" do
22
21
  expect(subject.get_url_for_authority("fake")).to be_nil
23
22
  end
24
23
  end
@@ -26,56 +25,53 @@ describe Qa::Authorities::LocSubauthority do
26
25
  # This is the original data structure that was used to define subauthority urls
27
26
  # It is retained here to ensure our refactor succeeded
28
27
  def subauthority_table
29
- begin
30
- vocab_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F'
31
- authority_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F'
32
- datatype_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F'
33
- vocab_preservation_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F'
34
- {
35
- 'subjects' => authority_base_url,
36
- 'names' => authority_base_url,
37
- 'classification' => authority_base_url,
38
- 'childrensSubjects' => authority_base_url,
39
- 'genreForms' => authority_base_url,
40
- 'performanceMediums' => authority_base_url,
41
- 'graphicMaterials' => vocab_base_url,
42
- 'organizations' => vocab_base_url,
43
- 'relators' => vocab_base_url,
44
- 'countries' => vocab_base_url,
45
- 'ethnographicTerms' => vocab_base_url,
46
- 'geographicAreas' => vocab_base_url,
47
- 'languages' => vocab_base_url,
48
- 'iso639-1' => vocab_base_url,
49
- 'iso639-2' => vocab_base_url,
50
- 'iso639-5' => vocab_base_url,
51
- 'edtf' => datatype_base_url,
52
- 'preservation' => vocab_base_url,
53
- 'actionsGranted' => vocab_base_url,
54
- 'agentType' => vocab_base_url,
55
- 'contentLocationType' => vocab_preservation_base_url,
56
- 'copyrightStatus' => vocab_preservation_base_url,
57
- 'cryptographicHashFunctions' => vocab_preservation_base_url,
58
- 'environmentCharacteristic' => vocab_preservation_base_url,
59
- 'environmentPurpose' => vocab_preservation_base_url,
60
- 'eventRelatedAgentRole' => vocab_preservation_base_url,
61
- 'eventRelatedObjectRole' => vocab_preservation_base_url,
62
- 'eventType' => vocab_preservation_base_url,
63
- 'formatRegistryRole' => vocab_preservation_base_url,
64
- 'hardwareType' => vocab_preservation_base_url,
65
- 'inhibitorTarget' => vocab_preservation_base_url,
66
- 'inhibitorType' => vocab_preservation_base_url,
67
- 'objectCategory' => vocab_preservation_base_url,
68
- 'preservationLevelRole' => vocab_preservation_base_url,
69
- 'relationshipSubType' => vocab_preservation_base_url,
70
- 'relationshipType' => vocab_preservation_base_url,
71
- 'rightsBasis' => vocab_preservation_base_url,
72
- 'rightsRelatedAgentRole' => vocab_preservation_base_url,
73
- 'signatureEncoding' => vocab_preservation_base_url,
74
- 'signatureMethod' => vocab_preservation_base_url,
75
- 'softwareType' => vocab_preservation_base_url,
76
- 'storageMedium' => vocab_preservation_base_url
77
- }
78
- end
28
+ vocab_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2F'
29
+ authority_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fauthorities%2F'
30
+ datatype_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fdatatypes%2F'
31
+ vocab_preservation_base_url = 'cs%3Ahttp%3A%2F%2Fid.loc.gov%2Fvocabulary%2Fpreservation%2F'
32
+ {
33
+ 'subjects' => authority_base_url,
34
+ 'names' => authority_base_url,
35
+ 'classification' => authority_base_url,
36
+ 'childrensSubjects' => authority_base_url,
37
+ 'genreForms' => authority_base_url,
38
+ 'performanceMediums' => authority_base_url,
39
+ 'graphicMaterials' => vocab_base_url,
40
+ 'organizations' => vocab_base_url,
41
+ 'relators' => vocab_base_url,
42
+ 'countries' => vocab_base_url,
43
+ 'ethnographicTerms' => vocab_base_url,
44
+ 'geographicAreas' => vocab_base_url,
45
+ 'languages' => vocab_base_url,
46
+ 'iso639-1' => vocab_base_url,
47
+ 'iso639-2' => vocab_base_url,
48
+ 'iso639-5' => vocab_base_url,
49
+ 'edtf' => datatype_base_url,
50
+ 'preservation' => vocab_base_url,
51
+ 'actionsGranted' => vocab_base_url,
52
+ 'agentType' => vocab_base_url,
53
+ 'contentLocationType' => vocab_preservation_base_url,
54
+ 'copyrightStatus' => vocab_preservation_base_url,
55
+ 'cryptographicHashFunctions' => vocab_preservation_base_url,
56
+ 'environmentCharacteristic' => vocab_preservation_base_url,
57
+ 'environmentPurpose' => vocab_preservation_base_url,
58
+ 'eventRelatedAgentRole' => vocab_preservation_base_url,
59
+ 'eventRelatedObjectRole' => vocab_preservation_base_url,
60
+ 'eventType' => vocab_preservation_base_url,
61
+ 'formatRegistryRole' => vocab_preservation_base_url,
62
+ 'hardwareType' => vocab_preservation_base_url,
63
+ 'inhibitorTarget' => vocab_preservation_base_url,
64
+ 'inhibitorType' => vocab_preservation_base_url,
65
+ 'objectCategory' => vocab_preservation_base_url,
66
+ 'preservationLevelRole' => vocab_preservation_base_url,
67
+ 'relationshipSubType' => vocab_preservation_base_url,
68
+ 'relationshipType' => vocab_preservation_base_url,
69
+ 'rightsBasis' => vocab_preservation_base_url,
70
+ 'rightsRelatedAgentRole' => vocab_preservation_base_url,
71
+ 'signatureEncoding' => vocab_preservation_base_url,
72
+ 'signatureMethod' => vocab_preservation_base_url,
73
+ 'softwareType' => vocab_preservation_base_url,
74
+ 'storageMedium' => vocab_preservation_base_url
75
+ }
79
76
  end
80
-
81
77
  end