hydra-works 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.travis.yml +2 -5
  4. data/Gemfile +1 -3
  5. data/README.md +28 -13
  6. data/hydra-works.gemspec +4 -3
  7. data/lib/hydra/works.rb +7 -57
  8. data/lib/hydra/works/models/concerns/block_child_objects.rb +16 -0
  9. data/lib/hydra/works/models/concerns/collection_behavior.rb +27 -2
  10. data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +5 -13
  11. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +9 -13
  12. data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +14 -9
  13. data/lib/hydra/works/models/concerns/generic_file/versioned_content.rb +18 -0
  14. data/lib/hydra/works/models/concerns/generic_file/virus_check.rb +48 -0
  15. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +24 -1
  16. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +32 -3
  17. data/lib/hydra/works/models/generic_file.rb +3 -0
  18. data/lib/hydra/works/services/generic_file/add_file_to_generic_file.rb +127 -0
  19. data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +1 -2
  20. data/lib/hydra/works/services/generic_file/persist_derivative.rb +22 -0
  21. data/lib/hydra/works/services/generic_file/upload_file.rb +11 -19
  22. data/lib/hydra/works/version.rb +1 -1
  23. data/lib/hydra/works/vocab/works_terms.rb +1 -1
  24. data/spec/fixtures/Example.ogg +0 -0
  25. data/spec/fixtures/charter.docx +0 -0
  26. data/spec/fixtures/countdown.avi +0 -0
  27. data/spec/fixtures/image.jp2 +0 -0
  28. data/spec/fixtures/piano_note.wav +0 -0
  29. data/spec/fixtures/test5.mp3 +0 -0
  30. data/spec/fixtures/world.png +0 -0
  31. data/spec/hydra/works/models/collection_spec.rb +499 -16
  32. data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +19 -0
  33. data/spec/hydra/works/models/concerns/{file → generic_file}/contained_files_spec.rb +20 -17
  34. data/spec/hydra/works/models/concerns/generic_file/mime_types_spec.rb +76 -0
  35. data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +32 -0
  36. data/spec/hydra/works/models/concerns/generic_file/virus_check_spec.rb +50 -0
  37. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +1 -1
  38. data/spec/hydra/works/models/generic_file_spec.rb +201 -14
  39. data/spec/hydra/works/models/generic_work_spec.rb +530 -14
  40. data/spec/hydra/works/services/generic_file/add_file_to_generic_file_spec.rb +110 -0
  41. data/spec/hydra/works/services/generic_file/upload_file_spec.rb +45 -28
  42. data/spec/hydra/works/services/persist_derivatives_spec.rb +93 -0
  43. data/spec/hydra/works_spec.rb +35 -35
  44. data/spec/spec_helper.rb +6 -0
  45. metadata +56 -95
  46. data/lib/hydra/works/models/concerns/aggregates_collections.rb +0 -16
  47. data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +0 -20
  48. data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +0 -20
  49. data/lib/hydra/works/processor.rb +0 -9
  50. data/lib/hydra/works/services/collection/add_collection.rb +0 -19
  51. data/lib/hydra/works/services/collection/add_generic_work.rb +0 -19
  52. data/lib/hydra/works/services/collection/add_related_object.rb +0 -19
  53. data/lib/hydra/works/services/collection/get_collections.rb +0 -17
  54. data/lib/hydra/works/services/collection/get_generic_works.rb +0 -17
  55. data/lib/hydra/works/services/collection/get_related_objects.rb +0 -17
  56. data/lib/hydra/works/services/collection/remove_collection.rb +0 -19
  57. data/lib/hydra/works/services/collection/remove_generic_work.rb +0 -20
  58. data/lib/hydra/works/services/collection/remove_related_object.rb +0 -19
  59. data/lib/hydra/works/services/generic_file/add_file.rb +0 -55
  60. data/lib/hydra/works/services/generic_file/add_generic_file.rb +0 -19
  61. data/lib/hydra/works/services/generic_file/add_original_file.rb +0 -11
  62. data/lib/hydra/works/services/generic_file/add_related_object.rb +0 -19
  63. data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +0 -10
  64. data/lib/hydra/works/services/generic_file/get_generic_files.rb +0 -17
  65. data/lib/hydra/works/services/generic_file/get_related_objects.rb +0 -17
  66. data/lib/hydra/works/services/generic_file/remove_generic_file.rb +0 -20
  67. data/lib/hydra/works/services/generic_file/remove_related_object.rb +0 -19
  68. data/lib/hydra/works/services/generic_work/add_generic_file.rb +0 -19
  69. data/lib/hydra/works/services/generic_work/add_generic_work.rb +0 -19
  70. data/lib/hydra/works/services/generic_work/add_related_object.rb +0 -19
  71. data/lib/hydra/works/services/generic_work/get_generic_files.rb +0 -17
  72. data/lib/hydra/works/services/generic_work/get_generic_works.rb +0 -17
  73. data/lib/hydra/works/services/generic_work/get_related_objects.rb +0 -17
  74. data/lib/hydra/works/services/generic_work/move_generic_file.rb +0 -19
  75. data/lib/hydra/works/services/generic_work/remove_generic_file.rb +0 -20
  76. data/lib/hydra/works/services/generic_work/remove_generic_work.rb +0 -20
  77. data/lib/hydra/works/services/generic_work/remove_related_object.rb +0 -19
  78. data/spec/hydra/works/services/collection/add_collection_spec.rb +0 -166
  79. data/spec/hydra/works/services/collection/add_generic_work_spec.rb +0 -155
  80. data/spec/hydra/works/services/collection/add_related_object_spec.rb +0 -149
  81. data/spec/hydra/works/services/collection/get_collections_spec.rb +0 -35
  82. data/spec/hydra/works/services/collection/get_generic_works_spec.rb +0 -35
  83. data/spec/hydra/works/services/collection/get_related_objects_spec.rb +0 -49
  84. data/spec/hydra/works/services/collection/remove_collection_spec.rb +0 -133
  85. data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +0 -133
  86. data/spec/hydra/works/services/collection/remove_related_object_spec.rb +0 -128
  87. data/spec/hydra/works/services/generic_file/add_file_spec.rb +0 -28
  88. data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +0 -174
  89. data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +0 -150
  90. data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +0 -19
  91. data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +0 -45
  92. data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +0 -124
  93. data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +0 -123
  94. data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +0 -156
  95. data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +0 -157
  96. data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +0 -148
  97. data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +0 -35
  98. data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +0 -35
  99. data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +0 -46
  100. data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +0 -21
  101. data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +0 -132
  102. data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +0 -133
  103. data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +0 -128
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hydra::Works::AddFileToGenericFile do
4
+
5
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
6
+ let(:filename) { "sample-file.pdf" }
7
+ let(:filename2) { "updated-file.txt" }
8
+ let(:original_name) { "original-name.pdf" }
9
+ let(:file) { File.open(File.join(fixture_path, filename)) }
10
+ let(:file2) { File.open(File.join(fixture_path, filename2)) }
11
+ let(:type) { ::RDF::URI("http://pcdm.org/use#ExtractedText") }
12
+ let(:update_existing) { true }
13
+ let(:mime_type) { "application/pdf" }
14
+
15
+ context "when generic_file is not persisted" do
16
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
17
+ it "saves generic_file" do
18
+ described_class.call(generic_file, file, type)
19
+ expect(generic_file.persisted?).to be true
20
+ end
21
+ end
22
+
23
+ context "when generic_file is not valid" do
24
+ before do
25
+ generic_file.save
26
+ allow(generic_file).to receive(:valid?).and_return(false)
27
+ end
28
+ it "returns false" do
29
+ expect( described_class.call(generic_file, file, type) ).to be false
30
+ end
31
+ end
32
+
33
+ context "file responds to :mime_type and :original_name" do
34
+ before do
35
+ allow(file).to receive(:mime_type).and_return(mime_type)
36
+ allow(file).to receive(:original_name).and_return(original_name)
37
+ described_class.call(generic_file, file, type)
38
+ end
39
+ subject { generic_file.filter_files_by_type(type).first }
40
+ it "uses the mime_type and original_name methods" do
41
+ expect(subject.mime_type).to eq(mime_type)
42
+ expect(subject.original_name).to eq(original_name)
43
+ end
44
+ end
45
+
46
+ context "file responds to :path but not to :mime_type nor :original_name" do
47
+ it "defaults to Hydra::PCDM for mimetype and ::File for basename." do
48
+ expect(Hydra::PCDM::GetMimeTypeForFile).to receive(:call).with(file.path)
49
+ expect(::File).to receive(:basename).with(file.path)
50
+ described_class.call(generic_file, file, type)
51
+ end
52
+ end
53
+
54
+ it "adds the given file and applies the specified type to it" do
55
+ described_class.call(generic_file, file, type, update_existing: update_existing)
56
+ expect(generic_file.filter_files_by_type(type).first.content).to start_with("%PDF-1.3")
57
+ end
58
+
59
+ context "when :type is the name of an association" do
60
+ let(:type) { :extracted_text }
61
+ before do
62
+ described_class.call(generic_file, file, type)
63
+ end
64
+ it "builds and uses the association's target" do
65
+ expect(generic_file.extracted_text.content).to start_with("%PDF-1.3")
66
+ end
67
+ end
68
+
69
+ context "when :versioning => true" do
70
+ let(:type) { :original_file }
71
+ let(:versioning) { true }
72
+ subject { generic_file }
73
+ it "updates the file and creates a version" do
74
+ described_class.call(generic_file, file, type, versioning: versioning)
75
+ expect(subject.original_file.versions.all.count).to eq(1)
76
+ expect(subject.original_file.content).to start_with("%PDF-1.3")
77
+ end
78
+ context "and there are already versions" do
79
+ before do
80
+ described_class.call(generic_file, file, type, versioning: versioning)
81
+ described_class.call(generic_file, file2, type, versioning: versioning)
82
+ end
83
+ it "adds to the version history" do
84
+ expect(subject.original_file.versions.all.count).to eq(2)
85
+ expect(subject.original_file.content).to eq("some updated content\n")
86
+ end
87
+ end
88
+ end
89
+
90
+ context "when :versioning => false" do
91
+ let(:type) { :original_file }
92
+ let(:versioning) { false }
93
+ before do
94
+ described_class.call(generic_file, file, type, versioning: versioning)
95
+ end
96
+ subject { generic_file }
97
+ it "skips creating versions" do
98
+ expect(subject.original_file.versions.all.count).to eq(0)
99
+ expect(subject.original_file.content).to start_with("%PDF-1.3")
100
+ end
101
+ end
102
+
103
+ context "type_to_uri" do
104
+ subject { Hydra::Works::AddFileToGenericFile::Updater.allocate }
105
+ it "converts URI strings to RDF::URI" do
106
+ expect(subject.send(:type_to_uri, "http://example.com/CustomURI" )).to eq(::RDF::URI("http://example.com/CustomURI"))
107
+ end
108
+ end
109
+
110
+ end
@@ -2,39 +2,45 @@ require 'spec_helper'
2
2
 
