diff --git a/lib/active_fedora/attached_files.rb b/lib/active_fedora/attached_files.rb index 5e1d8e28e..1a2c48462 100644 --- a/lib/active_fedora/attached_files.rb +++ b/lib/active_fedora/attached_files.rb @@ -156,13 +156,10 @@ def accessor_name(file_path) end module ClassMethods - extend Deprecation - self.deprecation_horizon = 'active-fedora version 10.0' - def ds_specs + Deprecation.warn(self, "ds_specs is deprecated and will be removed in ActiveFedora 10.0") child_resource_reflections end - deprecation_deprecate :ds_specs # This method is used to specify the details of a datastream. # You can pass the name as the first argument and a hash of options as the second argument @@ -177,6 +174,7 @@ def ds_specs # @option args [Boolean] :autocreate Always create this datastream on new objects # @yield block executed by some kinds of datastreams def has_metadata(*args, &block) + Deprecation.warn(self, "has_metadata is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.") if args.first.is_a? String name = args.first args = args[1] || {} @@ -189,7 +187,6 @@ def has_metadata(*args, &block) args[:class_name] = args.delete(:type).to_s has_subresource(name, args, &block) end - deprecation_deprecate :has_metadata # @overload has_file_datastream(name, args) # Declares a file datastream exists for objects of this type @@ -204,6 +201,7 @@ def has_metadata(*args, &block) # @option args :type (ActiveFedora::File) The class the datastream should have # @option args [Boolean] :autocreate Always create this datastream on new objects def has_file_datastream(*args) + Deprecation.warn(self, "has_file_datastream is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.") if args.first.is_a? String name = args.first args = args[1] || {} @@ -215,7 +213,6 @@ def has_file_datastream(*args) args[:class_name] = args.delete(:type).to_s has_subresource(name, args) end - deprecation_deprecate :has_file_datastream end end end diff --git a/spec/integration/attached_files_spec.rb b/spec/integration/attached_files_spec.rb index c1376bdf8..c30d2122e 100644 --- a/spec/integration/attached_files_spec.rb +++ b/spec/integration/attached_files_spec.rb @@ -25,32 +25,91 @@ class FooHistory < ActiveFedora::Base end end end - describe "serializing datastreams" do - before do - class TestingMetadataSerializing < ActiveFedora::Base - has_metadata "nokogiri_autocreate_on", autocreate: true, type: ActiveFedora::OmDatastream - has_metadata "nokogiri_autocreate_off", autocreate: false, type: ActiveFedora::OmDatastream + + describe "#has_metadata" do + describe "autosave" do + before :each do + class MockAFBaseRelationship < ActiveFedora::Base + extend Deprecation + Deprecation.silence(MockAFBaseRelationship) do + has_metadata 'foo', type: Hydra::ModsArticleDatastream + end + end end - end + after :each do + Object.send(:remove_const, :MockAFBaseRelationship) + end + describe "a new document" do + before do + @obj = MockAFBaseRelationship.new - after do - Object.send(:remove_const, :TestingMetadataSerializing) + @obj.foo.person = "bob" + @obj.save + end + + it "saves the datastream." do + obj = MockAFBaseRelationship.find(@obj.id) + expect(obj.foo).to_not be_new_record + expect(obj.foo.person).to eq ['bob'] + person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string) + solr_result = ActiveFedora::SolrService.query("{!field f=id}#{@obj.id}", fl: "id #{person_field}").first + expect(solr_result).to eq("id" => @obj.id, person_field => ['bob']) + end + end + + describe "that already exists in the repo" do + before do + @release = MockAFBaseRelationship.create + @release.foo.person = "test foo content" + @release.save + end + describe "and has been changed" do + before do + @release.foo.person = 'frank' + @release.save! + end + it "saves the datastream." do + expect(MockAFBaseRelationship.find(@release.id).foo.person).to eq ['frank'] + person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string) + expect(ActiveFedora::SolrService.query("id:\"#{@release.id}\"", fl: "id #{person_field}").first).to eq("id" => @release.id, person_field => ['frank']) + end + end + end end - subject { TestingMetadataSerializing.new } + describe "serializing datastreams" do + before do + class TestingMetadataSerializing < ActiveFedora::Base + extend Deprecation + Deprecation.silence(TestingMetadataSerializing) do + has_metadata "nokogiri_autocreate_on", autocreate: true, type: ActiveFedora::OmDatastream + has_metadata "nokogiri_autocreate_off", autocreate: false, type: ActiveFedora::OmDatastream + end + end + end - it "works" do - subject.save(validate: false) - expect(subject.nokogiri_autocreate_on).to_not be_new_record - expect(subject.nokogiri_autocreate_off).to be_new_record + after do + Object.send(:remove_const, :TestingMetadataSerializing) + end + + subject { TestingMetadataSerializing.new } + + it "works" do + subject.save(validate: false) + expect(subject.nokogiri_autocreate_on).to_not be_new_record + expect(subject.nokogiri_autocreate_off).to be_new_record + end end end describe "#has_file_datastream" do before do class HasFile < ActiveFedora::Base - has_file_datastream "file_ds" - has_file_datastream "file_ds2", autocreate: false + extend Deprecation + Deprecation.silence(HasFile) do + has_file_datastream "file_ds" + has_file_datastream "file_ds2", autocreate: false + end end end diff --git a/spec/integration/attributes_spec.rb b/spec/integration/attributes_spec.rb index ca9f55277..48d9cfbff 100644 --- a/spec/integration/attributes_spec.rb +++ b/spec/integration/attributes_spec.rb @@ -10,13 +10,18 @@ class PropertiesDatastream < ActiveFedora::OmDatastream end end class TitledObject < ActiveFedora::Base - has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m| - m.field "title", :string + extend Deprecation + + Deprecation.silence(TitledObject) do + has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m| + m.field "title", :string + end end Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, datastream: 'foo', multiple: false end end + class RdfObject < ActiveFedora::Base has_subresource 'foo', class_name: 'PropertiesDatastream' Deprecation.silence(ActiveFedora::Attributes) do diff --git a/spec/integration/autosave_association_spec.rb b/spec/integration/autosave_association_spec.rb index b9cc0702a..7b73c7c4d 100644 --- a/spec/integration/autosave_association_spec.rb +++ b/spec/integration/autosave_association_spec.rb @@ -3,7 +3,6 @@ describe ActiveFedora::Base do before :all do class MockAFBaseRelationship < ActiveFedora::Base - has_metadata name: 'foo', type: Hydra::ModsArticleDatastream end end after :all do diff --git a/spec/integration/base_spec.rb b/spec/integration/base_spec.rb index 42d03daad..a46854d3a 100644 --- a/spec/integration/base_spec.rb +++ b/spec/integration/base_spec.rb @@ -1,79 +1,32 @@ require 'spec_helper' describe ActiveFedora::Base do - describe "A base object with metadata" do - before :each do - class MockAFBaseRelationship < ActiveFedora::Base - has_metadata 'foo', type: Hydra::ModsArticleDatastream + describe '#reload' do + before do + class Foo < ActiveFedora::Base + property :person, predicate: ::RDF::Vocab::DC.creator end end - after :each do - Object.send(:remove_const, :MockAFBaseRelationship) + after do + Object.send(:remove_const, :Foo) end - describe "a new document" do + context "when persisted" do + let(:object) { Foo.create(person: ['bob']) } + let(:object2) { Foo.find(object.id) } before do - @obj = MockAFBaseRelationship.new - - @obj.foo.person = "bob" - @obj.save - end - - it "saves the datastream." do - obj = described_class.find(@obj.id) - expect(obj.foo).to_not be_new_record - expect(obj.foo.person).to eq ['bob'] - person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string) - solr_result = ActiveFedora::SolrService.query("{!field f=id}#{@obj.id}", fl: "id #{person_field}").first - expect(solr_result).to eq("id" => @obj.id, person_field => ['bob']) + object2.update(person: ['dave']) end - end - describe "that already exists in the repo" do - before do - @release = MockAFBaseRelationship.create - @release.foo.person = "test foo content" - @release.save - end - describe "and has been changed" do - before do - @release.foo.person = 'frank' - @release.save! - end - it "saves the datastream." do - expect(MockAFBaseRelationship.find(@release.id).foo.person).to eq ['frank'] - person_field = ActiveFedora.index_field_mapper.solr_name('foo__person', type: :string) - expect(ActiveFedora::SolrService.query("id:\"#{@release.id}\"", fl: "id #{person_field}").first).to eq("id" => @release.id, person_field => ['frank']) - end - end - describe "when trying to create it again" do - it "raises an error" do - expect { MockAFBaseRelationship.create(id: @release.id) }.to raise_error(ActiveFedora::IllegalOperation, "Attempting to recreate existing ldp_source: `#{@release.uri}'") - @release.reload - expect(@release.foo.person).to include('test foo content') - end + it 're-queries Fedora' do + object.reload + expect(object.person).to eq ['dave'] end end - describe '#reload' do - before do - @object = MockAFBaseRelationship.new - @object.foo.person = 'bob' - @object.save - - @object2 = @object.class.find(@object.id) - - @object2.foo.person = 'dave' - @object2.save - end - - it 'requeries Fedora' do - @object.reload - expect(@object.foo.person).to eq ['dave'] - end - - it 'raises an error if not persisted' do - @object = MockAFBaseRelationship.new - expect { @object.reload }.to raise_error(ActiveFedora::ObjectNotFoundError) + context "when not persisted" do + let(:object) { Foo.new } + it 'raises an error' do + expect { object.reload }.to raise_error(ActiveFedora::ObjectNotFoundError) end end end @@ -93,12 +46,12 @@ class Book < ActiveFedora::Base after { obj.destroy unless obj.destroyed? } - describe "errors" do + describe "#errors" do subject { obj.errors } it { should be_empty } end - describe "id" do + describe "#id" do subject { obj.id } it { should_not be_nil } end diff --git a/spec/integration/bug_spec.rb b/spec/integration/bug_spec.rb deleted file mode 100644 index 02ae59486..000000000 --- a/spec/integration/bug_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -require 'active_fedora' -require 'active_fedora/model' -require "rexml/document" - -describe 'bugs' do - before do - class FooHistory < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string - end - end - @test_object = FooHistory.new - @test_object.save - end - after do - @test_object.delete - Object.send(:remove_const, :FooHistory) - end - - it 'raises ActiveFedora::ObjectNotFoundError when find("")' do - expect { - FooHistory.find('') - }.to raise_error(ActiveFedora::ObjectNotFoundError) - end - - it "does not clobber everything when setting a value" do - @test_object.someData.fubar = ['initial'] - @test_object.save! - - x = FooHistory.find(@test_object.id) - x.someData.fubar = ["replacement"] # set a new value - x.save! - - x = FooHistory.find(@test_object.id) - expect(x.someData.fubar).to eq ["replacement"] # recall the value - x.save - end -end diff --git a/spec/integration/field_to_solr_name_spec.rb b/spec/integration/field_to_solr_name_spec.rb index 6aeec2d06..b981c2458 100644 --- a/spec/integration/field_to_solr_name_spec.rb +++ b/spec/integration/field_to_solr_name_spec.rb @@ -2,19 +2,19 @@ describe "An object with RDF backed attributes" do before do - class TestOne < ActiveFedora::Base - class MyMetadata < ActiveFedora::NtriplesRDFDatastream - Deprecation.silence(ActiveFedora::RDFDatastream) do - property :title, predicate: ::RDF::Vocab::DC.title do |index| - index.as :stored_searchable - end - property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted do |index| - index.type :date - index.as :stored_searchable, :sortable - end + class MyMetadata < ActiveFedora::NtriplesRDFDatastream + Deprecation.silence(ActiveFedora::RDFDatastream) do + property :title, predicate: ::RDF::Vocab::DC.title do |index| + index.as :stored_searchable + end + property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted do |index| + index.type :date + index.as :stored_searchable, :sortable end end - has_metadata 'descMetadata', type: MyMetadata + end + class TestOne < ActiveFedora::Base + has_subresource 'descMetadata', class_name: 'MyMetadata' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, :date_uploaded, datastream: 'descMetadata' end @@ -23,6 +23,7 @@ class MyMetadata < ActiveFedora::NtriplesRDFDatastream after do Object.send(:remove_const, :TestOne) + Object.send(:remove_const, :MyMetadata) end it "is able to grab the solr name" do diff --git a/spec/integration/file_spec.rb b/spec/integration/file_spec.rb index b53de1102..67a96747e 100644 --- a/spec/integration/file_spec.rb +++ b/spec/integration/file_spec.rb @@ -53,7 +53,10 @@ def size context "when autocreate is true" do before do class MockAFBase < ActiveFedora::Base - has_metadata "descMetadata", type: ActiveFedora::QualifiedDublinCoreDatastream, autocreate: true + extend Deprecation + Deprecation.silence(MockAFBase) do + has_metadata "descMetadata", type: ActiveFedora::QualifiedDublinCoreDatastream, autocreate: true + end end end diff --git a/spec/integration/full_featured_model_spec.rb b/spec/integration/full_featured_model_spec.rb index a71eb28ee..22cd50f98 100644 --- a/spec/integration/full_featured_model_spec.rb +++ b/spec/integration/full_featured_model_spec.rb @@ -6,52 +6,55 @@ describe ActiveFedora::Base do before(:all) do class OralHistory < ActiveFedora::Base - # These are all the properties that don't quite fit into Qualified DC - # Put them on the object itself (in the properties datastream) for now. - has_metadata name: "properties", type: ActiveFedora::SimpleDatastream do |m| - m.field "narrator", :string - m.field "interviewer", :string - m.field "transcript_editor", :text - m.field "bio", :string - m.field "notes", :text - m.field "hard_copy_availability", :text - m.field "hard_copy_location", :text - m.field "other_contributor", :string - m.field "restrictions", :text - m.field "series", :string - m.field "location", :string - end - - has_metadata name: "mods_article", type: Hydra::ModsArticleDatastream - - has_metadata name: "dublin_core", type: ActiveFedora::QualifiedDublinCoreDatastream do |_m| - # Default :multiple => true - # - # on retrieval, these will be pluralized and returned as arrays - # ie. subject_entries = my_oral_history.dublin_core.subjects - # - # aimint to use method-missing to support calling methods like - # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible - - # Setting new Types for dates and text content - # m.field "creation_date", :date, :xml_node => "date" - # m.field "abstract", :text, :xml_node => "abstract" - # m.field "rights", :text, :xml_node => "rights" - - # Setting up special named fields - # m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH" - # m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN" - # m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period" - # m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE" - # m.field "alt_title", :string, :xml_node => "alternative" - end - - has_metadata name: "significant_passages", type: ActiveFedora::SimpleDatastream do |m| - m.field "significant_passage", :text - end - - has_metadata name: "sensitive_passages", type: ActiveFedora::SimpleDatastream do |m| - m.field "sensitive_passage", :text + extend Deprecation + Deprecation.silence(OralHistory) do + # These are all the properties that don't quite fit into Qualified DC + # Put them on the object itself (in the properties datastream) for now. + has_metadata name: "properties", type: ActiveFedora::SimpleDatastream do |m| + m.field "narrator", :string + m.field "interviewer", :string + m.field "transcript_editor", :text + m.field "bio", :string + m.field "notes", :text + m.field "hard_copy_availability", :text + m.field "hard_copy_location", :text + m.field "other_contributor", :string + m.field "restrictions", :text + m.field "series", :string + m.field "location", :string + end + + has_metadata name: "mods_article", type: Hydra::ModsArticleDatastream + + has_metadata name: "dublin_core", type: ActiveFedora::QualifiedDublinCoreDatastream do |_m| + # Default :multiple => true + # + # on retrieval, these will be pluralized and returned as arrays + # ie. subject_entries = my_oral_history.dublin_core.subjects + # + # aimint to use method-missing to support calling methods like + # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible + + # Setting new Types for dates and text content + # m.field "creation_date", :date, :xml_node => "date" + # m.field "abstract", :text, :xml_node => "abstract" + # m.field "rights", :text, :xml_node => "rights" + + # Setting up special named fields + # m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH" + # m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN" + # m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period" + # m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE" + # m.field "alt_title", :string, :xml_node => "alternative" + end + + has_metadata name: "significant_passages", type: ActiveFedora::SimpleDatastream do |m| + m.field "significant_passage", :text + end + + has_metadata name: "sensitive_passages", type: ActiveFedora::SimpleDatastream do |m| + m.field "sensitive_passage", :text + end end end sample_location = "Boston, Massachusetts" diff --git a/spec/integration/has_and_belongs_to_many_associations_spec.rb b/spec/integration/has_and_belongs_to_many_associations_spec.rb index 115e901b0..a764856d2 100644 --- a/spec/integration/has_and_belongs_to_many_associations_spec.rb +++ b/spec/integration/has_and_belongs_to_many_associations_spec.rb @@ -350,22 +350,12 @@ class Collection < ActiveFedora::Base before do class Item < ActiveFedora::Base has_many :components - has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| - m.field "title", :string - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :title, datastream: 'foo' - end + property :title, predicate: ::RDF::Vocab::DC.title end class Component < ActiveFedora::Base has_and_belongs_to_many :items, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf - has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| - m.field "description", :string - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :description, datastream: 'foo' - end + property :description, predicate: ::RDF::Vocab::DC.description end end @@ -376,11 +366,11 @@ class Component < ActiveFedora::Base describe "From the has_and_belongs_to_many side" do describe "dependent records" do - let(:component) { Component.create(items: [Item.new(title: 'my title')]) } + let(:component) { Component.create(items: [Item.new(title: ['my title'])]) } it "is saved" do component.reload - expect(component.items.first.title).to eq 'my title' + expect(component.items.first.title).to eq ['my title'] end end @@ -413,11 +403,11 @@ class Component < ActiveFedora::Base end describe "From the has_many side" do - let(:item) { Item.create(components: [Component.new(description: 'my description')]) } + let(:item) { Item.create(components: [Component.new(description: ['my description'])]) } it "saves dependent records" do item.reload - expect(item.components.first.description).to eq 'my description' + expect(item.components.first.description).to eq ['my description'] end end end diff --git a/spec/integration/has_many_associations_spec.rb b/spec/integration/has_many_associations_spec.rb index 812a175a2..382a41b2e 100644 --- a/spec/integration/has_many_associations_spec.rb +++ b/spec/integration/has_many_associations_spec.rb @@ -314,21 +314,11 @@ class Component < ActiveFedora::Base before do class Item < ActiveFedora::Base has_many :components - has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| - m.field "title", :string - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :title, datastream: 'foo' - end + property :title, predicate: ::RDF::Vocab::DC.title end class Component < ActiveFedora::Base belongs_to :item, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf - has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| - m.field "description", :string - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :description, datastream: 'foo' - end + property :description, predicate: ::RDF::Vocab::DC.description end end @@ -338,20 +328,20 @@ class Component < ActiveFedora::Base end context "From the belongs_to side" do - let(:component) { Component.create(item: Item.new(title: 'my title')) } + let(:component) { Component.create(item: Item.new(title: ['my title'])) } it "saves dependent records" do component.reload - expect(component.item.title).to eq 'my title' + expect(component.item.title).to eq ['my title'] end end context "From the has_many side" do - let(:item) { Item.create(components: [Component.new(description: 'my description')]) } + let(:item) { Item.create(components: [Component.new(description: ['my description'])]) } it "saves dependent records" do item.reload - expect(item.components.first.description).to eq 'my description' + expect(item.components.first.description).to eq ['my description'] end end end diff --git a/spec/integration/json_serialization_spec.rb b/spec/integration/json_serialization_spec.rb index a9a31bb75..5d18ad5cc 100644 --- a/spec/integration/json_serialization_spec.rb +++ b/spec/integration/json_serialization_spec.rb @@ -8,9 +8,12 @@ context "with properties and datastream attributes" do before do class Foo < ActiveFedora::Base - has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| - m.field "foo", :text - m.field "bar", :text + extend Deprecation + Deprecation.silence(Foo) do + has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| + m.field "foo", :text + m.field "bar", :text + end end Deprecation.silence(ActiveFedora::Attributes) do has_attributes :foo, datastream: 'descMetadata', multiple: true @@ -56,7 +59,7 @@ def serialization_format end class DummyAsset < ActiveFedora::Base - has_metadata 'descMetadata', type: DummyResource + has_subresource 'descMetadata', class_name: 'DummyResource' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false end diff --git a/spec/integration/model_spec.rb b/spec/integration/model_spec.rb index 92ee49bee..db1f70d37 100644 --- a/spec/integration/model_spec.rb +++ b/spec/integration/model_spec.rb @@ -1,25 +1,19 @@ require 'spec_helper' describe ActiveFedora::Model do - before(:each) do + before do module ModelIntegrationSpec class Base < ActiveFedora::Base include ActiveFedora::Model - def self.id_namespace - "foo" - end - has_metadata name: "properties", type: ActiveFedora::SimpleDatastream, autocreate: true end class Basic < Base end end - - @test_instance = ModelIntegrationSpec::Basic.new - @test_instance.save end + let!(:test_instance) { ModelIntegrationSpec::Basic.create! } - after(:each) do - @test_instance.delete + after do + test_instance.delete Object.send(:remove_const, :ModelIntegrationSpec) end @@ -37,15 +31,15 @@ class Basic < Base describe '#find' do describe "#find with a valid id without cast" do - subject { ActiveFedora::Base.find(@test_instance.id) } + subject { ActiveFedora::Base.find(test_instance.id) } it { should be_instance_of ModelIntegrationSpec::Basic } end describe "#find with a valid id with cast of false" do - subject { ActiveFedora::Base.find(@test_instance.id, cast: false) } + subject { ActiveFedora::Base.find(test_instance.id, cast: false) } it { should be_instance_of ActiveFedora::Base } end describe "#find with a valid id without cast on a model extending Base" do - subject { ModelIntegrationSpec::Basic.find(@test_instance.id) } + subject { ModelIntegrationSpec::Basic.find(test_instance.id) } it { should be_instance_of ModelIntegrationSpec::Basic } end end diff --git a/spec/integration/ntriples_datastream_spec.rb b/spec/integration/ntriples_datastream_spec.rb index 0945c985a..891855ff2 100644 --- a/spec/integration/ntriples_datastream_spec.rb +++ b/spec/integration/ntriples_datastream_spec.rb @@ -26,7 +26,7 @@ class MyDatastream < ActiveFedora::NtriplesRDFDatastream end class RdfTest < ActiveFedora::Base - has_metadata 'rdf', type: MyDatastream + has_subresource 'rdf', class_name: 'MyDatastream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :based_near, :related_url, :part, :date_uploaded, datastream: 'rdf', multiple: true has_attributes :title, :filesize, datastream: 'rdf', multiple: false @@ -227,7 +227,7 @@ class TitleDatastream < ActiveFedora::NtriplesRDFDatastream property :title, predicate: ::RDF::Vocab::DC.title end class Foobar < ActiveFedora::Base - has_metadata 'rdf', type: TitleDatastream + has_subresource 'rdf', class_name: 'TitleDatastream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, datastream: 'rdf', multiple: true end diff --git a/spec/integration/om_datastream_spec.rb b/spec/integration/om_datastream_spec.rb index 10093b4cf..39be751b3 100644 --- a/spec/integration/om_datastream_spec.rb +++ b/spec/integration/om_datastream_spec.rb @@ -4,7 +4,7 @@ before(:all) do class ModsArticle2 < ActiveFedora::Base # Uses the Hydra MODS Article profile for tracking most of the descriptive metadata - has_metadata "descMetadata", type: Hydra::ModsArticleDatastream, autocreate: true + has_subresource "descMetadata", class_name: 'Hydra::ModsArticleDatastream' end end diff --git a/spec/integration/persistence_spec.rb b/spec/integration/persistence_spec.rb index 602d803d8..3ef8387da 100644 --- a/spec/integration/persistence_spec.rb +++ b/spec/integration/persistence_spec.rb @@ -4,9 +4,6 @@ describe "#create!" do before do class MockAFBaseRelationship < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "foo" do |m| - m.field "name", :string - end property :name, predicate: ::RDF::Vocab::DC.title, multiple: false validates :name, presence: true end diff --git a/spec/integration/query_result_builder_spec.rb b/spec/integration/query_result_builder_spec.rb index 0e2ba05f1..44e640a31 100644 --- a/spec/integration/query_result_builder_spec.rb +++ b/spec/integration/query_result_builder_spec.rb @@ -8,7 +8,7 @@ def self.id_namespace "foo" end - has_metadata name: "descMetadata", type: ActiveFedora::QualifiedDublinCoreDatastream + has_subresource :descMetadata, class_name: 'ActiveFedora::QualifiedDublinCoreDatastream' end @test_object = ActiveFedora::Base.new @foo_object = FooObject.new diff --git a/spec/integration/relation_delegation_spec.rb b/spec/integration/relation_delegation_spec.rb index e2c55fc6d..dbf38f6d9 100644 --- a/spec/integration/relation_delegation_spec.rb +++ b/spec/integration/relation_delegation_spec.rb @@ -4,14 +4,9 @@ before(:all) do module ModelIntegrationSpec class Basic < ActiveFedora::Base - has_metadata name: "properties", type: ActiveFedora::SimpleDatastream do |m| - m.field "foo", :string - m.field "bar", :string - m.field "baz", :string - end - - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true + property :foo, predicate: ::RDF::URI('http://example.com/foo') + property :bar, predicate: ::RDF::URI('http://example.com/bar') do |index| + index.as :stored_searchable end def to_solr(doc = {}) diff --git a/spec/integration/scoped_query_spec.rb b/spec/integration/scoped_query_spec.rb index 3f481b78d..8d3d0ca1a 100644 --- a/spec/integration/scoped_query_spec.rb +++ b/spec/integration/scoped_query_spec.rb @@ -4,15 +4,13 @@ before do module ModelIntegrationSpec class Basic < ActiveFedora::Base - has_metadata "properties", type: ActiveFedora::SimpleDatastream do |m| - m.field "foo", :string - m.field "bar", :string - m.field "baz", :string + property :foo, predicate: ::RDF::URI('http://example.com/foo') do |index| + index.as :stored_searchable end - - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true + property :bar, predicate: ::RDF::URI('http://example.com/bar') do |index| + index.as :stored_searchable end + property :baz, predicate: ::RDF::URI('http://example.com/baz') def to_solr(doc = {}) doc = super diff --git a/spec/integration/solr_hit_spec.rb b/spec/integration/solr_hit_spec.rb index 066633900..ac15dd2d4 100644 --- a/spec/integration/solr_hit_spec.rb +++ b/spec/integration/solr_hit_spec.rb @@ -3,9 +3,12 @@ describe ActiveFedora::SolrHit do before do class Foo < ActiveFedora::Base - has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| - m.field "foo", :text - m.field "bar", :text + extend Deprecation + Deprecation.silence(self) do + has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| + m.field "foo", :text + m.field "bar", :text + end end Deprecation.silence(ActiveFedora::Attributes) do has_attributes :foo, datastream: 'descMetadata', multiple: true diff --git a/spec/integration/solr_instance_loader_spec.rb b/spec/integration/solr_instance_loader_spec.rb index d6f0e9cf2..de7e02d03 100644 --- a/spec/integration/solr_instance_loader_spec.rb +++ b/spec/integration/solr_instance_loader_spec.rb @@ -3,9 +3,12 @@ describe ActiveFedora::SolrInstanceLoader do before do class Foo < ActiveFedora::Base - has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| - m.field "foo", :text - m.field "bar", :text + extend Deprecation + Deprecation.silence(Foo) do + has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m| + m.field "foo", :text + m.field "bar", :text + end end Deprecation.silence(ActiveFedora::Attributes) do has_attributes :foo, datastream: 'descMetadata', multiple: true diff --git a/spec/unit/attached_files_spec.rb b/spec/unit/attached_files_spec.rb index ec31a8d67..fc06a86fa 100644 --- a/spec/unit/attached_files_spec.rb +++ b/spec/unit/attached_files_spec.rb @@ -37,17 +37,17 @@ class FooHistory < ActiveFedora::Base describe '.has_metadata' do before do - @original_behavior = Deprecation.default_deprecation_behavior - Deprecation.default_deprecation_behavior = :silence class Z < ActiveFedora::File end class FooHistory < ActiveFedora::Base - has_metadata name: 'dsid', type: ActiveFedora::SimpleDatastream - has_metadata 'complex_ds', autocreate: true, type: 'Z' + extend Deprecation + Deprecation.silence(FooHistory) do + has_metadata name: 'dsid', type: ActiveFedora::SimpleDatastream + has_metadata 'complex_ds', autocreate: true, type: 'Z' + end end end after do - Deprecation.default_deprecation_behavior = @original_behavior Object.send(:remove_const, :FooHistory) Object.send(:remove_const, :Z) end @@ -66,13 +66,21 @@ class FooHistory < ActiveFedora::Base end it "raises an error if you don't give a type" do - expect { FooHistory.has_metadata "bob" }.to raise_error ArgumentError, - "You must provide a :type property for the datastream 'bob'" + expect { + Deprecation.silence(FooHistory) do + FooHistory.has_metadata "bob" + end + }.to raise_error ArgumentError, + "You must provide a :type property for the datastream 'bob'" end it "raises an error if you don't give a dsid" do - expect { FooHistory.has_metadata type: ActiveFedora::SimpleDatastream }.to raise_error ArgumentError, - "You must provide a path name (f.k.a. dsid) for the resource" + expect { + Deprecation.silence(FooHistory) do + FooHistory.has_metadata type: ActiveFedora::SimpleDatastream + end + }.to raise_error ArgumentError, + "You must provide a path name (f.k.a. dsid) for the resource" end describe "creates accessors" do @@ -86,8 +94,11 @@ class FooHistory < ActiveFedora::Base describe '.has_file_datastream' do before do class FooHistory < ActiveFedora::Base - has_file_datastream name: 'dsid' - has_file_datastream 'another' + extend Deprecation + Deprecation.silence(FooHistory) do + has_file_datastream name: 'dsid' + has_file_datastream 'another' + end end end after do diff --git a/spec/unit/attributes_spec.rb b/spec/unit/attributes_spec.rb index 307ca84e8..af079d28a 100644 --- a/spec/unit/attributes_spec.rb +++ b/spec/unit/attributes_spec.rb @@ -37,7 +37,7 @@ def self.xml_template context "with an xml property (default cardinality)" do before do class BarHistory4 < ActiveFedora::Base - has_metadata type: BarStream2, name: "xmlish" + has_subresource 'xmlish', class_name: 'BarStream2' Deprecation.silence(ActiveFedora::Attributes) do property :cow, delegate_to: 'xmlish' end @@ -64,7 +64,7 @@ class BarHistory4 < ActiveFedora::Base context "with multiple set to false" do before do class BarHistory4 < ActiveFedora::Base - has_metadata type: BarStream2, name: "xmlish" + has_subresource 'xmlish', class_name: 'BarStream2' Deprecation.silence(ActiveFedora::Attributes) do property :cow, delegate_to: 'xmlish', multiple: false end @@ -86,7 +86,7 @@ class BarHistory4 < ActiveFedora::Base context "when updating and saving a property" do before do class BarHistory4 < ActiveFedora::Base - has_metadata type: BarStream2, name: "xmlish" + has_subresource 'xmlish', class_name: 'BarStream2' Deprecation.silence(ActiveFedora::Attributes) do property :cow, delegate_to: 'xmlish', multiple: false end @@ -113,22 +113,25 @@ class BarHistory4 < ActiveFedora::Base end describe "first level delegation" do - before :all do + before do class BarHistory2 < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string - m.field "bandana", :string - m.field "swank", :text - m.field "animal_id", :string - end - has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m| - m.field "fubar", :text - end - has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m| - m.field "fubar", :text + extend Deprecation + Deprecation.silence(self) do + has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| + m.field "fubar", :string + m.field "bandana", :string + m.field "swank", :text + m.field "animal_id", :string + end + has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m| + m.field "fubar", :text + end + has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m| + m.field "fubar", :text + end end - has_metadata type: BarStream2, name: "xmlish" + has_subresource 'xmlish', class_name: 'BarStream2' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :cow, datastream: 'xmlish' # for testing the default value of multiple has_attributes :fubar, datastream: 'withText', multiple: true # test alternate datastream @@ -142,7 +145,7 @@ class BarHistory2 < ActiveFedora::Base end end - after :all do + after do Object.send(:remove_const, :BarHistory2) end @@ -350,7 +353,7 @@ class BarHistory3 < BarHistory2 describe "with a superclass" do before :all do class BarHistory2 < ActiveFedora::Base - has_metadata 'xmlish', type: BarStream2 + has_subresource 'xmlish', class_name: 'BarStream2' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :donkey, :cow, datastream: 'xmlish', multiple: true end @@ -386,7 +389,7 @@ class BarRdfDatastream < ActiveFedora::NtriplesRDFDatastream property :description, predicate: ::RDF::Vocab::DC.description end class BarHistory4 < ActiveFedora::Base - has_metadata 'rdfish', type: BarRdfDatastream + has_subresource 'rdfish', class_name: 'BarRdfDatastream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, datastream: 'rdfish', multiple: true has_attributes :description, datastream: 'rdfish', multiple: false @@ -478,7 +481,7 @@ class BarRdfDatastream < ActiveFedora::NtriplesRDFDatastream property :description, predicate: ::RDF::Vocab::DC.description end class BarHistory4 < ActiveFedora::Base - has_metadata 'rdfish', type: BarRdfDatastream + has_subresource 'rdfish', class_name: 'BarRdfDatastream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :description, datastream: :rdfish end diff --git a/spec/unit/base_active_model_spec.rb b/spec/unit/base_active_model_spec.rb index d67286f8a..10a168e62 100644 --- a/spec/unit/base_active_model_spec.rb +++ b/spec/unit/base_active_model_spec.rb @@ -15,19 +15,22 @@ def self.xml_template end end - class BarHistory < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string - m.field "swank", :text - end - has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m| - m.field "fubar", :text + class BazStream < ActiveFedora::OmDatastream + set_terminology do |t| + t.root(path: "first", xmlns: "urn:foobar") + t.fubar end - has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m| - m.field "fubar", :text + + def self.xml_template + Nokogiri::XML::Document.parse ' + + ' end + end - has_metadata type: BarStream, name: "xmlish" + class BarHistory < ActiveFedora::Base + has_subresource 'xmlish', class_name: 'BarStream' + has_subresource 'withText', class_name: 'BazStream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :fubar, datastream: 'withText', multiple: false has_attributes :duck, datastream: 'xmlish', multiple: false diff --git a/spec/unit/base_spec.rb b/spec/unit/base_spec.rb index 3bf864486..ac0c91bf5 100644 --- a/spec/unit/base_spec.rb +++ b/spec/unit/base_spec.rb @@ -111,34 +111,12 @@ class SpecialThing < ActiveFedora::Base describe "With a test class" do before do class FooHistory < ActiveFedora::Base - has_metadata 'someData', type: ActiveFedora::SimpleDatastream, autocreate: true do |m| - m.field "fubar", :string - m.field "swank", :text - end - has_metadata "withText", type: ActiveFedora::SimpleDatastream, autocreate: true do |m| - m.field "fubar", :text - end - has_metadata "withText2", type: ActiveFedora::SimpleDatastream, autocreate: true do |m| - m.field "fubar", :text - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :fubar, datastream: 'withText', multiple: true - has_attributes :swank, datastream: 'someData', multiple: true - end - end - - class FooAdaptation < ActiveFedora::Base - has_metadata 'someData', type: ActiveFedora::OmDatastream - end - - class FooInherited < FooHistory + property :fubar, predicate: ::RDF::URI('http://example.com/fubar') end end after do Object.send(:remove_const, :FooHistory) - Object.send(:remove_const, :FooAdaptation) - Object.send(:remove_const, :FooInherited) end def increment_id @@ -305,7 +283,7 @@ class WithProperty < ActiveFedora::Base obj = double expect(obj).to receive(:save) expect(FooHistory).to receive(:new).and_return(obj) - @hist = FooHistory.create(fubar: 'ta', swank: 'da') + FooHistory.create(fubar: 'ta') end end diff --git a/spec/unit/callback_spec.rb b/spec/unit/callback_spec.rb index 6bf7a4c35..22f732f37 100644 --- a/spec/unit/callback_spec.rb +++ b/spec/unit/callback_spec.rb @@ -3,14 +3,6 @@ describe ActiveFedora::Base do before :each do class CallbackStub < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string - m.field "swank", :text - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :fubar, :swank, datastream: 'someData', multiple: true - end - after_initialize :a_init before_save :b_save after_save :a_save diff --git a/spec/unit/core_spec.rb b/spec/unit/core_spec.rb index de862b774..8e9274822 100644 --- a/spec/unit/core_spec.rb +++ b/spec/unit/core_spec.rb @@ -8,11 +8,14 @@ class MyDatastream < ActiveFedora::NtriplesRDFDatastream class Library < ActiveFedora::Base end class Book < ActiveFedora::Base + extend Deprecation belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent - has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| - m.field "title", :string + Deprecation.silence(Book) do + has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m| + m.field "title", :string + end + has_metadata "bar", type: MyDatastream end - has_metadata "bar", type: MyDatastream Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, datastream: 'foo' # Om backed property has_attributes :publisher, datastream: 'bar' # RDF backed property diff --git a/spec/unit/inheritance_spec.rb b/spec/unit/inheritance_spec.rb index 63ac7b36f..143675f45 100644 --- a/spec/unit/inheritance_spec.rb +++ b/spec/unit/inheritance_spec.rb @@ -3,14 +3,20 @@ describe ActiveFedora::Base do before do class Foo < ActiveFedora::Base - has_metadata "foostream", type: ActiveFedora::SimpleDatastream do |m| - m.field "foostream", :string + extend Deprecation + Deprecation.silence(Foo) do + has_metadata "foostream", type: ActiveFedora::SimpleDatastream do |m| + m.field "foostream", :string + end + has_metadata 'dcstream', type: ActiveFedora::QualifiedDublinCoreDatastream end - has_metadata 'dcstream', type: ActiveFedora::QualifiedDublinCoreDatastream end class Bar < ActiveFedora::Base - has_metadata 'barstream', type: ActiveFedora::SimpleDatastream do |m| - m.field "barfield", :string + extend Deprecation + Deprecation.silence(Bar) do + has_metadata 'barstream', type: ActiveFedora::SimpleDatastream do |m| + m.field "barfield", :string + end end end end @@ -26,8 +32,13 @@ class Bar < ActiveFedora::Base it "works for multiple types" do b = Foo.new f = Bar.new - expect(b.class.ds_specs).to_not eq f.class.ds_specs + Deprecation.silence(Foo) do + Deprecation.silence(Bar) do + expect(b.class.ds_specs).to_not eq f.class.ds_specs + end + end end + after do Object.send(:remove_const, :Bar) Object.send(:remove_const, :Foo) diff --git a/spec/unit/ntriples_datastream_spec.rb b/spec/unit/ntriples_datastream_spec.rb index 5ce3353e0..7839302de 100644 --- a/spec/unit/ntriples_datastream_spec.rb +++ b/spec/unit/ntriples_datastream_spec.rb @@ -196,7 +196,7 @@ class MyDatastream < ActiveFedora::NtriplesRDFDatastream describe "with an actual object" do before(:each) do class Foo < ActiveFedora::Base - has_metadata "descMetadata", type: MyDatastream + has_subresource "descMetadata", class_name: 'MyDatastream' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :created, :title, :publisher, :based_near, :related_url, :rights, datastream: :descMetadata, multiple: true end diff --git a/spec/unit/om_datastream_spec.rb b/spec/unit/om_datastream_spec.rb index ae56af4ee..2f2f89644 100644 --- a/spec/unit/om_datastream_spec.rb +++ b/spec/unit/om_datastream_spec.rb @@ -306,7 +306,7 @@ def prefix(_) describe "an instance that exists in the datastore, but hasn't been loaded" do before do class MyObj < ActiveFedora::Base - has_metadata 'descMetadata', type: Hydra::ModsArticleDatastream + has_subresource 'descMetadata', class_name: 'Hydra::ModsArticleDatastream' end @obj = MyObj.new @obj.descMetadata.title = 'Foobar' diff --git a/spec/unit/persistence_spec.rb b/spec/unit/persistence_spec.rb index c1e3418b8..fd0544ce3 100644 --- a/spec/unit/persistence_spec.rb +++ b/spec/unit/persistence_spec.rb @@ -35,6 +35,14 @@ expect { |b| ActiveFedora::Base.create(&b) }.to yield_with_args(an_instance_of(ActiveFedora::Base)) end end + + context "when trying to create it again" do + let(:object) { ActiveFedora::Base.create! } + + it "raises an error" do + expect { ActiveFedora::Base.create(id: object.id) }.to raise_error(ActiveFedora::IllegalOperation, "Attempting to recreate existing ldp_source: `#{object.uri}'") + end + end end describe '.destroy' do diff --git a/spec/unit/query_spec.rb b/spec/unit/query_spec.rb index 6bbb74c89..9ee3a4999 100644 --- a/spec/unit/query_spec.rb +++ b/spec/unit/query_spec.rb @@ -67,6 +67,14 @@ class Basic < ActiveFedora::Base SpecModel::Basic.find(id: "_ID_") end end + + context "with a blank string" do + it 'raises ActiveFedora::ObjectNotFoundError' do + expect { + SpecModel::Basic.find('') + }.to raise_error(ActiveFedora::ObjectNotFoundError) + end + end end describe "#where" do diff --git a/spec/unit/rdf_datastream_spec.rb b/spec/unit/rdf_datastream_spec.rb index 4c439cb24..0c0401e86 100644 --- a/spec/unit/rdf_datastream_spec.rb +++ b/spec/unit/rdf_datastream_spec.rb @@ -15,7 +15,7 @@ class MyDatastream < ActiveFedora::NtriplesRDFDatastream property :description, predicate: ::RDF::Vocab::DC.description end class MyObj < ActiveFedora::Base - has_metadata 'descMetadata', type: MyDatastream + has_subresource 'descMetadata', class_name: 'MyDatastream' end @obj = MyObj.new @obj.descMetadata.title = 'Foobar' diff --git a/spec/unit/rdf_resource_datastream_spec.rb b/spec/unit/rdf_resource_datastream_spec.rb index ed0a5db2c..984d1a4cc 100644 --- a/spec/unit/rdf_resource_datastream_spec.rb +++ b/spec/unit/rdf_resource_datastream_spec.rb @@ -25,7 +25,7 @@ def serialization_format end class DummyAsset < ActiveFedora::Base - has_metadata 'descMetadata', type: DummyResource + has_subresource 'descMetadata', class_name: 'DummyResource' Deprecation.silence(ActiveFedora::Attributes) do has_attributes :title, :license, datastream: 'descMetadata', multiple: true has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false diff --git a/spec/unit/simple_datastream_spec.rb b/spec/unit/simple_datastream_spec.rb index 92745bc40..3acab68d1 100644 --- a/spec/unit/simple_datastream_spec.rb +++ b/spec/unit/simple_datastream_spec.rb @@ -70,8 +70,11 @@ before do class FooHistory < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string + extend Deprecation + Deprecation.silence(FooHistory) do + has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| + m.field "fubar", :string + end end Deprecation.silence(ActiveFedora::Attributes) do has_attributes :fubar, datastream: 'someData', multiple: false diff --git a/spec/unit/validations_spec.rb b/spec/unit/validations_spec.rb index 2d1786c9e..81e988360 100644 --- a/spec/unit/validations_spec.rb +++ b/spec/unit/validations_spec.rb @@ -3,14 +3,8 @@ describe ActiveFedora::Base do before :all do class ValidationStub < ActiveFedora::Base - has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m| - m.field "fubar", :string - m.field "swank", :text - end - Deprecation.silence(ActiveFedora::Attributes) do - has_attributes :fubar, datastream: 'someData', multiple: true - has_attributes :swank, datastream: 'someData', multiple: false - end + property :fubar, predicate: ::RDF::URI('http://example.com/fubar') + property :swank, predicate: ::RDF::URI('http://example.com/swank'), multiple: false validates_presence_of :fubar validates_length_of :swank, minimum: 5