qa 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,11 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::AssignFast do
4
-
5
4
  # subauthority infrastructure
6
5
  describe "#new" do
7
6
  context "without a sub-authority" do
8
- it "should raise an exception" do
7
+ it "raises an exception" do
9
8
  expect { described_class.new }.to raise_error RuntimeError, "Initializing with as sub authority is removed. use Module.subauthority_for(nil) instead"
10
9
  end
11
10
  end
@@ -13,13 +12,13 @@ describe Qa::Authorities::AssignFast do
13
12
 
14
13
  describe "#subauthority_for" do
15
14
  context "with an invalid sub-authority" do
16
- it "should raise an exception" do
17
- expect { Qa::Authorities::AssignFast.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
15
+ it "raises an exception" do
16
+ expect { described_class.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
18
17
  end
19
18
  end
20
19
  context "with a valid sub-authority" do
21
- it "should create the authority" do
22
- expect(Qa::Authorities::AssignFast.subauthority_for("all")).to be_kind_of Qa::Authorities::AssignFast::GenericAuthority
20
+ it "creates the authority" do
21
+ expect(described_class.subauthority_for("all")).to be_kind_of Qa::Authorities::AssignFast::GenericAuthority
23
22
  end
24
23
  end
25
24
  end
@@ -27,7 +26,7 @@ describe Qa::Authorities::AssignFast do
27
26
  # api call
28
27
  describe "query url" do
29
28
  let :authority do
30
- Qa::Authorities::AssignFast.subauthority_for("all")
29
+ described_class.subauthority_for("all")
31
30
  end
32
31
 
33
32
  it "is correctly formed" do
@@ -38,15 +37,15 @@ describe Qa::Authorities::AssignFast do
38
37
 
39
38
  describe "search result" do
40
39
  let :authority do
41
- Qa::Authorities::AssignFast.subauthority_for("all")
40
+ described_class.subauthority_for("all")
42
41
  end
43
42
 
44
43
  context "when we sent a bad character" do
45
44
  # server returns 200 with empty response; JSON throws a ParserError
46
45
  before do
47
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject").
48
- with(:headers => {'Accept'=>'application/json'}).
49
- to_return(:status => 200, :body => "", :headers => {})
46
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
47
+ .with(headers: { 'Accept' => 'application/json' })
48
+ .to_return(status: 200, body: "", headers: {})
50
49
  end
51
50
  it "logs an info and returns an empty array" do
52
51
  expect(Rails.logger).to receive(:info).with("Could not parse response as JSON. Request url: http://fast.oclc.org/searchfast/fastsuggest?&query=word%20ling&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20")
@@ -58,11 +57,11 @@ describe Qa::Authorities::AssignFast do
58
57
  context "when query is blank" do
59
58
  # server returns results but no results header
60
59
  let :results do
61
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?&query=&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20").
62
- with(:headers => {'Accept'=>'application/json'}).
63
- to_return(:body => webmock_fixture("assign-fast-noheader.json"), :status => 200, :headers => {})
60
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?&query=&queryIndex=suggestall&queryReturn=suggestall%2Cidroot%2Cauth%2Ctype&suggest=autoSubject&rows=20")
61
+ .with(headers: { 'Accept' => 'application/json' })
62
+ .to_return(body: webmock_fixture("assign-fast-noheader.json"), status: 200, headers: {})
64
63
  authority.search("")
65
- end
64
+ end
66
65
  it "returns an empty array" do
67
66
  expect(results).to eq([])
68
67
  end
@@ -70,9 +69,9 @@ describe Qa::Authorities::AssignFast do
70
69
 
71
70
  context "with no results" do
72
71
  let :results do
73
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject").
74
- with(:headers => {'Accept'=>'application/json'}).
75
- to_return(:body => webmock_fixture("assign-fast-noresults.json"), :status => 200, :headers => {})
72
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
73
+ .with(headers: { 'Accept' => 'application/json' })
74
+ .to_return(body: webmock_fixture("assign-fast-noresults.json"), status: 200, headers: {})
76
75
  authority.search("word (ling")
77
76
  end
78
77
  it "returns an empty array" do
@@ -82,9 +81,9 @@ describe Qa::Authorities::AssignFast do
82
81
 
83
82
  context "with suggestall results" do
84
83
  let :results do
85
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject").
86
- with(:headers => {'Accept'=>'application/json'}).
87
- to_return(:body => webmock_fixture("assign-fast-oneresult.json"), :status => 200, :headers => {})
84
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word%20ling&queryIndex=suggestall&queryReturn=suggestall,idroot,auth,type&rows=20&suggest=autoSubject")
85
+ .with(headers: { 'Accept' => 'application/json' })
86
+ .to_return(body: webmock_fixture("assign-fast-oneresult.json"), status: 200, headers: {})
88
87
  authority.search("word (ling")
89
88
  end
90
89
  it "is correctly parsed" do
@@ -92,16 +91,16 @@ describe Qa::Authorities::AssignFast do
92
91
  expect(results.first[:id]).to eq('fst01180101')
93
92
  expect(results.first[:label]).to eq('Word (Linguistics)')
94
93
  expect(results.first[:value]).to eq('Word (Linguistics)')
95
- expect(results.first).to eq({:id=>"fst01180101", :label=>"Word (Linguistics)", :value=>"Word (Linguistics)"})
94
+ expect(results.first).to eq(id: "fst01180101", label: "Word (Linguistics)", value: "Word (Linguistics)")
96
95
  end
97
96
  end
98
97
 
99
98
  context "with topical results" do
100
99
  let :results do
101
- stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject").
102
- with(:headers => {'Accept'=>'application/json'}).
103
- to_return(:body => webmock_fixture("assign-fast-topical-result.json"), :status => 200, :headers => {})
104
- Qa::Authorities::AssignFast.subauthority_for("topical").search("word")
100
+ stub_request(:get, "http://fast.oclc.org/searchfast/fastsuggest?query=word&queryIndex=suggest50&queryReturn=suggest50,idroot,auth,type&rows=20&suggest=autoSubject")
101
+ .with(headers: { 'Accept' => 'application/json' })
102
+ .to_return(body: webmock_fixture("assign-fast-topical-result.json"), status: 200, headers: {})
103
+ described_class.subauthority_for("topical").search("word")
105
104
  end
106
105
  it "is correctly parsed" do
107
106
  expect(results.count).to eq(20)
@@ -111,5 +110,4 @@ describe Qa::Authorities::AssignFast do
111
110
  end
112
111
  end
113
112
  end
114
-
115
113
  end
@@ -7,30 +7,30 @@ describe Qa::Authorities::Local::FileBasedAuthority do
7
7
  let(:authority_d) { Qa::Authorities::Local.subauthority_for("authority_D") }
8
8
 
9
9
  describe "#all" do
10
- let(:expected) { [ { 'id'=> "A1", 'label' => "Abc Term A1" },
11
- { 'id' => "A2", 'label'=> "Term A2" },
12
- { 'id' => "A3", 'label' => "Abc Term A3" } ] }
13
- it "should return all the entries" do
10
+ let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
11
+ { 'id' => "A2", 'label' => "Term A2" },
12
+ { 'id' => "A3", 'label' => "Abc Term A3" }] }
13
+ it "returns all the entries" do
14
14
  expect(authority_a.all).to eq(expected)