3
3
  describe Hydra::Works::UploadFileToGenericFile do
4
4
 
5
- let(:generic_work) { Hydra::Works::GenericWork::Base.create }
6
- let(:generic_file) { Hydra::Works::GenericFile::Base.create }
7
- let(:filename) { "sample-file.pdf" }
8
- let(:file) { File.join(fixture_path, filename) }
9
- let(:updated_filename) { "updated-file.txt"}
10
- let(:updated_file) { File.join(fixture_path, updated_filename) }
5
+ let(:generic_work) { Hydra::Works::GenericWork::Base.new }
6
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
7
+ let(:file) { File.open(File.join(fixture_path, "sample-file.pdf")) }
8
+ let(:updated_file) { File.open(File.join(fixture_path, "updated-file.txt")) }
11
9
  let(:mime_type) { "application/pdf" }
12
- let(:updated_mime_type) { "text/plain" }
10
+ let(:original_name) { "my_original.pdf" }
11
+ let(:updated_mime_type) { "text/plain" }
12
+ let(:updated_name) { "my_updated.txt" }
13
13
  let(:additional_services) { [Hydra::Works::GenerateThumbnail] }
14
14
 
15
- context "without a proper generic file" do
16
- let(:error_message) { "supplied object must be a generic file" }
17
- it "raises an error" do
18
- expect( lambda { described_class.call(generic_work, file) }).to raise_error(ArgumentError, error_message)
15
+ context "when you provide mime_type and original_name, etc" do
16
+ it "uses the provided values" do
17
+ expect(Hydra::Works::AddFileToGenericFile).to receive(:call).with(generic_file, file, :original_file, update_existing: true, versioning: true )
18
+ described_class.call(generic_file, file )
19
19
  end
