|
1 |
| -$:.unshift '.' |
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +$LOAD_PATH.unshift '.' |
2 | 4 | require File.join(File.dirname(__FILE__), 'spec_helper')
|
3 | 5 | require 'rdf/spec/repository'
|
4 | 6 |
|
|
9 | 11 | # docker stop virtuoso-testing
|
10 | 12 |
|
11 | 13 | 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 | + |
13 | 23 | let(:uri) { 'http://localhost:8890/sparql' }
|
14 | 24 | let(:update_uri) { 'http://localhost:8890/sparql-auth' }
|
15 |
| - let(:repo) { RDF::Virtuoso::Repository.new(uri) } |
16 | 25 | let(:password) { 'tester' }
|
17 | 26 | 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') |
24 | 36 | end
|
25 | 37 |
|
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) |
29 | 47 | end
|
30 | 48 |
|
31 | 49 | # it_behaves_like "an RDF::Repository" do
|
32 |
| - # let(:repository) {repo} |
| 50 | + # let(:repository) {subject} |
33 | 51 | # end
|
34 |
| - |
35 | 52 | end
|
36 | 53 | end
|
0 commit comments