ddr-models 3.0.0.beta.3 → 3.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/config/locales/ddr-models.en.yml +74 -0
  4. data/ddr-models.gemspec +3 -2
  5. data/lib/ddr/auth.rb +5 -2
  6. data/lib/ddr/auth/roles.rb +0 -2
  7. data/lib/ddr/auth/roles/role_set.rb +1 -0
  8. data/lib/ddr/derivatives/generators/png_generator.rb +1 -1
  9. data/lib/ddr/index.rb +6 -2
  10. data/lib/ddr/index/abstract_query_result.rb +1 -1
  11. data/lib/ddr/index/csv_options.rb +14 -0
  12. data/lib/ddr/index/csv_query_result.rb +39 -32
  13. data/lib/ddr/index/field.rb +11 -1
  14. data/lib/ddr/index/field_attribute.rb +22 -0
  15. data/lib/ddr/index/fields.rb +29 -20
  16. data/lib/ddr/index/filter.rb +81 -30
  17. data/lib/ddr/index/filters.rb +15 -10
  18. data/lib/ddr/index/query.rb +34 -13
  19. data/lib/ddr/index/query_builder.rb +150 -30
  20. data/lib/ddr/index/query_clause.rb +64 -19
  21. data/lib/ddr/index/query_params.rb +40 -0
  22. data/lib/ddr/index/solr_csv_options.rb +18 -0
  23. data/lib/ddr/index/sort_order.rb +28 -0
  24. data/lib/ddr/jobs.rb +5 -1
  25. data/lib/ddr/jobs/fits_file_characterization.rb +3 -41
  26. data/lib/ddr/jobs/fixity_check.rb +13 -0
  27. data/lib/ddr/jobs/job.rb +36 -0
  28. data/lib/ddr/jobs/queue.rb +27 -0
  29. data/lib/ddr/jobs/update_index.rb +13 -0
  30. data/lib/ddr/models.rb +20 -3
  31. data/lib/ddr/models/admin_set.rb +7 -3
  32. data/lib/ddr/models/contact.rb +19 -0
  33. data/lib/ddr/models/error.rb +3 -0
  34. data/lib/ddr/models/file_characterization.rb +37 -0
  35. data/lib/ddr/models/finding_aid.rb +35 -2
  36. data/lib/ddr/models/has_admin_metadata.rb +5 -1
  37. data/lib/ddr/models/has_content.rb +4 -2
  38. data/lib/ddr/models/indexing.rb +7 -0
  39. data/lib/ddr/models/licenses/license.rb +7 -3
  40. data/lib/ddr/models/solr_document.rb +2 -2
  41. data/lib/ddr/models/version.rb +1 -1
  42. data/lib/ddr/models/with_content_file.rb +37 -0
  43. data/lib/ddr/vocab/asset.rb +3 -0
  44. data/spec/derivatives/png_generator_spec.rb +8 -1
  45. data/spec/fixtures/arrow1rightred_e0.gif +0 -0
  46. data/spec/index/fields_spec.rb +197 -0
  47. data/spec/index/filter_spec.rb +155 -30
  48. data/spec/index/query_builder_spec.rb +116 -0
  49. data/spec/index/query_clause_spec.rb +58 -0
  50. data/spec/index/query_spec.rb +39 -10
  51. data/spec/jobs/fits_file_characterization_spec.rb +7 -43
  52. data/spec/jobs/fixity_check_spec.rb +22 -0
  53. data/spec/jobs/job_spec.rb +40 -0
  54. data/spec/jobs/update_index_spec.rb +22 -0
  55. data/spec/managers/derivatives_manager_spec.rb +15 -11
  56. data/spec/models/admin_set_spec.rb +28 -10
  57. data/spec/models/contact_spec.rb +42 -0
  58. data/spec/models/effective_license_spec.rb +17 -7
  59. data/spec/models/file_characterization_spec.rb +38 -0
  60. data/spec/models/finding_aid_spec.rb +31 -8
  61. data/spec/models/has_admin_metadata_spec.rb +8 -5
  62. data/spec/models/indexing_spec.rb +2 -0
  63. data/spec/models/license_spec.rb +31 -10
  64. data/spec/models/solr_document_spec.rb +23 -3
  65. data/spec/models/with_content_file_spec.rb +32 -0
  66. data/spec/spec_helper.rb +2 -0
  67. metadata +66 -28
  68. data/lib/ddr/contacts.rb +0 -25
  69. data/lib/ddr/index/query_value.rb +0 -18
  70. data/lib/ddr/models/access_controllable.rb +0 -12
  71. data/spec/auth/ldap_gateway_spec.rb +0 -9
  72. data/spec/contacts/contacts_spec.rb +0 -26
  73. data/spec/index/filters_spec.rb +0 -17
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Ddr::Jobs
4
+ RSpec.describe FixityCheck do
5
+
6
+ it "should use the :fixity queue" do
7
+ expect(described_class.queue).to eq(:fixity)
8
+ end
9
+
10
+ describe ".perform" do
11
+ let!(:obj) { double(fixity_check: nil) }
12
+ before do
13
+ allow(ActiveFedora::Base).to receive(:find).with("test:1") { obj }
14
+ end
15
+ it "should call `fixity_check` on the object" do
16
+ expect(obj).to receive(:fixity_check)
17
+ described_class.perform("test:1")
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ module Ddr::Jobs
2
+ RSpec.describe Job do
3
+
4
+ before(:all) do
5
+ class TestJob
6
+ extend Job
7
+
8
+ @queue = :test
9
+
10
+ def perform(object_id)
11
+ puts object_id
12
+ end
13
+ end
14
+ end
15
+
16
+ after(:all) do
17
+ Ddr::Jobs.send(:remove_const, :TestJob)
18
+ end
19
+
20
+ let(:queued) do
21
+ [{"class"=>"Ddr::Jobs::TestJob", "args"=>["test-1"]},
22
+ {"class"=>"Ddr::Jobs::OtherJob", "args"=>["test-2"]},
23
+ {"class"=>"Ddr::Jobs::TestJob", "args"=>["test-3"]},
24
+ ]
25
+ end
26
+
27
+ before(:each) do
28
+ allow(Resque).to receive(:size).with(:test) { 3 }
29
+ allow(Resque).to receive(:peek).with(:test, 0, 3) { queued }
30
+ end
31
+
32
+ describe ".queued_object_ids" do
33
+ it "returns the list of object_ids for queued jobs of this type" do
34
+ expect(TestJob.queued_object_ids)
35
+ .to contain_exactly("test-1", "test-3")
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Ddr::Jobs
4
+ RSpec.describe UpdateIndex do
5
+
6
+ it "should use the :index queue" do
7
+ expect(described_class.queue).to eq(:index)
8
+ end
9
+
10
+ describe ".perform" do
11
+ let!(:obj) { double(update_index: nil) }
12
+ before do
13
+ allow(ActiveFedora::Base).to receive(:find).with("test:1") { obj }
14
+ end
15
+ it "should call `update_index` on the object" do
16
+ expect(obj).to receive(:update_index)
17
+ described_class.perform("test:1")
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -28,7 +28,7 @@ module Ddr
28
28
  context "all derivatives" do