20
20
  end
21
21
 
22
- context "without a proper path" do
23
- let(:error_message) { "supplied path must be a string" }
22
+ # Duplicate test from add_file_spec
23
+ context "without a proper generic file" do
24
+ let(:error_message) { "supplied object must be a generic file" }
24
25
  it "raises an error" do
25
- expect( lambda { described_class.call(generic_file, ["this isn't a path"]) }).to raise_error(ArgumentError, error_message)
26
+ expect( lambda { described_class.call(generic_work, file) }).to raise_error(ArgumentError, error_message)
26
27
  end
27
28
  end
28
29
 
29
- context "with a non-existent file" do
30
- let(:error_message) { "supplied path to file does not exist" }
30
+ # Duplicate test from add_file_spec
31
+ context "without file that responds to read." do
32
+ let(:error_message) { "supplied file must respond to read" }
31
33
  it "raises an error" do
32
- expect( lambda { described_class.call(generic_file, "/i/do/not/exist") }).to raise_error(ArgumentError, error_message)
34
+ expect( lambda { described_class.call(generic_file, ["this does not respond to read."]) }).to raise_error(ArgumentError, error_message)
33
35
  end
34
36
  end
35
37
 
36
38
  context "with an empty generic file" do
37
- before { described_class.call(generic_file, file, additional_services) }
39
+ before do
40
+ allow(file).to receive(:mime_type).and_return(mime_type)
41
+ allow(file).to receive(:original_name).and_return(original_name)
42
+ described_class.call(generic_file, file, additional_services: additional_services)
43
+ end
38
44
 