15
15
  end
16
16
  context "when terms do not have ids" do
17
- let(:expected) { [ { 'id' => "Term B1", 'label' => "Term B1" },
18
- { 'id' => "Term B2", 'label' => "Term B2" },
19
- { 'id' => "Term B3", 'label' => "Term B3" } ] }
20
- it "should set the id to be same as the label" do
17
+ let(:expected) { [{ 'id' => "Term B1", 'label' => "Term B1" },
18
+ { 'id' => "Term B2", 'label' => "Term B2" },
19
+ { 'id' => "Term B3", 'label' => "Term B3" }] }
20
+ it "sets the id to be same as the label" do
21
21
  expect(authority_b.all).to eq(expected)
22
22
  end
23
23
  end
24
24
  context "authority YAML file is a list of terms" do
25
- let(:expected) { [ { 'id' => "Term C1", 'label' => "Term C1" },
26
- { 'id' => "Term C2", 'label' => "Term C2" },
27
- { 'id' => "Term C3", 'label' => "Term C3" } ] }
28
- it "should use the terms as labels" do
25
+ let(:expected) { [{ 'id' => "Term C1", 'label' => "Term C1" },
26
+ { 'id' => "Term C2", 'label' => "Term C2" },
27
+ { 'id' => "Term C3", 'label' => "Term C3" }] }
28
+ it "uses the terms as labels" do
29
29
  expect(authority_c.all).to eq(expected)
