Skip to content

Commit 901ab96

Browse files
committed
Release 2.0.0.beta1
2 parents b8fd4c2 + 5e00e7c commit 901ab96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1533
-796
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ tmp
66
/*.gem
77
/*.lock
88
/doc/
9+
/coverage/
10+
/.byebug_history

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: ruby
2+
bundler_args: --without debug
3+
script: "bundle exec rspec spec"
4+
env:
5+
- CI=true
6+
rvm:
7+
- 2.0
8+
- 2.1
9+
- 2.2.4
10+
- 2.3.0
11+
- jruby-9.0.4.0
12+
- rbx-2
13+
cache: bundler
14+
sudo: false
15+
matrix:
16+
allow_failures:
17+
- rvm: rbx-2

Gemfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ source "http://rubygems.org"
22

33
gemspec
44

5-
gem "rdf", git: "git://github.com/ruby-rdf/rdf.git", branch: "develop"
5+
gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"
6+
gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop"
67

78
group :development do
89
gem "wirble"
910
end
11+
12+
group :debug do
13+
gem "byebug", platform: :mri
14+
end
15+
16+
group :development, :test do
17+
gem 'simplecov', require: false, platform: :mri
18+
gem 'coveralls', require: false, platform: :mri
19+
end

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and shared examples for Ruby projects that use RDF.rb and RSpec.
66
* <http://github.com/ruby-rdf/rdf-spec>
77

88
[![Gem Version](https://badge.fury.io/rb/rdf-spec.png)](http://badge.fury.io/rb/rdf-spec)
9+
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-spec.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-spec)
10+
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-spec/badge.svg)](https://coveralls.io/r/ruby-rdf/rdf-spec)
911

1012
## Documentation
1113

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.99.0
1+
2.0.0.beta1

lib/rdf/spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'rdf' # @see http://rubygems.org/gems/rdf
2+
require 'rdf/isomorphic' # @see http://rubygems.org/gems/rdf-isomorphic
23
require 'rspec' # @see http://rubygems.org/gems/rspec
34
require 'rdf/spec/inspects'
45
require 'rspec/its'
@@ -68,5 +69,22 @@ def self.triples
6869
require 'rdf/ntriples'
6970
(@triples ||= RDF::NTriples::Reader.new(File.open(TRIPLES_FILE)).to_a).dup
7071
end
72+
73+
# Logger used for Specs; allows clearing and converting to string
74+
require 'logger'
75+
def self.logger
76+
logger = Logger.new(StringIO.new)
77+
def logger.clear
78+
@logdev.instance_variable_set(:@dev, StringIO.new)
79+
end
80+
def logger.to_s
81+
dev = @logdev.instance_variable_get(:@dev)
82+
dev.rewind
83+
dev.read
84+
end
85+
logger.level = Logger::DEBUG
86+
logger.formatter = lambda {|severity, datetime, progname, msg| "#{severity} #{msg}\n"}
87+
logger
88+
end
7189
end # Spec
7290
end # RDF

lib/rdf/spec/countable.rb

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
RSpec.shared_examples 'an RDF::Countable' do
44
include RDF::Spec::Matchers
55

6+
let(:statements) {RDF::Spec.quads}
67
before do
78
raise 'countable must be set with `let(:countable)' unless
89
defined? countable
910

10-
@statements = RDF::Spec.quads
11-
1211
if countable.empty?
1312
if (countable.writable? rescue false)
14-
countable.send(:insert_statements, @statements)
13+
countable.send(:insert_statements, statements)
1514
elsif countable.respond_to?(:<<)
16-
@statements.each { |statement| countable << statement }
15+
statements.each { |statement| countable << statement }
1716
else
1817
raise "+countable+ must respond to #<< or be pre-populated with the" \
1918
"statements in #{RDF::Spec::TRIPLES_FILE} in a before block"
@@ -27,9 +26,9 @@
2726
it {is_expected.to respond_to(:empty?)}
2827
it {is_expected.to_not be_empty}
2928
it {is_expected.to respond_to(:count)}
30-
its(:count) {is_expected.to eq @statements.size}
29+
its(:count) {is_expected.to eq statements.size}
3130
it {is_expected.to respond_to(:size)}
32-
its(:size) {is_expected.to eq @statements.size}
31+
its(:size) {is_expected.to eq statements.size}
3332

3433
context "when empty" do
3534
subject {[].extend(RDF::Countable)}
@@ -45,25 +44,3 @@
4544
end
4645
end
4746
end
48-
49-
##
50-
# @deprecated use `it_behaves_like "an RDF::Countable"` instead
51-
module RDF_Countable
52-
extend RSpec::SharedContext
53-
include RDF::Spec::Matchers
54-
55-
def self.included(mod)
56-
warn "[DEPRECATION] `RDF_Countable` is deprecated. "\
57-
"Please use `it_behaves_like 'an RDF::Countable'`"
58-
end
59-
60-
describe 'examples for' do
61-
include_examples 'an RDF::Countable' do
62-
let(:countable) { @countable }
63-
64-
before do
65-
raise '@countable must be defined' unless defined?(countable)
66-
end
67-
end
68-
end
69-
end

lib/rdf/spec/dataset.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require 'rdf/spec'
2+
3+
RSpec.shared_examples 'an RDF::Dataset' do
4+
include RDF::Spec::Matchers
5+
6+
before :each do
7+
raise 'dataset must be set with `let(:dataset)' unless
8+
defined? dataset
9+
10+
if dataset.empty?
11+
raise "+dataset+ must respond be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before block"
12+
end
13+
end
14+
15+
let(:countable) { dataset }
16+
let(:enumerable) { dataset }
17+
let(:queryable) { dataset }
18+
19+
context "when counting statements" do
20+
require 'rdf/spec/countable'
21+
it_behaves_like 'an RDF::Countable'
22+
end
23+
24+
context "when enumerating statements" do
25+
require 'rdf/spec/enumerable'
26+
it_behaves_like 'an RDF::Enumerable'
27+
end
28+
29+
context "as durable" do
30+
require 'rdf/spec/durable'
31+
before { @load_durable ||= lambda { dataset } }
32+
33+
it_behaves_like 'an RDF::Durable'
34+
end
35+
36+
context "when querying statements" do
37+
require 'rdf/spec/queryable'
38+
it_behaves_like 'an RDF::Queryable'
39+
end
40+
41+
describe '#isolation_level' do
42+
it 'is an allowable isolation level' do
43+
expect(described_class::ISOLATION_LEVELS)
44+
.to include(dataset.isolation_level)
45+
end
46+
end
47+
end

lib/rdf/spec/durable.rb

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#describe RDF::DataObjects::Repository do
77
# context "The SQLite adapter" do
88
# before :each do
9-
# @repository = RDF::DataObjects::Repository.new "sqlite3://:memory:"
10-
# @load_durable = lambda { RDF::DataObjects::Repository.new "sqlite3:test.db" }
9+
# @load_durable = lambda { RDF::DataObjects::Repository.new uri: "sqlite3:test.db" }
1110
# end
1211
#
1312
# after :each do
@@ -29,38 +28,24 @@
2928

3029
it { is_expected.to respond_to(:durable?) }
3130

32-
it "is_expected.to support #durable?" do
31+
it "supports #durable?" do
3332
expect([true,false]).to be_member(subject.durable?)
3433
end
3534

3635
it {is_expected.to respond_to(:nondurable?)}
3736

38-
it "is_expected.to support #nondurable?" do
37+
it "supports #nondurable?" do
3938
expect([true,false]).to be_member(@load_durable.call.nondurable?)
4039
end
4140

4241
its(:nondurable?) {is_expected.to_not eq subject.durable?}
4342

44-
it "is_expected.to save contents between instantiations" do
43+
it "saves contents between instantiations" do
4544
if subject.durable?
46-
subject.load(RDF::Spec::TRIPLES_FILE)
47-
expect(subject.count).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
45+
subject.insert RDF::Statement(RDF::RDFS.Resource, RDF.value, "string") if subject.empty?
46+
subject.close if subject.respond_to?(:close)
47+
new_instance = @load_durable.call
48+
expect(new_instance).not_to be_empty
4849
end
4950
end
5051
end
51-
52-
##
53-
# @deprecated use `it_behaves_like "an RDF::Durable"` instead
54-
module RDF_Durable
55-
extend RSpec::SharedContext
56-
include RDF::Spec::Matchers
57-
58-
def self.included(mod)
59-
warn "[DEPRECATION] `RDF_Durable` is deprecated. "\
60-
"Please use `it_behaves_like 'an RDF::Durable'`"
61-
end
62-
63-
describe 'examples for' do
64-
include_examples 'an RDF::Durable'
65-
end
66-
end

0 commit comments

Comments
 (0)