39
45
  describe "the uploaded file" do
40
46
  subject { generic_file.original_file }
@@ -45,38 +51,49 @@ describe Hydra::Works::UploadFileToGenericFile do
45
51
  expect(subject.mime_type).to eql mime_type
46
52
  end
47
53
  it "has a name" do
48
- expect(subject.original_name).to eql filename
54
+ expect(subject.original_name).to eql original_name
49
55
  end
50
56
  end
51
57
 
52
58
  describe "the generic file's generated files" do
53
59
  subject { generic_file }
54
- it "has a thumbnail" do
60
+ it "has content and generated files" do
61
+ expect(subject.original_file.content).to start_with("%PDF-1.3")
62
+ expect(subject.original_file.mime_type).to eql mime_type
63
+ expect(subject.original_file.original_name).to eql original_name
55
64
  expect(subject.thumbnail.content).not_to be_nil
56
65
  end
57
66
  end
58
67
  end
59
68
 
60
- context "when replacing an existing file" do
69
+ context "when updating an existing file" do
70
+ let(:additional_services) { [] }
71
+
61
72
  before do
62
- described_class.call(generic_file, file, additional_services)
63
- described_class.call(generic_file, updated_file, additional_services, replace: true)
64
- generic_file.reload
73
+ allow(file).to receive(:mime_type).and_return(mime_type)
74
+ allow(file).to receive(:original_name).and_return(original_name)
75
+ allow(updated_file).to receive(:mime_type).and_return(updated_mime_type)
76
+ allow(updated_file).to receive(:original_name).and_return(updated_name)
77
+
78
+ described_class.call(generic_file, file, additional_services: additional_services)
79
+ described_class.call(generic_file, updated_file, additional_services: additional_services, update_existing: true)
65
80
  end
66
81
 
67
82
  describe "the new file" do
68
83
  subject { generic_file.original_file }
69
84
  it "has updated content" do
70
- expect(subject.content).to eql File.open(updated_file).read
85
+ updated_file.rewind
86
+ expect(subject.content).to eql updated_file.read
71
87
  end
72
88
  it "has an updated name" do
73
- expect(subject.original_name).to eql updated_filename
89
+ expect(subject.original_name).to eql updated_name
74
90
  end
75
91
  it "has a updated mime type" do
76
92
  expect(subject.mime_type).to eql updated_mime_type
77
- end
93
+ expect(subject.versions.all.count).to eql 2
94
+ end
78
95
  end
79
96
  end
80
97
 
81
98
  end