30
30
  end
31
31
  end
32
32
  context "YAML file is malformed" do
33
- it "should raise an error" do
33
+ it "raises an error" do
34
34
  expect { authority_d.all }.to raise_error Psych::SyntaxError
35
35
  end
36
36
  end
@@ -39,26 +39,26 @@ describe Qa::Authorities::Local::FileBasedAuthority do
39
39
  describe "#search" do
40
40
  context "with an empty query string" do
41
41
  let(:expected) { [] }
42
- it "should return no results" do
42
+ it "returns no results" do
43
43
  expect(authority_a.search("")).to eq(expected)
44
44
  end
45
45
  end
46
46
  context "with at least one matching entry" do
47
- let(:expected) { [ { 'id' => "A1", 'label' => "Abc Term A1" },
48
- { 'id' => "A3", 'label' => "Abc Term A3" } ] }
49
- it "should return only entries matching the query term" do
47
+ let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
48
+ { 'id' => "A3", 'label' => "Abc Term A3" }] }
49
+ it "returns only entries matching the query term" do
50
50
  expect(authority_a.search("Abc")).to eq(expected)
51
51
  end
52
- it "should match parts of words in the middle of the term" do
53
- expect(authority_a.search("Term A1")).to eq([{"id"=>"A1", "label"=>"Abc Term A1"}])
52
+ it "matches parts of words in the middle of the term" do
53
+ expect(authority_a.search("Term A1")).to eq([{ "id" => "A1", "label" => "Abc Term A1" }])
54
54
  end
55
- it "should be case insensitive" do
55
+ it "is case insensitive" do
56
56
  expect(authority_a.search("aBc")).to eq(expected)
57
57
  end
58
58
  end
59
59
  context "with no matching entries" do
60
60
  let(:expected) { [] }
61
- it "should return an empty array" do
61
+ it "returns an empty array" do
62
62
  expect(authority_a.search("def")).to eq(expected)
63
63
  end
64
64
  end
@@ -68,14 +68,14 @@ describe Qa::Authorities::Local::FileBasedAuthority do
68
68
  context "source is a hash" do
69
69
  let(:id) { "A2" }
70
70
  let(:expected) { { 'id' => "A2", 'term' => "Term A2", 'active' => false } }
71
- it "should return the full term record" do
71
+ it "returns the full term record" do
72
72
  record = authority_a.find(id)
73
73
  expect(record).to be_a HashWithIndifferentAccess
74
74
  expect(record).to eq(expected)
75
75
  end
76
76
  end
77
77
  context "source is a list" do
78
- it "should be indifferent access" do
78
+ it "is indifferent access" do
79
79
  record = authority_c.find("Term C1")
80
80
  expect(record).to be_a HashWithIndifferentAccess
81
81
  end
@@ -83,17 +83,16 @@ describe Qa::Authorities::Local::FileBasedAuthority do
83
83
  context "term does not exist" do
84
84
  let(:id) { "NonID" }
85
85
  let(:expected) { {} }
86
- it "should return an empty hash" do
86
+ it "returns an empty hash" do
87
87
  expect(authority_a.find(id)).to eq(expected)
88
88
  end
89
89
  end
90
90
  context "on a sub-authority" do
91
- it "should return the full term record" do
91
+ it "returns the full term record" do
92
92
  record = authority_a.find("A2")
93
93
  expect(record).to be_a HashWithIndifferentAccess
94
94
  expect(record).to eq('id' => "A2", 'term' => "Term A2", 'active' => false)
95
95
  end
96
96
  end
97
97
  end
98
-
99
98
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Geonames do
4
-
5
4
  before do
6
5
  described_class.username = 'dummy'
7
6
  end
@@ -21,8 +20,8 @@ describe Qa::Authorities::Geonames do
21
20
  describe "#search" do
22
21
  context "authorities" do
23
22
  before do
24
- stub_request(:get, /api\.geonames\.org.*/).
25
- to_return(:body => webmock_fixture("geonames-response.json"), status: 200)
23
+ stub_request(:get, /api\.geonames\.org.*/)
24
+ .to_return(body: webmock_fixture("geonames-response.json"), status: 200)
26
25
  end
27
26
 
28
27
  subject { authority.search('whatever') }
@@ -77,13 +76,13 @@ describe Qa::Authorities::Geonames do
77
76
  describe "#find" do
78
77
  context "using a subject id" do
