Skip to content

Commit

Permalink
Generate tests for model with RDF predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jan 5, 2015
1 parent ebbf618 commit 2d826d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/generators/active_fedora/model/templates/model.rb.erb
Expand Up @@ -6,16 +6,16 @@ class <%= class_name %> < ActiveFedora::Base
<% else %>
# Define some properties to store:
#
property :title, predicate: RDF::DC.title do |index|
property :title, predicate: ::RDF::DC.title do |index|
index.as :stored_searchable, :facetable
end
property :creator, predicate: RDF::DC.creator do |index|
property :creator, predicate: ::RDF::DC.creator do |index|
index.as :stored_searchable, :facetable
end
property :contributor, predicate: RDF::DC.contributor do |index|
property :contributor, predicate: ::RDF::DC.contributor do |index|
index.as :stored_searchable, :facetable
end
property :description, predicate: RDF::DC.description do |index|
property :description, predicate: ::RDF::DC.description do |index|
index.as :stored_searchable
end
<%- end -%>
Expand All @@ -38,7 +38,7 @@ class <%= class_name %> < ActiveFedora::Base
# class IndexingService < ActiveFedora::IndexingService
# def generate_solr_document
# super.tap do |solr_doc|
# solr_document["my_attribute_s"] = object.my_attribute
# solr_doc["my_attribute_s"] = object.my_attribute
# end
# end
# end
Expand Down
15 changes: 15 additions & 0 deletions lib/generators/active_fedora/model/templates/model_spec.rb.erb
Expand Up @@ -16,8 +16,23 @@ describe <%= class_name %> do
end
end

<% if options['datastream'] %>
it 'should have a descMetadata datastream' do
expect(subject.descMetadata).to be_kind_of <%= options['descMetadata'] ? options['descMetadata'] : "#{class_name}Metadata" %>
end
<% else %>
it 'should have a title' do
subject.title = ['War and Peace']
expect(subject.title).to eq ['War and Peace']
end

describe "#to_solr" do
subject { <%= class_name %>.new(title: ['War and Peace']).to_solr }

it 'should have a title' do
expect(subject['title_tesim']).to eq ['War and Peace']
end
end
<% end %>

end

0 comments on commit 2d826d3

Please sign in to comment.