29
29
  context "not multires_image_able" do
30
30
  let(:object) { ContentBearing.new }
31
- context "content is image" do
31
+ context "content is an image" do
32
32
  let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
33
33
  it "should generate a thumbnail and not a ptif" do
34
34
  expect(object.derivatives).to receive(:generate_derivative).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
@@ -36,15 +36,7 @@ module Ddr
36
36
  object.derivatives.update_derivatives(:now)
37
37
  end
38
38
  end
39
- # context "content is a PDF" do
40
- # let(:file) { fixture_file_upload("sample.pdf", "application/pdf") }
41
- # it "should generate a thumbnail and not a ptif" do
42
- # expect(object.derivatives).to receive(:generate_derivative).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
43
- # expect(object.derivatives).to_not receive(:generate_derivative).with(Ddr::Derivatives::DERIVATIVES[:multires_image])
44
- # object.derivatives.update_derivatives(:now)
45
- # end
46
- # end
47
- context "content is neither an image nor a PDF" do
39
+ context "content is not an image" do
48
40
  let(:file) { fixture_file_upload("sample.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document") }
49
41
  it "should generate neither a thumbnail nor a ptif" do
50
42
  expect(object.derivatives).to_not receive(:generate_derivative).with(Ddr::Derivatives::DERIVATIVES[:thumbnail])
