Skip to content

Commit 061c2a5

Browse files
committed
extend tests to check the connection is working and some cleaning up
check with a single select which is unlikely to change, and also include a simple insert #15
1 parent d389deb commit 061c2a5

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

spec/integration_spec.rb

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$:.unshift '.'
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.unshift '.'
24
require File.join(File.dirname(__FILE__), 'spec_helper')
35
require 'rdf/spec/repository'
46

@@ -9,28 +11,43 @@
911
# docker stop virtuoso-testing
1012

1113
describe RDF::Virtuoso::Repository do
12-
context('when interating with a virtuoso repository instance') do
14+
context('when interacting with a virtuoso repository instance') do
15+
subject(:repository) do
16+
described_class.new(uri,
17+
update_uri: update_uri,
18+
username: username,
19+
password: password,
20+
auth_method: 'digest')
21+
end
22+
1323
let(:uri) { 'http://localhost:8890/sparql' }
1424
let(:update_uri) { 'http://localhost:8890/sparql-auth' }
15-
let(:repo) { RDF::Virtuoso::Repository.new(uri) }
1625
let(:password) { 'tester' }
1726
let(:username) { 'dba' }
18-
let(:repo) do
19-
RDF::Virtuoso::Repository.new(uri,
20-
update_uri: update_uri,
21-
username: username,
22-
password: password,
23-
auth_method: 'digest')
27+
let(:graph) { 'http://example.org/' }
28+
29+
it 'is able to select' do
30+
# check a single triple result which is unlikely to change
31+
32+
query = RDF::Virtuoso::Query.select.where([RDF::URI('http://localhost:8890/sparql'),
33+
RDF::URI('http://www.w3.org/ns/sparql-service-description#endpoint'), :o])
34+
35+
expect(repository.select(query).last.o).to eql RDF::URI('http://localhost:8890/sparql')
2436
end
2537

26-
it 'should be able to select' do
27-
query = RDF::Virtuoso::Query.select.where([RDF::Resource('http://localhost:8890/sparql'), :p, :o])
28-
expect(repo.select(query).count).to eql 14
38+
it 'is able to insert' do
39+
query = RDF::Virtuoso::Query.insert([RDF::URI('subject:person'), RDF::URI('http://purl.org/dc/terms/title'),
40+
'The title']).graph(graph)
41+
expect(repository.insert(query)).to eql 'Insert into <http://example.org/>, 1 (or less) triples -- done'
42+
43+
# #clean up
44+
query = RDF::Virtuoso::Query.delete([RDF::URI('subject:person'), :p,
45+
:o]).where([RDF::URI('subject:person'), :p, :o]).graph(graph)
46+
repository.delete(query)
2947
end
3048

3149
# it_behaves_like "an RDF::Repository" do
32-
# let(:repository) {repo}
50+
# let(:repository) {subject}
3351
# end
34-
3552
end
3653
end

0 commit comments

Comments
 (0)