82
-
99
+
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hydra::Works::PersistDerivative do
4
+
5
+ describe 'thumbnail generation' do
6
+ before do
7
+ file = File.open(File.join(fixture_path, file_name), 'r')
8
+ Hydra::Works::UploadFileToGenericFile.call(generic_file, file)
9
+ allow_any_instance_of(Hydra::Works::GenericFile::Base).to receive(:mime_type).and_return(mime_type)
10
+ generic_file.save!
11
+ end
12
+
13
+ context 'with a video (.avi) file' do
14
+ let(:mime_type) { 'video/avi' }
15
+ let(:file_name) { 'countdown.avi' }
16
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
17
+
18
+ it 'lacks a thumbnail' do
19
+ expect(generic_file.thumbnail).to be_nil
20
+ end
21
+
22
+ it 'generates a thumbnail derivative', unless: ENV['CI'] do
23
+ generic_file.create_derivatives
24
+ expect(generic_file.thumbnail).to have_content
25
+ expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
26
+ end
27
+ end
28
+
29
+ context 'with an image file' do
30
+ let(:mime_type) { 'image/png' }
31
+ let(:file_name) { 'world.png' }
32
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
33
+
34
+ it 'lacks a thumbnail' do
35
+ expect(generic_file.thumbnail).to be_nil
36
+ end
37
+
38
+ it 'uses PersistDerivative service to generate a thumbnail derivative' do
39
+ generic_file.create_derivatives
40
+ expect(Hydra::Derivatives.output_file_service).to eq(Hydra::Works::PersistDerivative)
41
+ expect(generic_file.thumbnail).to have_content
42
+ expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
43
+ end
44
+ end
45
+
46
+ context 'with an audio (.wav) file' do
47
+ let(:mime_type) { 'audio/wav' }
48
+ let(:file_name) { 'piano_note.wav' }
49
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
50
+
51
+ it 'lacks a thumbnail' do
52
+ expect(generic_file.thumbnail).to be_nil
53
+ end
54
+
55
+ it 'does not generate a thumbnail when derivatives are created', unless: ENV['CI'] do
56
+ generic_file.create_derivatives
57
+ expect(generic_file.thumbnail).to be_nil
58
+ end
59
+ end
60
+
61
+ context 'with an image (.jp2) file' do
62
+ let(:mime_type) { 'image/jp2' }
63
+ let(:file_name) { 'image.jp2' }
64
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
65
+
66
+ it 'lacks a thumbnail' do
67
+ expect(generic_file.thumbnail).to be_nil
68
+ end
69
+
70
+ it 'generates a thumbnail on job run' do
71
+ generic_file.create_derivatives
72
+ expect(generic_file.thumbnail).to have_content
73
+ expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
74
+ end
75
+ end
76
+
77
+ context 'with an office document (.docx) file' do
78
+ let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
79
+ let(:file_name) { 'charter.docx' }
80
+ let(:generic_file) { Hydra::Works::GenericFile::Base.new }
81
+
82
+ it 'lacks a thumbnail' do
83
+ expect(generic_file.thumbnail).to be_nil
84
+ end
85
+
86
+ it 'generates a thumbnail on job run', unless: ENV['CI'] do
87
+ generic_file.create_derivatives
88
+ expect(generic_file.thumbnail).to have_content
89
+ expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
90
+ end
91
+ end
92
+ end
93
+ end
@@ -2,91 +2,91 @@ require 'spec_helper'
2
2
 
3
3
  describe Hydra::Works do
4
4
 
5
- let(:works_coll) { Hydra::Works::Collection.create }
6
- let(:works_gwork) { Hydra::Works::GenericWork::Base.create }
7
- let(:works_gfile) { Hydra::Works::GenericFile::Base.create }
5
+ let(:works_coll) { Hydra::Works::Collection.new }
6
+ let(:works_gwork) { Hydra::Works::GenericWork::Base.new }
7
+ let(:works_gfile) { Hydra::Works::GenericFile::Base.new }
8
8
 
9
- let(:pcdm_coll) { Hydra::PCDM::Collection.create }
10
- let(:pcdm_obj) { Hydra::PCDM::Object.create }
9
+ let(:pcdm_coll) { Hydra::PCDM::Collection.new }
10
+ let(:pcdm_obj) { Hydra::PCDM::Object.new }
11
11
  let(:pcdm_file) { Hydra::PCDM::File.new }
12
12
 
13
13
  describe 'Validations' do
14
14
 
15
- describe "#collection?" do
15
+ describe "#works_collection?" do
16
16
  it "should return true for a works collection" do
17
- expect( Hydra::Works.collection? works_coll ).to be true
17
+ expect( works_coll.works_collection? ).to be true
18
18
  end
19
19
 
20
20
  it "should return false for a works generic work" do
21
- expect( Hydra::Works.collection? works_gwork ).to be false
21
+ expect( works_gwork.works_collection? ).to be false
22
22
  end
23
23
 
