Skip to content

Commit

Permalink
extend tests to check the connection is working and some cleaning up
Browse files Browse the repository at this point in the history
check with a single select which is unlikely to change, and also include a simple insert #15
  • Loading branch information
stuzart committed Apr 13, 2021
1 parent d389deb commit 061c2a5
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
$:.unshift '.'
# frozen_string_literal: true

$LOAD_PATH.unshift '.'
require File.join(File.dirname(__FILE__), 'spec_helper')
require 'rdf/spec/repository'

Expand All @@ -9,28 +11,43 @@
# docker stop virtuoso-testing

describe RDF::Virtuoso::Repository do
context('when interating with a virtuoso repository instance') do
context('when interacting with a virtuoso repository instance') do
subject(:repository) do
described_class.new(uri,
update_uri: update_uri,
username: username,
password: password,
auth_method: 'digest')
end

let(:uri) { 'http://localhost:8890/sparql' }
let(:update_uri) { 'http://localhost:8890/sparql-auth' }
let(:repo) { RDF::Virtuoso::Repository.new(uri) }
let(:password) { 'tester' }
let(:username) { 'dba' }
let(:repo) do
RDF::Virtuoso::Repository.new(uri,
update_uri: update_uri,
username: username,
password: password,
auth_method: 'digest')
let(:graph) { 'http://example.org/' }

it 'is able to select' do
# check a single triple result which is unlikely to change

query = RDF::Virtuoso::Query.select.where([RDF::URI('http://localhost:8890/sparql'),
RDF::URI('http://www.w3.org/ns/sparql-service-description#endpoint'), :o])

expect(repository.select(query).last.o).to eql RDF::URI('http://localhost:8890/sparql')
end

it 'should be able to select' do
query = RDF::Virtuoso::Query.select.where([RDF::Resource('http://localhost:8890/sparql'), :p, :o])
expect(repo.select(query).count).to eql 14
it 'is able to insert' do
query = RDF::Virtuoso::Query.insert([RDF::URI('subject:person'), RDF::URI('http://purl.org/dc/terms/title'),
'The title']).graph(graph)
expect(repository.insert(query)).to eql 'Insert into <http://example.org/>, 1 (or less) triples -- done'

# #clean up
query = RDF::Virtuoso::Query.delete([RDF::URI('subject:person'), :p,
:o]).where([RDF::URI('subject:person'), :p, :o]).graph(graph)
repository.delete(query)
end

# it_behaves_like "an RDF::Repository" do
# let(:repository) {repo}
# let(:repository) {subject}
# end

end
end

0 comments on commit 061c2a5

Please # to comment.