This repository has been archived by the owner on Dec 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes problem where array value was producing multiple SPARQL insert …
…statements.
- Loading branch information
1 parent
eeba42f
commit 2e56a15
Showing
2 changed files
with
60 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,54 +67,71 @@ | |
end | ||
|
||
describe '#serialize' do | ||
let(:first_hash) do | ||
{ | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'].to_s, | ||
'@graph' => Rialto::Etl::NamedGraphs::STANFORD_PEOPLE_GRAPH.to_s, | ||
'@type' => [RDF::Vocab::FOAF.Person, Rialto::Etl::Vocabs::Stanford.Staff], | ||
Rialto::Etl::Vocabs::VIVO.overview.to_s => 'Justin Littman is a software developer and librarian.', | ||
RDF::Vocab::VCARD.hasEmail.to_s => '[email protected]', | ||
'#advisee' => { | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'].to_s, | ||
describe 'when serializing a hash' do | ||
let(:first_hash) do | ||
{ | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'].to_s, | ||
'@graph' => Rialto::Etl::NamedGraphs::STANFORD_PEOPLE_GRAPH.to_s, | ||
'@type' => [RDF::Vocab::FOAF.Person], | ||
RDF::Vocab::VCARD.hasName.to_s => Rialto::Etl::Vocabs::RIALTO_CONTEXT_NAMES['188882'] | ||
'@type' => [RDF::Vocab::FOAF.Person, Rialto::Etl::Vocabs::Stanford.Staff], | ||
Rialto::Etl::Vocabs::VIVO.overview.to_s => 'Justin Littman is a software developer and librarian.', | ||
RDF::Vocab::VCARD.hasEmail.to_s => '[email protected]', | ||
'#advisee' => { | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'].to_s, | ||
'@graph' => Rialto::Etl::NamedGraphs::STANFORD_PEOPLE_GRAPH.to_s, | ||
'@type' => [RDF::Vocab::FOAF.Person], | ||
RDF::Vocab::VCARD.hasName.to_s => Rialto::Etl::Vocabs::RIALTO_CONTEXT_NAMES['188882'] | ||
} | ||
} | ||
} | ||
end | ||
end | ||
|
||
let(:second_hash) do | ||
{ | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'].to_s, | ||
'@graph' => Rialto::Etl::NamedGraphs::STANFORD_PEOPLE_GRAPH.to_s, | ||
'@type' => [RDF::Vocab::FOAF.Person, Rialto::Etl::Vocabs::Stanford.Staff], | ||
"!#{RDF::Vocab::VCARD.hasEmail}" => true, | ||
RDF::Vocab::VCARD.hasEmail.to_s => '[email protected]' | ||
} | ||
end | ||
let(:second_hash) do | ||
{ | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'].to_s, | ||
'@graph' => Rialto::Etl::NamedGraphs::STANFORD_PEOPLE_GRAPH.to_s, | ||
'@type' => [RDF::Vocab::FOAF.Person, Rialto::Etl::Vocabs::Stanford.Staff], | ||
"!#{RDF::Vocab::VCARD.hasEmail}" => true, | ||
RDF::Vocab::VCARD.hasEmail.to_s => '[email protected]' | ||
} | ||
end | ||
|
||
let(:first_statements) { writer.serialize_hash(first_hash) } | ||
let(:first_statements) { writer.serialize_hash(first_hash) } | ||
|
||
let(:second_statements) { writer.serialize_hash(second_hash) } | ||
|
||
before do | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], RDF.type, RDF::Vocab::FOAF.Person] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], RDF.type, Rialto::Etl::Vocabs::Stanford.Staff] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], | ||
Rialto::Etl::Vocabs::VIVO.overview, | ||
'Justin Littman is a software developer and librarian.'] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], | ||
RDF::Vocab::VCARD.hasEmail, | ||
'[email protected]'] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'], RDF.type, RDF::Vocab::FOAF.Person] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'], | ||
RDF::Vocab::VCARD.hasName, | ||
Rialto::Etl::Vocabs::RIALTO_CONTEXT_NAMES['188882']] | ||
|
||
execute_sparql!(first_statements) | ||
execute_sparql!(second_statements) | ||
end | ||
|
||
let(:second_statements) { writer.serialize_hash(second_hash) } | ||
it { is_expected.to have_same_triples(graph) } | ||
end | ||
|
||
before do | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], RDF.type, RDF::Vocab::FOAF.Person] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], RDF.type, Rialto::Etl::Vocabs::Stanford.Staff] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], | ||
Rialto::Etl::Vocabs::VIVO.overview, | ||
'Justin Littman is a software developer and librarian.'] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'], | ||
RDF::Vocab::VCARD.hasEmail, | ||
'[email protected]'] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'], RDF.type, RDF::Vocab::FOAF.Person] | ||
graph << [Rialto::Etl::Vocabs::RIALTO_PEOPLE['188882'], | ||
RDF::Vocab::VCARD.hasName, | ||
Rialto::Etl::Vocabs::RIALTO_CONTEXT_NAMES['188882']] | ||
describe 'when serializing a hash with an array' do | ||
let(:hash) do | ||
{ | ||
'@id' => Rialto::Etl::Vocabs::RIALTO_PEOPLE['1234'].to_s, | ||
RDF::Vocab::SKOS.altLabel.to_s => ['Justin Littman', 'Littman, Justin'] | ||
} | ||
end | ||
|
||
execute_sparql!(first_statements) | ||
execute_sparql!(second_statements) | ||
end | ||
let(:statements) { writer.serialize_hash(hash).flatten } | ||
|
||
it { is_expected.to have_same_triples(graph) } | ||
it 'produces a single insert for the array' do | ||
expect(statements.length).to be(1) | ||
end | ||
end | ||
end | ||
end |