rdf-spec 1.0.9 → 1.1.0.p1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/AUTHORS +1 -1
- data/README +16 -23
- data/VERSION +1 -1
- data/etc/bendiken.nq +8 -8
- data/etc/bendiken.nt +8 -0
- data/etc/bendiken.ttl +17 -0
- data/etc/bhuga.nq +6 -6
- data/etc/bhuga.nt +6 -0
- data/etc/bhuga.ttl +15 -0
- data/etc/{triples.nt → doap.nq} +73 -76
- data/etc/doap.nt +39 -39
- data/etc/doap.ttl +79 -0
- data/etc/gkellogg.nq +5 -6
- data/etc/gkellogg.nt +5 -0
- data/etc/gkellogg.ttl +14 -0
- data/etc/test-data.nt +1 -0
- data/lib/rdf/spec.rb +0 -20
- data/lib/rdf/spec/countable.rb +26 -21
- data/lib/rdf/spec/durable.rb +13 -9
- data/lib/rdf/spec/enumerable.rb +314 -264
- data/lib/rdf/spec/format.rb +8 -9
- data/lib/rdf/spec/indexable.rb +13 -6
- data/lib/rdf/spec/matchers.rb +38 -38
- data/lib/rdf/spec/mutable.rb +81 -84
- data/lib/rdf/spec/queryable.rb +168 -195
- data/lib/rdf/spec/readable.rb +7 -3
- data/lib/rdf/spec/reader.rb +43 -43
- data/lib/rdf/spec/repository.rb +26 -15
- data/lib/rdf/spec/transaction.rb +90 -42
- data/lib/rdf/spec/writable.rb +55 -68
- data/lib/rdf/spec/writer.rb +36 -35
- data/spec/version_spec.rb +1 -1
- metadata +41 -34
- data/etc/quads.nq +0 -95
data/lib/rdf/spec/readable.rb
CHANGED
@@ -9,8 +9,12 @@ module RDF_Readable
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe RDF::Readable do
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
it "responds to #readable?" do
|
13
|
+
@readable.respond_to?(:readable?)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "implements #readable?" do
|
17
|
+
!!@readable.readable?.should == @readable.readable?
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
data/lib/rdf/spec/reader.rb
CHANGED
@@ -13,25 +13,25 @@ module RDF_Reader
|
|
13
13
|
describe ".each" do
|
14
14
|
it "yields each reader" do
|
15
15
|
@reader_class.each do |r|
|
16
|
-
|
16
|
+
r.should_not be_nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe ".open" do
|
22
22
|
before(:each) do
|
23
|
-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
|
23
|
+
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
|
24
24
|
end
|
25
25
|
|
26
26
|
it "yields reader given file_name" do
|
27
27
|
@reader_class.format.each do |f|
|
28
|
-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
|
28
|
+
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
|
29
29
|
f.file_extensions.each_pair do |sym, content_type|
|
30
|
-
reader_mock =
|
31
|
-
|
32
|
-
|
30
|
+
reader_mock = mock("reader")
|
31
|
+
reader_mock.should_receive(:got_here)
|
32
|
+
@reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
|
33
33
|
@reader_class.open("foo.#{sym}") do |r|
|
34
|
-
|
34
|
+
r.should be_a(RDF::Reader)
|
35
35
|
reader_mock.got_here
|
36
36
|
end
|
37
37
|
end
|
@@ -40,13 +40,13 @@ module RDF_Reader
|
|
40
40
|
|
41
41
|
it "yields reader given symbol" do
|
42
42
|
@reader_class.format.each do |f|
|
43
|
-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
|
43
|
+
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
|
44
44
|
sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
|
45
|
-
reader_mock =
|
46
|
-
|
47
|
-
|
45
|
+
reader_mock = mock("reader")
|
46
|
+
reader_mock.should_receive(:got_here)
|
47
|
+
@reader_class.should_receive(:for).with(sym).and_return(@reader_class)
|
48
48
|
@reader_class.open("foo.#{sym}", :format => sym) do |r|
|
49
|
-
|
49
|
+
r.should be_a(RDF::Reader)
|
50
50
|
reader_mock.got_here
|
51
51
|
end
|
52
52
|
end
|
@@ -54,13 +54,13 @@ module RDF_Reader
|
|
54
54
|
|
55
55
|
it "yields reader given {:file_name => file_name}" do
|
56
56
|
@reader_class.format.each do |f|
|
57
|
-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
|
57
|
+
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
|
58
58
|
f.file_extensions.each_pair do |sym, content_type|
|
59
|
-
reader_mock =
|
60
|
-
|
61
|
-
|
59
|
+
reader_mock = mock("reader")
|
60
|
+
reader_mock.should_receive(:got_here)
|
61
|
+
@reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
|
62
62
|
@reader_class.open("foo.#{sym}", :file_name => "foo.#{sym}") do |r|
|
63
|
-
|
63
|
+
r.should be_a(RDF::Reader)
|
64
64
|
reader_mock.got_here
|
65
65
|
end
|
66
66
|
end
|
@@ -69,13 +69,13 @@ module RDF_Reader
|
|
69
69
|
|
70
70
|
it "yields reader given {:content_type => 'a/b'}" do
|
71
71
|
@reader_class.format.each do |f|
|
72
|
-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
|
72
|
+
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
|
73
73
|
f.content_types.each_pair do |content_type, formats|
|
74
|
-
reader_mock =
|
75
|
-
|
76
|
-
|
74
|
+
reader_mock = mock("reader")
|
75
|
+
reader_mock.should_receive(:got_here)
|
76
|
+
@reader_class.should_receive(:for).with(:content_type => content_type, :file_name => "foo").and_return(@reader_class)
|
77
77
|
@reader_class.open("foo", :content_type => content_type) do |r|
|
78
|
-
|
78
|
+
r.should be_a(RDF::Reader)
|
79
79
|
reader_mock.got_here
|
80
80
|
end
|
81
81
|
end
|
@@ -86,27 +86,27 @@ module RDF_Reader
|
|
86
86
|
describe ".format" do
|
87
87
|
it "returns itself even if given explicit format" do
|
88
88
|
other_format = @reader_class == RDF::NTriples::Reader ? :nquads : :ntriples
|
89
|
-
|
89
|
+
@reader_class.for(other_format).should == @reader_class
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
describe ".new" do
|
94
94
|
it "sets @input to StringIO given a string" do
|
95
|
-
reader_mock =
|
96
|
-
|
95
|
+
reader_mock = mock("reader")
|
96
|
+
reader_mock.should_receive(:got_here)
|
97
97
|
@reader_class.new("string") do |r|
|
98
98
|
reader_mock.got_here
|
99
|
-
|
99
|
+
r.instance_variable_get(:@input).should be_a(StringIO)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
it "sets @input to input given something other than a string" do
|
104
|
-
reader_mock =
|
105
|
-
|
104
|
+
reader_mock = mock("reader")
|
105
|
+
reader_mock.should_receive(:got_here)
|
106
106
|
file = StringIO.new("")
|
107
107
|
@reader_class.new(file) do |r|
|
108
108
|
reader_mock.got_here
|
109
|
-
|
109
|
+
r.instance_variable_get(:@input).should == file
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -114,37 +114,37 @@ module RDF_Reader
|
|
114
114
|
# Either set validate, or through error, due to invalid input (null input may be invalid)
|
115
115
|
begin
|
116
116
|
@reader_class.new("string", :validate => true) do |r|
|
117
|
-
|
117
|
+
r.send(:validate?).should be_true
|
118
118
|
end
|
119
119
|
rescue
|
120
|
-
|
120
|
+
$!.should be_a(RDF::ReaderError) # An error is acceptable
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
it "sets canonicalize given :canonicalize => true" do
|
125
|
-
reader_mock =
|
126
|
-
|
125
|
+
reader_mock = mock("reader")
|
126
|
+
reader_mock.should_receive(:got_here)
|
127
127
|
@reader_class.new("string", :canonicalize => true) do |r|
|
128
128
|
reader_mock.got_here
|
129
|
-
|
129
|
+
r.send(:canonicalize?).should be_true
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
133
|
it "sets intern given :intern => true" do
|
134
|
-
reader_mock =
|
135
|
-
|
134
|
+
reader_mock = mock("reader")
|
135
|
+
reader_mock.should_receive(:got_here)
|
136
136
|
@reader_class.new("string", :intern => true) do |r|
|
137
137
|
reader_mock.got_here
|
138
|
-
|
138
|
+
r.send(:intern?).should be_true
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
142
|
it "sets prefixes given :prefixes => {}" do
|
143
|
-
reader_mock =
|
144
|
-
|
143
|
+
reader_mock = mock("reader")
|
144
|
+
reader_mock.should_receive(:got_here)
|
145
145
|
@reader_class.new("string", :prefixes => {:a => "b"}) do |r|
|
146
146
|
reader_mock.got_here
|
147
|
-
|
147
|
+
r.prefixes.should == {:a => "b"}
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
@@ -152,7 +152,7 @@ module RDF_Reader
|
|
152
152
|
describe "#prefixes=" do
|
153
153
|
it "sets prefixes from hash" do
|
154
154
|
@reader.prefixes = {:a => "b"}
|
155
|
-
|
155
|
+
@reader.prefixes.should == {:a => "b"}
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -163,8 +163,8 @@ module RDF_Reader
|
|
163
163
|
"foo" => "bar",
|
164
164
|
}.each_pair do |pfx, uri|
|
165
165
|
it "sets prefix(#{pfx}) to #{uri}" do
|
166
|
-
|
167
|
-
|
166
|
+
@reader.prefix(pfx, uri).should == uri
|
167
|
+
@reader.prefix(pfx).should == uri
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
data/lib/rdf/spec/repository.rb
CHANGED
@@ -6,50 +6,61 @@ module RDF_Repository
|
|
6
6
|
|
7
7
|
before :each do
|
8
8
|
raise '+@repository+ must be defined in a before(:each) block' unless instance_variable_get('@repository')
|
9
|
-
@
|
10
|
-
|
11
|
-
@repository.insert(*@statements)
|
12
|
-
elsif @repository.empty?
|
13
|
-
raise "+@repository+ must respond to #<< or be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before(:each) block"
|
14
|
-
end
|
15
|
-
@countable = @repository
|
9
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
10
|
+
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
16
11
|
@enumerable = @repository
|
17
|
-
@queryable = @repository
|
18
|
-
@mutable = @repository
|
19
12
|
end
|
20
13
|
|
21
14
|
describe RDF::Repository do
|
22
|
-
|
23
15
|
context "when counting statements" do
|
24
16
|
require 'rdf/spec/countable'
|
17
|
+
|
18
|
+
before :each do
|
19
|
+
@countable = @repository
|
20
|
+
@countable.insert(*@statements)
|
21
|
+
end
|
22
|
+
|
25
23
|
include RDF_Countable
|
26
24
|
end
|
27
25
|
|
28
26
|
context "when enumerating statements" do
|
29
27
|
require 'rdf/spec/enumerable'
|
28
|
+
|
29
|
+
before :each do
|
30
|
+
@enumerable = @repository
|
31
|
+
@enumerable.insert(*@statements)
|
32
|
+
end
|
33
|
+
|
30
34
|
include RDF_Enumerable
|
31
35
|
end
|
32
36
|
|
33
37
|
context "when querying statements" do
|
34
38
|
require 'rdf/spec/queryable'
|
39
|
+
|
40
|
+
before :each do
|
41
|
+
@queryable = @repository
|
42
|
+
@subject = RDF::URI.new('http://rubygems.org/gems/rdf')
|
43
|
+
end
|
44
|
+
|
35
45
|
include RDF_Queryable
|
36
46
|
end
|
37
47
|
|
38
|
-
# FIXME: This should be condition on the repository being mutable
|
39
48
|
context "when updating" do
|
40
49
|
require 'rdf/spec/mutable'
|
41
|
-
|
42
|
-
|
50
|
+
|
51
|
+
before :each do
|
52
|
+
@mutable = @repository
|
53
|
+
@subject = RDF::URI.new('http://rubygems.org/gems/rdf')
|
54
|
+
@context = RDF::URI.new('http://example.org/context')
|
43
55
|
end
|
56
|
+
|
44
57
|
include RDF_Mutable
|
45
58
|
end
|
46
59
|
|
47
|
-
# FIXME: This should be condition on the repository being mutable
|
48
60
|
context "as a durable repository" do
|
49
61
|
require 'rdf/spec/durable'
|
50
62
|
|
51
63
|
before :each do
|
52
|
-
@repository.clear
|
53
64
|
@load_durable ||= lambda { @repository }
|
54
65
|
end
|
55
66
|
|
data/lib/rdf/spec/transaction.rb
CHANGED
@@ -1,62 +1,110 @@
|
|
1
1
|
require 'rdf/spec'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Pass in an instance of RDF::Transaction as follows:
|
4
|
+
#
|
5
|
+
# it_behaves_like "RDF_Transaction", RDF::Transaction
|
6
|
+
shared_examples "RDF_Transaction" do |klass|
|
5
7
|
include RDF::Spec::Matchers
|
6
8
|
|
7
|
-
before :each do
|
8
|
-
raise '+@transaction+ must be defined in a before(:each) block' unless instance_variable_get('@transaction')
|
9
|
-
end
|
10
|
-
|
11
9
|
describe RDF::Transaction do
|
12
|
-
|
10
|
+
subject {klass.new(:context => RDF::URI("name"), :insert => RDF::Graph.new, :delete => RDF::Graph.new)}
|
11
|
+
|
13
12
|
describe "#initialize" do
|
14
|
-
|
15
|
-
it "accepts a
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it "
|
13
|
+
subject {klass}
|
14
|
+
it "accepts a graph" do
|
15
|
+
g = mock("graph")
|
16
|
+
this = subject.new(:graph => g)
|
17
|
+
this.graph.should == g
|
18
|
+
end
|
19
|
+
|
20
|
+
it "accepts a context" do
|
21
|
+
c = mock("context")
|
22
|
+
this = subject.new(:graph => c)
|
23
|
+
this.graph.should == c
|
24
|
+
this.context.should == c
|
25
|
+
|
26
|
+
this = subject.new(:context => c)
|
27
|
+
this.graph.should == c
|
28
|
+
this.context.should == c
|
29
|
+
end
|
30
|
+
|
31
|
+
it "accepts inserts" do
|
32
|
+
g = mock("inserts")
|
33
|
+
this = subject.new(:insert => g)
|
34
|
+
this.inserts.should == g
|
35
|
+
end
|
36
|
+
|
37
|
+
it "accepts deletes" do
|
38
|
+
g = mock("deletes")
|
39
|
+
this = subject.new(:delete => g)
|
40
|
+
this.deletes.should == g
|
41
|
+
end
|
22
42
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
43
|
+
|
44
|
+
its(:deletes) {should be_a(RDF::Enumerable)}
|
45
|
+
its(:inserts) {should be_a(RDF::Enumerable)}
|
46
|
+
it {should be_mutable}
|
47
|
+
it {should_not be_readable}
|
48
|
+
|
49
|
+
it "does not respond to #load" do
|
50
|
+
lambda {subject.load("http://example/")}.should raise_error(NoMethodError)
|
26
51
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
52
|
+
|
53
|
+
it "does not respond to #update" do
|
54
|
+
lambda {subject.update(RDF::Statement.new)}.should raise_error(NoMethodError)
|
30
55
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(@transaction.readable?).to be_false
|
35
|
-
end
|
56
|
+
|
57
|
+
it "does not respond to #clear" do
|
58
|
+
lambda {subject.clear}.should raise_error(NoMethodError)
|
36
59
|
end
|
37
|
-
|
60
|
+
|
38
61
|
describe "#execute" do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
it "
|
43
|
-
|
44
|
-
|
45
|
-
|
62
|
+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
|
63
|
+
let(:r) {mock("repository")}
|
64
|
+
|
65
|
+
it "deletes statements" do
|
66
|
+
r.should_receive(:delete).with(s)
|
67
|
+
r.should_not_receive(:insert)
|
68
|
+
subject.delete(s)
|
69
|
+
subject.execute(r)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "inserts statements" do
|
73
|
+
r.should_not_receive(:delete)
|
74
|
+
r.should_receive(:insert).with(s)
|
75
|
+
subject.insert(s)
|
76
|
+
subject.execute(r)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "calls before_execute" do
|
80
|
+
subject.should_receive(:before_execute).with(r, {})
|
81
|
+
subject.execute(r)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "calls after_execute" do
|
85
|
+
subject.should_receive(:after_execute).with(r, {})
|
86
|
+
subject.execute(r)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns self" do
|
90
|
+
subject.execute(r).should == subject
|
91
|
+
end
|
46
92
|
end
|
47
93
|
|
48
94
|
describe "#delete_statement" do
|
49
|
-
|
50
|
-
it "
|
95
|
+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
|
96
|
+
it "adds statement to #deletes" do
|
97
|
+
subject.delete(s)
|
98
|
+
subject.deletes.to_a.should == [s]
|
99
|
+
end
|
51
100
|
end
|
52
101
|
|
53
102
|
describe "#insert_statement" do
|
54
|
-
|
55
|
-
it "
|
103
|
+
let(:s) {RDF::Statement.new(RDF::URI("s"), RDF::URI("p"), RDF::URI("o"))}
|
104
|
+
it "adds statement to #inserts" do
|
105
|
+
subject.insert(s)
|
106
|
+
subject.inserts.to_a.should == [s]
|
107
|
+
end
|
56
108
|
end
|
57
|
-
|
58
|
-
it "does not respond to #load"
|
59
|
-
it "does not respond to #update"
|
60
|
-
it "does not respond to #clear"
|
61
109
|
end
|
62
110
|
end
|
data/lib/rdf/spec/writable.rb
CHANGED
@@ -7,130 +7,117 @@ module RDF_Writable
|
|
7
7
|
before :each do
|
8
8
|
raise '+@writable+ must be defined in a before(:each) block' unless instance_variable_get('@writable')
|
9
9
|
|
10
|
-
@filename =
|
10
|
+
@filename = File.expand_path("../../../../etc/doap.nt", __FILE__)
|
11
11
|
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
12
12
|
|
13
13
|
@supports_context = @writable.respond_to?(:supports?) && @writable.supports?(:context)
|
14
14
|
end
|
15
15
|
|
16
16
|
describe RDF::Writable do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
it {should respond_to(:writable?)}
|
22
|
-
its(:writable?) {should == !!subject.writable?}
|
17
|
+
it "responds to #writable?" do
|
18
|
+
@writable.respond_to?(:readable?)
|
19
|
+
end
|
23
20
|
|
21
|
+
it "implements #writable?" do
|
22
|
+
!!@writable.writable?.should == @writable.writable?
|
23
|
+
end
|
24
|
+
|
24
25
|
describe "#<<" do
|
25
26
|
it "inserts a reader" do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expect(subject.count).to eq count
|
31
|
-
end
|
27
|
+
reader = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
28
|
+
@writable << reader
|
29
|
+
@writable.should have_statement(@statements.first)
|
30
|
+
@writable.count.should == @statements.size
|
32
31
|
end
|
33
32
|
|
34
33
|
it "inserts a graph" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
expect(subject.count).to eq count
|
40
|
-
end
|
34
|
+
graph = RDF::Graph.new << @statements
|
35
|
+
@writable << graph
|
36
|
+
@writable.should have_statement(@statements.first)
|
37
|
+
@writable.count.should == @statements.size
|
41
38
|
end
|
42
39
|
|
43
40
|
it "inserts an enumerable" do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
expect(subject.count).to eq count
|
49
|
-
end
|
41
|
+
enumerable = @statements.dup.extend(RDF::Enumerable)
|
42
|
+
@writable << enumerable
|
43
|
+
@writable.should have_statement(@statements.first)
|
44
|
+
@writable.count.should == @statements.size
|
50
45
|
end
|
51
46
|
|
52
47
|
it "inserts data responding to #to_rdf" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
expect(subject.count).to eq count
|
59
|
-
end
|
48
|
+
mock = double('mock')
|
49
|
+
mock.stub(:to_rdf).and_return(@statements)
|
50
|
+
@writable << mock
|
51
|
+
@writable.should have_statement(@statements.first)
|
52
|
+
@writable.count.should == @statements.size
|
60
53
|
end
|
61
54
|
|
62
55
|
it "inserts a statement" do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
expect(subject.count).to eq 1
|
67
|
-
end
|
56
|
+
@writable << @statements.first
|
57
|
+
@writable.should have_statement(@statements.first)
|
58
|
+
@writable.count.should == 1
|
68
59
|
end
|
69
60
|
|
70
61
|
it "inserts an invalid statement" do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
expect(subject.count).to eq 1
|
76
|
-
end
|
62
|
+
s = RDF::Statement.from([nil, nil, nil])
|
63
|
+
s.should_not be_valid
|
64
|
+
@writable << s
|
65
|
+
@writable.count.should == 1
|
77
66
|
end
|
78
67
|
end
|
79
68
|
|
80
69
|
context "when inserting statements" do
|
81
70
|
it "should support #insert" do
|
82
|
-
|
83
|
-
expect(subject).to respond_to(:insert)
|
84
|
-
end
|
71
|
+
@writable.should respond_to(:insert)
|
85
72
|
end
|
86
73
|
|
87
74
|
it "should not raise errors" do
|
88
|
-
|
89
|
-
|
75
|
+
if @writable.writable?
|
76
|
+
lambda { @writable.insert(@statements.first) }.should_not raise_error
|
90
77
|
end
|
91
78
|
end
|
92
79
|
|
93
80
|
it "should support inserting one statement at a time" do
|
94
|
-
|
95
|
-
|
96
|
-
|
81
|
+
if @writable.writable?
|
82
|
+
@writable.insert(@statements.first)
|
83
|
+
@writable.should have_statement(@statements.first)
|
97
84
|
end
|
98
85
|
end
|
99
86
|
|
100
87
|
it "should support inserting multiple statements at a time" do
|
101
|
-
|
102
|
-
|
88
|
+
if @writable.writable?
|
89
|
+
@writable.insert(*@statements)
|
103
90
|
end
|
104
91
|
end
|
105
92
|
|
106
93
|
it "should insert statements successfully" do
|
107
|
-
|
108
|
-
|
109
|
-
|
94
|
+
if @writable.writable?
|
95
|
+
@writable.insert(*@statements)
|
96
|
+
@writable.count.should == @statements.size
|
110
97
|
end
|
111
98
|
end
|
112
99
|
|
113
100
|
it "should not insert a statement twice" do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
101
|
+
if @writable.writable?
|
102
|
+
@writable.insert(@statements.first)
|
103
|
+
@writable.insert(@statements.first)
|
104
|
+
@writable.count.should == 1
|
118
105
|
end
|
119
106
|
end
|
120
107
|
|
121
108
|
it "should treat statements with a different context as distinct" do
|
122
|
-
|
123
|
-
s1 =
|
109
|
+
if @writable.writable?
|
110
|
+
s1 = @statements.first.dup
|
124
111
|
s1.context = nil
|
125
|
-
s2 =
|
112
|
+
s2 = @statements.first.dup
|
126
113
|
s2.context = RDF::URI.new("urn:context:1")
|
127
|
-
s3 =
|
114
|
+
s3 = @statements.first.dup
|
128
115
|
s3.context = RDF::URI.new("urn:context:2")
|
129
|
-
|
130
|
-
|
131
|
-
|
116
|
+
@writable.insert(s1)
|
117
|
+
@writable.insert(s2)
|
118
|
+
@writable.insert(s3)
|
132
119
|
# If contexts are not suported, all three are redundant
|
133
|
-
|
120
|
+
@writable.count.should == (@supports_context ? 3 : 1)
|
134
121
|
end
|
135
122
|
end
|
136
123
|
end
|