@@ -85,7 +77,7 @@ module Ddr
85
77
  object.derivatives.update_derivatives(:now)
86
78
  end
87
79
  end
88
- end
80
+ end
89
81
 
90
82
  describe "derivative generation" do
91
83
  let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
@@ -120,6 +112,18 @@ end
120
112
  end
121
113
  end
122
114
 
115
+ describe "exception during derivative generation" do
116
+ let(:object) { ContentBearing.create }
117
+ before do
118
+ allow(Dir::Tmpname).to receive(:make_tmpname).with('', nil) { 'test-temp-dir' }
119
+ # simulate raising of exception during derivative generation
120
+ allow_any_instance_of(Ddr::Managers::DerivativesManager).to receive(:generate_derivative).and_raise(StandardError)
121
+ end
122
+ it "should delete the temporary work directory" do
123
+ expect(File.exist?(File.join(Dir.tmpdir, 'test-temp-dir'))).to be false
124
+ end
125
+ end
126
+
123
127
  end
124
128
  end
125
129
  end
@@ -1,25 +1,43 @@
1
1
  module Ddr::Models
2
- RSpec.describe AdminSet do
2
+ RSpec.describe AdminSet, ddr_aux: true do
3
3
 
4
4
  describe ".call" do
5
- subject { described_class.call(obj) }
5
+ let(:obj) { Item.new }
6
6
 
7
7
  describe "when the object has an admin set" do
8
- let(:obj) { double(admin_set: "dvs") }
9
- before do
10
- allow(described_class).to receive(:find).with(code: "dvs") do
11
- described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z")
8
+ before { obj.admin_set = "dvs" }
9
+ describe "and the admin set code is found" do
10
+ before {
11
+ allow(described_class).to receive(:get).with(:find, code: "dvs") {
12
+ {"id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z"}
13
+ }
14
+ }
15
+ it "returns an AdminSet instance" do
16
+ expect(described_class.call(obj)).to be_a(described_class)
17
+ end
18
+ end
19
+ describe "and the admin set is not found" do
20
+ before {
21
+ allow(described_class).to receive(:get).with(:find, code: "dvs")
22
+ .and_raise(ActiveResource::ResourceNotFound, "404")
23
+ }
24
+ it "raises an exception" do
25
+ expect { described_class.call(obj) }.to raise_error(Ddr::Models::NotFoundError)
12
26
  end
13
27
  end
14
-
15
- its(:to_s) { is_expected.to eq("Data and Visualization Services") }
16
28
  end
17
29
 
18
30
  describe "when the object does not have an admin set" do
19
- let(:obj) { double(admin_set: nil) }
20
- it { is_expected.to be_nil }
31
+ it "returns nil" do
32
+ expect(described_class.call(obj)).to be_nil
33
+ end
21
34
  end
22
35
  end
23
36
 