79
78
  before do
80
- stub_request(:get, "http://www.geonames.org/getJSON?geonameId=2088122&username=dummy").
81
- to_return(status: 200, body: webmock_fixture("geonames-find-response.json"))
79
+ stub_request(:get, "http://www.geonames.org/getJSON?geonameId=2088122&username=dummy")
80
+ .to_return(status: 200, body: webmock_fixture("geonames-find-response.json"))
82
81
  end
83
82
  subject { authority.find("2088122") }
84
83
 
85
84
  it "returns the complete record for a given subject" do
86
- expect(subject['geonameId']).to eq 2088122
85
+ expect(subject['geonameId']).to eq 2_088_122
87
86
  expect(subject['name']).to eq "Port Moresby"
88
87
  end
89
88
  end
@@ -1,12 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Getty::AAT do
4
-
5
4
  let(:authority) { described_class.new }
6
5
 
7
6
  describe "#build_query_url" do
8
7
  subject { authority.build_query_url("foo") }
9
- it { is_expected.to match /^http:\/\/vocab\.getty\.edu\// }
8
+ it { is_expected.to match(/^http:\/\/vocab\.getty\.edu\//) }
10
9
  end
11
10
 
12
11
  describe "#find_url" do
@@ -17,13 +16,13 @@ describe Qa::Authorities::Getty::AAT do
17
16
  describe "#search" do
18
17
  context "authorities" do
19
18
  before do
20
- stub_request(:get, /vocab\.getty\.edu.*/).
21
- to_return(:body => webmock_fixture("aat-response.txt"), :status => 200)
19
+ stub_request(:get, /vocab\.getty\.edu.*/)
20
+ .to_return(body: webmock_fixture("aat-response.txt"), status: 200)
22
21
  end
23
22
 
24
23
  subject { authority.search('whatever') }
25
24
 
26
- it "should have id and label keys" do
25
+ it "has id and label keys" do
27
26
  expect(subject.first).to eq("id" => 'http://vocab.getty.edu/aat/300053264', "label" => "photocopying")
28
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/aat/300265560', "label" => "photoscreenprints")
29
28
  expect(subject.size).to eq(10)
@@ -48,8 +47,8 @@ describe Qa::Authorities::Getty::AAT do
48
47
  describe "#find" do
49
48
  context "using a subject id" do
50
49
  before do
51
- stub_request(:get, "http://vocab.getty.edu/aat/300265560.json").
52
- to_return(status: 200, body: webmock_fixture("getty-aat-find-response.json"))
50
+ stub_request(:get, "http://vocab.getty.edu/aat/300265560.json")
51
+ .to_return(status: 200, body: webmock_fixture("getty-aat-find-response.json"))
53
52
  end
54
53
  subject { authority.find("300265560") }
55
54
 
@@ -76,7 +75,4 @@ describe Qa::Authorities::Getty::AAT do
76
75
  FILTER regex(?name, "search_term", "i") .
77
76
  } ORDER BY ?name' }
78
77
  end
79
-
80
78
  end
81
-
82
-
@@ -1,12 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Getty::TGN do
4
-
5
4
  let(:authority) { described_class.new }
6
5
 
7
6
  describe "#build_query_url" do
8
7
  subject { authority.build_query_url("foo") }
9
- it { is_expected.to match /^http:\/\/vocab\.getty\.edu\// }
8
+ it { is_expected.to match(/^http:\/\/vocab\.getty\.edu\//) }
10
9
  end
11
10
 
12
11
  describe "#find_url" do
@@ -17,13 +16,13 @@ describe Qa::Authorities::Getty::TGN do
17
16
  describe "#search" do
18
17
  context "authorities" do
19
18
  before do
20
- stub_request(:get, /vocab\.getty\.edu.*/).
21
- to_return(:body => webmock_fixture("tgn-response.txt"), :status => 200)
19
+ stub_request(:get, /vocab\.getty\.edu.*/)
20
+ .to_return(body: webmock_fixture("tgn-response.txt"), status: 200)
22
21
  end
23
22
 
24
23
  subject { authority.search('whatever') }
25
24
 
26
- it "should have id and label keys" do
25
+ it "has id and label keys" do
27
26
  expect(subject.first).to eq("id" => 'http://vocab.getty.edu/tgn/2058300', "label" => "Cawood (Andrew, Missouri, United States)")
28
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/tgn/7022503', "label" => "Cawood Branch (Kentucky, United States)")
29
28
  expect(subject.size).to eq(6)
@@ -48,8 +47,8 @@ describe Qa::Authorities::Getty::TGN do
48
47
  describe "#find" do
49
48
  context "using a subject id" do
50
49
  before do
51
- stub_request(:get, "http://vocab.getty.edu/tgn/1028772.json").
52
- to_return(status: 200, body: webmock_fixture("getty-tgn-find-response.json"))
50
+ stub_request(:get, "http://vocab.getty.edu/tgn/1028772.json")
51
+ .to_return(status: 200, body: webmock_fixture("getty-tgn-find-response.json"))
53
52
  end
54
53
  subject { authority.find("1028772") }
55
54
 
@@ -89,7 +88,4 @@ describe Qa::Authorities::Getty::TGN do
89
88
  } ORDER BY ?name ASC(?par)" }
90
89
  end
91
90
  end
92
-
93
91
  end
94
-
95
-
@@ -1,12 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Getty::Ulan do
4
-
5
4
  let(:authority) { described_class.new }
6
5
 
7
6
  describe "#build_query_url" do
8
7
  subject { authority.build_query_url("foo") }
9
- it { is_expected.to match /^http:\/\/vocab\.getty\.edu\// }
8
+ it { is_expected.to match(/^http:\/\/vocab\.getty\.edu\//) }
10
9
  end
11
10
 
12
11
  describe "#find_url" do
@@ -17,13 +16,13 @@ describe Qa::Authorities::Getty::Ulan do
17
16
  describe "#search" do
18
17
  context "authorities" do
19
18
  before do
20
- stub_request(:get, /vocab\.getty\.edu.*/).
21
- to_return(:body => webmock_fixture("ulan-response.txt"), :status => 200)
19
+ stub_request(:get, /vocab\.getty\.edu.*/)
20
+ .to_return(body: webmock_fixture("ulan-response.txt"), status: 200)
22
21
  end
23
22
 
24
23
  subject { authority.search('whatever') }
25
24
 
26
- it "should have id and label keys" do
25
+ it "has id and label keys" do
27
26
  expect(subject.first).to eq("id" => 'http://vocab.getty.edu/ulan/500233743', "label" => "Alan Turner and Associates (British architectural firm, contemporary)")
28
27
  expect(subject.last).to eq("id" => 'http://vocab.getty.edu/ulan/500023812', "label" => "Warren, Charles Turner (English engraver, 1762-1823)")
29
28
  expect(subject.size).to eq(142)
@@ -48,8 +47,8 @@ describe Qa::Authorities::Getty::Ulan do
48
47
  describe "#find" do
49
48
  context "using a subject id" do
50
49
  before do
51
- stub_request(:get, "http://vocab.getty.edu/ulan/500026846.json").
52
- to_return(status: 200, body: webmock_fixture("getty-ulan-find-response.json"))
50
+ stub_request(:get, "http://vocab.getty.edu/ulan/500026846.json")
51
+ .to_return(status: 200, body: webmock_fixture("getty-ulan-find-response.json"))
53
52
  end
54
53
  subject { authority.find("500026846") }
55
54
 
@@ -91,7 +90,4 @@ describe Qa::Authorities::Getty::Ulan do
91
90
  } ORDER BY ?name" }
92
91
  end
93
92
  end
94
-
95
93
  end
96
-
97
-
@@ -1,28 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Qa::Authorities::Getty do
4
-
5
4
  describe "#new" do
6
- it "should raise an exception" do
5
+ it "raises an exception" 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
10
9
 
11
10
  describe "#subauthority_for" do
12
11
  context "without a sub-authority" do
13
- it "should raise an exception" do
12
+ it "raises an exception" do
14
13
  expect { described_class.subauthority_for }.to raise_error ArgumentError
15
14
  end
16
15
  end
17
16
 
18
17
  context "with an invalid sub-authority" do
19
- it "should raise an exception" do
18
+ it "raises an exception" do
20
19
  expect { described_class.subauthority_for("foo") }.to raise_error Qa::InvalidSubAuthority
21
20
  end
22
21
  end
23
22
 
24
23
  context "with a valid sub-authority" do
25
- it "should create the authority" do
24
+ it "creates the authority" do
26
25
  expect(described_class.subauthority_for("aat")).to be_kind_of Qa::Authorities::Getty::AAT
27
26
  end
28
27
  end