24
24
  it "should return false for a works generic file" do
25
- expect( Hydra::Works.collection? works_gfile ).to be false
25
+ expect( works_gfile.works_collection? ).to be false
26
26
  end
27
27
 
28
- it "should return false for a pcdm collection" do
29
- expect( Hydra::Works.collection? pcdm_coll ).to be false
28
+ it "should return that method is not available for pcdm a collection" do
29
+ expect(pcdm_coll).not_to respond_to(:works_collection?)
30
30
  end
31
31
 
32
- it "should return false for a pcdm object" do
33
- expect( Hydra::Works.collection? pcdm_obj ).to be false
32
+ it "should return that method is not available for a pcdm object" do
33
+ expect(pcdm_obj).not_to respond_to(:works_collection?)
34
34
  end
35
35
 
36
- it "should return false for a pcdm file" do
37
- expect( Hydra::Works.collection? pcdm_file ).to be false
36
+ it "should return that method is not available for a pcdm file" do
37
+ expect(pcdm_file).not_to respond_to(:works_collection?)
38
38
  end
39
39
  end
40
40
 
41
- describe "#generic_work?" do
41
+ describe "#works_generic_work?" do
42
42
  it "should return false for a works collection" do
43
- expect( Hydra::Works.generic_work? works_coll ).to be false
43
+ expect( works_coll.works_generic_work? ).to be false
44
44
  end
45
45
 
46
46
  it "should return true for a works generic work" do
47
- expect( Hydra::Works.generic_work? works_gwork ).to be true
47
+ expect( works_gwork.works_generic_work? ).to be true
48
48
  end
49
49
 
50
50
  it "should return false for a works generic file" do
51
- expect( Hydra::Works.generic_work? works_gfile ).to be false
51
+ expect( works_gfile.works_generic_work? ).to be false
52
52
  end
53
53
 
54
- it "should return false for a pcdm collection" do
55
- expect( Hydra::Works.generic_work? pcdm_coll ).to be false
54
+ it "should return that method is not available for a pcdm collection" do
55
+ expect(pcdm_coll).not_to respond_to(:works_generic_work?)
56
56
  end
57
57
 
58
- it "should return false for a pcdm object" do
59
- expect( Hydra::Works.generic_work? pcdm_obj ).to be false
58
+ it "should return that method is not available for a pcdm object" do
59
+ expect(pcdm_obj).not_to respond_to(:works_generic_work?)
60
60
  end
61
61
 
62
- it "should return false for a pcdm file" do
63
- expect( Hydra::Works.generic_work? pcdm_file ).to be false
62
+ it "should return that method is not available for a pcdm file" do
63
+ expect(pcdm_file).not_to respond_to(:works_generic_work?)
64
64
  end
65
65
  end
66
66
 
67
- describe "#generic_file?" do
67
+ describe "#works_generic_file?" do
68
68
  it "should return false for a works collection" do
69
- expect( Hydra::Works.generic_file? works_coll ).to be false
69
+ expect( works_coll.works_generic_file? ).to be false
70
70
  end
71
71
 
72
72
  it "should return false for a works generic work" do
73
- expect( Hydra::Works.generic_file? works_gwork ).to be false
73
+ expect( works_gwork.works_generic_file? ).to be false
74
74
  end
75
75
 
76
76
  it "should return true for a works generic file" do
77
- expect( Hydra::Works.generic_file? works_gfile ).to be true
77
+ expect( works_gfile.works_generic_file? ).to be true
78
78
  end
79
79
 
80
- it "should return false for a pcdm collection" do
81
- expect( Hydra::Works.generic_file? pcdm_coll ).to be false
80
+ it "should return that method is not available for a pcdm collection" do
81
+ expect(pcdm_coll).not_to respond_to(:works_generic_file?)
82
82
  end
83
83
 
84
- it "should return false for a pcdm object" do
85
- expect( Hydra::Works.generic_file? pcdm_obj ).to be false
84
+ it "should return that method is not available for a pcdm object" do
85
+ expect(pcdm_obj).not_to respond_to(:works_generic_file?)
86
86
  end
87
87
 
88
- it "should return false for a pcdm file" do
89
- expect( Hydra::Works.generic_file? pcdm_file ).to be false
88
+ it "should return that method is not available for a pcdm file" do
89
+ expect(pcdm_file).not_to respond_to(:works_generic_file?)
90
90
  end
91
91
  end
92
92
  end