37
+ describe "instance methods" do
38
+ subject { described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z") }
39
+ its(:to_s) { is_expected.to eq("Data and Visualization Services") }
40
+ end
41
+
24
42
  end
25
43
  end
@@ -0,0 +1,42 @@
1
+ module Ddr::Models
2
+ RSpec.describe Contact, ddr_aux: true do
3
+
4
+ describe ".call" do
5
+ describe "when the slug is found" do
6
+ before {
7
+ allow(described_class).to receive(:get).with(:find, slug: "abc") {
8
+ {"id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
9
+ "url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
10
+ "ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
11
+ "updated_at"=>"2015-09-15T16:15:58.514Z"}
12
+ }
13
+ }
14
+ it "returns a Contact instance" do
15
+ expect(described_class.call("abc")).to be_a(described_class)
16
+ end
17
+ end
18
+ describe "when the slug is not found" do
19
+ before {
20
+ allow(described_class).to receive(:get).with(:find, slug: "abc")
21
+ .and_raise(ActiveResource::ResourceNotFound, "404")
22
+ }
23
+ it "raises an exception" do
24
+ expect { described_class.call("abc") }.to raise_error(Ddr::Models::NotFoundError)
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "instance methods" do
30
+ subject {
31
+ described_class.new(
32
+ "id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
33
+ "url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
34
+ "ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
35
+ "updated_at"=>"2015-09-15T16:15:58.514Z"
36
+ )
37
+ }
38
+ its(:to_s) { is_expected.to eq("A, B, and C Services") }
39
+ end
40
+
41
+ end
42
+ end
@@ -6,34 +6,41 @@ module Ddr::Models
6
6
  let(:url) { "https://creativecommons.org/licenses/by-nc-nd/4.0/" }
7
7
 
8
8
  let(:license) { License.new(url: url) }
9
- before { allow(License).to receive(:find).with(url: url) { license } }
10
9
 
11
- let(:obj) { double(id: "test-1", license: nil, parent: nil, admin_policy: nil, admin_policy_id: nil) }
10
+ let(:obj) { Component.new(pid: "test:1") }
11
+ let(:parent) { Item.new(pid: "test:2") }
12
+ let(:admin_policy) { Collection.new(pid: "test:3") }
12
13
 
13
14
  describe "when the object has a license" do
14
- before { allow(obj).to receive(:license) { url } }
15
+ before do
16
+ allow(License).to receive(:call).with(obj) { license }
17
+ end
15
18
  it { is_expected.to eq(license) }
16
19
  end
17
20
 
18
21
  describe "when the object does not have a license" do
22
+ before do
23
+ allow(License).to receive(:call).with(obj) { nil }
24
+ end
19
25
  describe "and the object has a parent" do
20
- let(:parent) { double(id: "test-2", license: nil) }
21
26
  before do
22
27
  allow(obj).to receive(:parent) { parent }
23
28
  end
24
29
  describe "and the parent has a license" do
25
30
  before do
26
- allow(parent).to receive(:license) { url }
31
+ allow(License).to receive(:call).with(parent) { license }
27
32
  end
28
33
  it { is_expected.to eq(license) }
29
34
  end
30
35
  describe "and the parent does not have a license" do
36
+ before do
37
+ allow(License).to receive(:call).with(parent) { nil }
38
+ end
31
39
  it { is_expected.to be_nil }
32
40
  end
33
41
  end
34
42
  describe "and the object does not have a parent" do
35
43
  describe "and the object has an admin policy" do
36
- let(:admin_policy) { double(id: "test-3", license: nil) }
37
44
  before { allow(obj).to receive(:admin_policy) { admin_policy } }
38
45
  describe "and the admin policy has a different id from the object" do
39
46
  before do
@@ -41,11 +48,14 @@ module Ddr::Models
41
48
  end
42
49
  describe "and the admin policy has a license" do
43
50
  before do
44
- allow(admin_policy).to receive(:license) { url }
51
+ allow(License).to receive(:call).with(admin_policy) { license }
45
52
  end
46
53
  it { is_expected.to eq(license) }
47
54
  end
48
55
  describe "and the admin policy does not have a license" do
56
+ before do
57
+ allow(License).to receive(:call).with(admin_policy) { nil }
58
+ end
49
59
  it { is_expected.to be_nil }
50
60
  end
51
61
  end
@@ -0,0 +1,38 @@
1
+ module Ddr::Models
2
+ RSpec.describe FileCharacterization do
3
+
4
+ subject { described_class.new(obj) }
5
+
6
+ let(:obj) { FactoryGirl.create(:component) }
7
+ let(:fits_output) { "<fits/>" }
8
+
9
+ before {
10
+ allow(subject).to receive(:with_content_file).and_yield("/tmp/foobar")
11
+ }
12
+
13
+ describe "when there is an error running FITS" do
14
+ before {
15
+ allow(subject).to receive(:run_fits).with("/tmp/foobar").and_raise(FileCharacterization::FITSError)
16
+ }
17
+ specify {
18
+ begin
19
+ subject.call
20
+ rescue FileCharacterization::FITSError
21
+ ensure
22
+ expect(subject.fits).not_to have_content
23
+ end
24
+ }
25
+ end
26
+
27
+ describe "when FITS runs successfully" do
28
+ before {
29
+ allow(subject).to receive(:run_fits).with("/tmp/foobar") { fits_output }
30
+ }
31
+ specify {
32
+ subject.call
33
+ expect(subject.fits.content).to eq(fits_output)
34
+ }
35
+ end
36
+
37
+ end
38
+ end
@@ -15,15 +15,32 @@ module Ddr::Models
15
15
  findaidstatus="published"
16
16
  langencoding="iso639-2b"
17
17
  repositoryencoding="iso15511">
18
- <eadid url="http://example.com/ead/">ead</eadid>
19
- <filedesc>
20
- <titlestmt>
21
- <titleproper>Guide to the Perplexed
22
- <num>00001</num>
23
- </titleproper>
24
- </titlestmt>
25
- </filedesc>
18
+ <eadid url="http://example.com/ead/">ead</eadid>
19
+ <filedesc>
20
+ <titlestmt>
21
+ <titleproper>Guide to the Perplexed
22
+ <num>00001</num>
23
+ </titleproper>
24
+ </titlestmt>
25
+ </filedesc>
26
26
  </eadheader>
27
+ <archdesc level="collection">
28
+ <did>
29
+ <repository>
30
+ <corpname>Library of the Perplexed</corpname>
31
+ </repository>
32
+ <unittitle>Perplexities</unittitle>
33
+ <unitid>RL.00327</unitid>
34
+ <physdesc altrender="whole">
35
+ <extent altrender="materialtype spaceoccupied">6.5 Linear Feet</extent>
36
+ </physdesc>
37
+ <unitdate normal="1876/1953" type="inclusive">1876-1953</unitdate>
38
+ <abstract>Abstract of Perplexities.</abstract>
39
+ <physdesc id="aspace_foobar">
40
+ <extent>4000 Items</extent>
41
+ </physdesc>
42
+ </did>
43
+ </archdesc>
27
44
  </ead>
28
45
  EOS
29
46
  end
@@ -34,6 +51,12 @@ EOS
34
51
 
35
52
  its(:title) { is_expected.to eq("Guide to the Perplexed") }
36
53
  its(:url) { is_expected.to eq("http://example.com/ead/") }
54
+ its(:repository) { is_expected.to eq("Library of the Perplexed") }
55
+ its(:collection_date_span) { is_expected.to eq("1876-1953") }
56
+ its(:collection_number) { is_expected.to eq("RL.00327") }
57
+ its(:collection_title) { is_expected.to eq("Perplexities") }
58
+ its(:extent) { is_expected.to eq("6.5 Linear Feet; 4000 Items") }
59
+ its(:abstract) { is_expected.to eq("Abstract of Perplexities.") }
37
60
 
38
61
  end
39
62
  end
@@ -178,14 +178,17 @@ module Ddr::Models
178
178
 
179
179
  describe "contacts" do
180
180
  before do
181
- allow(YAML).to receive(:load_file) { { 'a' => { 'name' => 'Contact A', 'short_name' => 'A' },
182
- 'b' => { 'name' => 'Contact B', 'short_name' => 'B' } } }
183
- Ddr::Contacts.load_contacts
181
+ allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'xa') do
182
+ {'id'=>1, 'slug'=>'xa', 'name'=>'Contact A', 'short_name'=>'A'}
183
+ end
184
+ allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'yb') do
185
+ {'id'=>1, 'slug'=>'yb', 'name'=>'Contact B', 'short_name'=>'B'}
186
+ end
184
187
  end
