Skip to content

Commit 71cca1e

Browse files
committed
Create subject in Repository spec. Move snapshot test from Mutable to Repository.
1 parent bb72a17 commit 71cca1e

3 files changed

Lines changed: 22 additions & 21 deletions

File tree

lib/rdf/spec/mutable.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@
8484
end
8585
end
8686

87-
describe '#snapshot' do
88-
it 'is implemented when #supports(:snapshots) is true' do
89-
if mutable.supports?(:snapshots)
90-
expect(mutable.snapshot).to be_a RDF::Dataset
91-
else
92-
expect { mutable.snapshot }.to raise_error NotImplementedError
93-
end
94-
end
95-
end
96-
9787
context "when updating statements" do
9888
let(:s1) { RDF::Statement(resource, RDF::URI.new("urn:predicate:1"), RDF::URI.new("urn:object:1")) }
9989
let(:s2) { RDF::Statement(resource, RDF::URI.new("urn:predicate:2"), RDF::URI.new("urn:object:2")) }

lib/rdf/spec/repository.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
let(:mutable) { repository }
1919
let(:dataset) { repository }
20+
subject { repository }
2021

2122
context 'as dataset' do
2223
require 'rdf/spec/dataset'
@@ -38,7 +39,7 @@
3839
end
3940
end
4041
end
41-
42+
4243
describe "#transaction" do
4344
it 'gives an immutable transaction' do
4445
expect { subject.transaction { insert([]) } }.to raise_error TypeError
@@ -71,9 +72,19 @@
7172
end
7273

7374
context "with snapshot support" do
75+
76+
describe '#snapshot' do
77+
it 'is not implemented when #supports(:snapshots) is false' do
78+
unless subject.supports?(:snapshots)
79+
expect { subject.snapshot }.to raise_error NotImplementedError
80+
end
81+
end
82+
end
83+
7484
it 'returns a queryable #snapshot' do
75-
if repository.supports? :snapshots
76-
expect(repository.snapshot).to be_a RDF::Queryable
85+
if subject.supports? :snapshots
86+
expect(subject.snapshot).to be_a RDF::Queryable
87+
expect(mutable.snapshot).to be_a RDF::Dataset
7788
end
7889
end
7990

@@ -85,17 +96,17 @@
8596
end
8697

8798
it 'gives an accurate snapshot' do
88-
if repository.supports? :snapshots
89-
snap = repository.snapshot
99+
if subject.supports? :snapshots
100+
snap = subject.snapshot
90101
expect(snap.query([:s, :p, :o]))
91-
.to contain_exactly(*repository.query([:s, :p, :o]))
102+
.to contain_exactly(*subject.query([:s, :p, :o]))
92103
end
93104
end
94105

95106
it 'gives static snapshot' do
96-
if repository.supports? :snapshots
97-
snap = repository.snapshot
98-
expect { repository.clear }
107+
if subject.supports? :snapshots
108+
snap = subject.snapshot
109+
expect { subject.clear }
99110
.not_to change { snap.query([:s, :p, :o]).to_a }
100111
end
101112
end

spec/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
begin
44
require 'simplecov'
55
require 'coveralls'
6-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
77
SimpleCov::Formatter::HTMLFormatter,
88
Coveralls::SimpleCov::Formatter
9-
]
9+
])
1010
SimpleCov.start do
1111
add_filter "matchers.rb"
1212
add_filter "inspects.rb"

0 commit comments

Comments
 (0)