From 598328ff4592d2487504ebf5a30fbc46045c0085 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Tue, 16 Feb 2016 15:16:12 -0800 Subject: [PATCH] Add dataset_spec and repository_spec. From repository, use snapshot it repo supports snapshots for including dataset. --- Gemfile | 4 ++-- lib/rdf/spec/dataset.rb | 2 +- lib/rdf/spec/repository.rb | 2 +- spec/dataset_spec.rb | 14 ++++++++++++++ spec/repository_spec.rb | 11 +++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 spec/dataset_spec.rb create mode 100644 spec/repository_spec.rb diff --git a/Gemfile b/Gemfile index c518d14..cf8b9a2 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source "http://rubygems.org" gemspec -gem "rdf", git: "git://github.com/ruby-rdf/rdf.git", branch: "develop" -gem "rdf-isomorphic", git: "git://github.com/ruby-rdf/rdf-isomorphic.git", branch: "develop" +gem 'rdf', github: "ruby-rdf/rdf", branch: "develop" +gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop" group :development do gem "wirble" diff --git a/lib/rdf/spec/dataset.rb b/lib/rdf/spec/dataset.rb index 8f83252..e8fc82a 100644 --- a/lib/rdf/spec/dataset.rb +++ b/lib/rdf/spec/dataset.rb @@ -7,7 +7,7 @@ raise 'dataset must be set with `let(:dataset)' unless defined? dataset - if repository.empty? + if dataset.empty? raise "+dataset+ must respond be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before block" end end diff --git a/lib/rdf/spec/repository.rb b/lib/rdf/spec/repository.rb index 4a872c0..ba379f1 100644 --- a/lib/rdf/spec/repository.rb +++ b/lib/rdf/spec/repository.rb @@ -16,7 +16,7 @@ end let(:mutable) { repository } - let(:dataset) { repository } + let(:dataset) { repository.supports?(:snapshots) ? repository.snapshot : repository } subject { repository } context 'as dataset' do diff --git a/spec/dataset_spec.rb b/spec/dataset_spec.rb new file mode 100644 index 0000000..28e7e0a --- /dev/null +++ b/spec/dataset_spec.rb @@ -0,0 +1,14 @@ +require File.join(File.dirname(__FILE__), 'spec_helper') +require 'rdf/spec/dataset' + +describe RDF::Dataset do + + let(:dataset) do + RDF::Repository.new do |r| + r.insert(*RDF::Spec.quads) + end.snapshot + end + + # @see lib/rdf/spec/dataset.rb in rdf-spec + it_behaves_like 'an RDF::Dataset' +end diff --git a/spec/repository_spec.rb b/spec/repository_spec.rb new file mode 100644 index 0000000..c20c627 --- /dev/null +++ b/spec/repository_spec.rb @@ -0,0 +1,11 @@ +require File.join(File.dirname(__FILE__), 'spec_helper') +require 'rdf/spec/repository' + +describe RDF::Repository do + # @see lib/rdf/spec/repository.rb in rdf-spec + it_behaves_like 'an RDF::Repository' do + # The available reference implementations are `RDF::Repository` and + # `RDF::Graph`, but a plain Ruby array will do fine as well: + let(:repository) { RDF::Repository.new } + end +end