185
188
  describe "#research_help" do
186
- before { subject.research_help_contact = 'b' }
189
+ before { subject.research_help_contact = 'yb' }
187
190
  it "should return the appropriate contact" do
188
- expect(subject.research_help.slug).to eq('b')
191
+ expect(subject.research_help.slug).to eq('yb')
189
192
  end
190
193
  end
191
194
  end
@@ -18,6 +18,7 @@ module Ddr::Models
18
18
  obj.permanent_url = "http://id.library.duke.edu/ark:/99999/fk4zzz"
19
19
  obj.display_format = "Image"
20
20
  obj.roles.grant role1, role2, role3, role4
21
+ obj.aspace_id = "aspace_dccea43034e1b8261e14cf999e86449d"
21
22
  obj.fcrepo3_pid = "duke:1"
22
23
  end
23
24
 
@@ -28,6 +29,7 @@ module Ddr::Models
28
29
  its([Indexing::PERMANENT_URL]) { is_expected.to eq("http://id.library.duke.edu/ark:/99999/fk4zzz") }
29
30
  its([Indexing::DISPLAY_FORMAT]) { is_expected.to eq("Image") }
30
31
  its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
32
+ its([Indexing::ASPACE_ID]) { is_expected.to eq("aspace_dccea43034e1b8261e14cf999e86449d") }
31
33
  its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent, role3.agent, role4.agent) }
32
34
  its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent) }
33
35
  its([Indexing::FCREPO3_PID]) { is_expected.to eq("duke:1") }
@@ -1,24 +1,45 @@
1
1
  module Ddr::Models
2
- RSpec.describe License do
2
+ RSpec.describe License, ddr_aux: true do
3
3
 
4
4
  describe ".call" do
5
- subject { described_class.call(obj) }
6
-
7
5
  describe "when the object has a license URL" do
8
- let(:url) { "http://example.com" }
9
- let(:obj) { double(id: "test-1", license: url) }
10
- before do
11
- allow(described_class).to receive(:find).with(url: url) { described_class.new(url: url, title: "A License") }
6
+ let(:obj) { double(id: "test-1", license: "http://example.com") }
7
+ describe "and the license is found" do
8
+ before {
9
+ allow(described_class).to receive(:get).with(:find, url: "http://example.com") {
10
+ {"id"=>1, "url"=>"http://example.com", "title"=>"A License"}
11
+ }
12
+ }
13
+ it "returns a License instance" do
14
+ expect(described_class.call(obj)).to be_a(described_class)
15
+ end
16
+ it "sets `object_id` to the object id" do
17
+ expect(described_class.call(obj).object_id).to eq("test-1")
18
+ end
19
+ end
20
+ describe "and the license is not found" do
21
+ before {
22
+ allow(described_class).to receive(:get).with(:find, url: "http://example.com")
23
+ .and_raise(ActiveResource::ResourceNotFound, "404")
24
+ }
25
+ it "raises an exception" do
26
+ expect { described_class.call(obj) }.to raise_error(Ddr::Models::NotFoundError)
27
+ end
12
28
  end
13
- its(:pid) { is_expected.to eq("test-1") }
14
- its(:to_s) { is_expected.to eq("A License") }
15
29
  end
16
30
 
17
31
  describe "when the object does not have a license" do
18
32
  let(:obj) { double(id: "test-1", license: nil) }
19
- it { is_expected.to be_nil }
33
+ it "returns nil" do
34
+ expect(described_class.call(obj)).to be_nil
35
+ end
20
36
  end
21
37
  end
22
38
 
39
+ describe "instance methods" do
40
+ subject { described_class.new("id"=>1, "url"=>"http://example.com", "title"=>"A License") }
41
+ its(:to_s) { is_expected.to eq("A License") }
42
+ end
43
+
23
44
  end
24
45
  end