rdf-spec 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/VERSION +1 -1
- data/lib/rdf/spec/enumerable.rb +44 -8
- data/lib/rdf/spec/graph.rb +46 -0
- data/lib/rdf/spec/literal.rb +160 -0
- data/lib/rdf/spec/mutable.rb +12 -3
- data/lib/rdf/spec/node.rb +14 -0
- data/lib/rdf/spec/statement.rb +172 -0
- data/lib/rdf/spec/uri.rb +49 -0
- data/lib/rdf/spec/value.rb +30 -0
- data/lib/rdf/spec/version.rb +1 -1
- metadata +11 -5
data/README
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/rdf/spec/enumerable.rb
CHANGED
@@ -40,7 +40,8 @@ share_as :RDF_Enumerable do
|
|
40
40
|
@enumerable.has_statement?(statement).should be_true
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
unknown_statement = RDF::Statement.new(RDF::Node.new, RDF::URI.new("http://example.org/unknown"), RDF::Node.new)
|
44
|
+
@enumerable.has_statement?(unknown_statement).should be_false
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should support #each_statement" do
|
@@ -130,16 +131,25 @@ share_as :RDF_Enumerable do
|
|
130
131
|
it "should support #has_subject?" do
|
131
132
|
@enumerable.respond_to?(:has_subject?).should be_true
|
132
133
|
|
134
|
+
checked = []
|
133
135
|
@statements.each do |statement|
|
134
|
-
@enumerable.has_subject?(statement.subject).should be_true
|
136
|
+
@enumerable.has_subject?(statement.subject).should be_true unless checked.include?(statement.subject)
|
137
|
+
checked << statement.subject
|
135
138
|
end
|
139
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
140
|
+
@enumerable.has_predicate?(uri).should be_false
|
136
141
|
end
|
137
142
|
|
138
143
|
it "should support #each_subject" do
|
139
144
|
@enumerable.respond_to?(:each_subject).should be_true
|
140
145
|
|
141
146
|
@enumerable.each_subject.should be_instance_of(Enumerable::Enumerator)
|
142
|
-
@
|
147
|
+
subjects = @statements.map { |s| s.subject }.uniq
|
148
|
+
@enumerable.each_subject.to_a.size.should == subjects.size
|
149
|
+
@enumerable.each_subject do |value|
|
150
|
+
value.should be_a_value
|
151
|
+
subjects.should include value
|
152
|
+
end
|
143
153
|
end
|
144
154
|
|
145
155
|
it "should support #enum_subject" do
|
@@ -160,16 +170,25 @@ share_as :RDF_Enumerable do
|
|
160
170
|
it "should support #has_predicate?" do
|
161
171
|
@enumerable.respond_to?(:has_predicate?).should be_true
|
162
172
|
|
173
|
+
checked = []
|
163
174
|
@statements.each do |statement|
|
164
|
-
@enumerable.has_predicate?(statement.predicate).should be_true
|
175
|
+
@enumerable.has_predicate?(statement.predicate).should be_true unless checked.include?(statement.object)
|
176
|
+
checked << statement.predicate
|
165
177
|
end
|
178
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
179
|
+
@enumerable.has_predicate?(uri).should be_false
|
166
180
|
end
|
167
181
|
|
168
182
|
it "should support #each_predicate" do
|
169
183
|
@enumerable.respond_to?(:each_predicate).should be_true
|
170
184
|
|
185
|
+
predicates = @statements.map { |s| s.predicate }.uniq
|
186
|
+
@enumerable.each_predicate.to_a.size.should == predicates.size
|
171
187
|
@enumerable.each_predicate.should be_instance_of(Enumerable::Enumerator)
|
172
|
-
@enumerable.each_predicate
|
188
|
+
@enumerable.each_predicate do |value|
|
189
|
+
value.should be_a_uri
|
190
|
+
predicates.should include value
|
191
|
+
end
|
173
192
|
end
|
174
193
|
|
175
194
|
it "should support #enum_predicate" do
|
@@ -190,16 +209,25 @@ share_as :RDF_Enumerable do
|
|
190
209
|
it "should support #has_object?" do
|
191
210
|
@enumerable.respond_to?(:has_object?).should be_true
|
192
211
|
|
212
|
+
checked = []
|
193
213
|
@statements.each do |statement|
|
194
|
-
@enumerable.has_object?(statement.object).should be_true
|
214
|
+
@enumerable.has_object?(statement.object).should be_true unless checked.include?(statement.object)
|
215
|
+
checked << statement.object
|
195
216
|
end
|
217
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
218
|
+
@enumerable.has_object?(uri).should be_false
|
196
219
|
end
|
197
220
|
|
198
221
|
it "should support #each_object" do
|
199
222
|
@enumerable.respond_to?(:each_object).should be_true
|
200
223
|
|
224
|
+
objects = @statements.map { |s| s.object }.uniq
|
225
|
+
@enumerable.each_object.to_a.size.should == objects.size
|
201
226
|
@enumerable.each_object.should be_instance_of(Enumerable::Enumerator)
|
202
|
-
@enumerable.each_object
|
227
|
+
@enumerable.each_object do |value|
|
228
|
+
value.should be_a_value
|
229
|
+
objects.should include value
|
230
|
+
end
|
203
231
|
end
|
204
232
|
|
205
233
|
it "should support #enum_object" do
|
@@ -225,13 +253,21 @@ share_as :RDF_Enumerable do
|
|
225
253
|
@enumerable.has_context?(statement.context).should be_true
|
226
254
|
end
|
227
255
|
end
|
256
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
257
|
+
@enumerable.has_context?(uri).should be_false
|
228
258
|
end
|
229
259
|
|
230
260
|
it "should support #each_context" do
|
231
261
|
@enumerable.respond_to?(:each_context).should be_true
|
232
262
|
|
263
|
+
contexts = @statements.map { |s| s.context }.uniq
|
264
|
+
contexts.delete nil
|
265
|
+
@enumerable.each_context.to_a.size.should == contexts.size
|
233
266
|
@enumerable.each_context.should be_instance_of(Enumerable::Enumerator)
|
234
|
-
@enumerable.each_context
|
267
|
+
@enumerable.each_context do |value|
|
268
|
+
value.should be_a_resource
|
269
|
+
contexts.should include value
|
270
|
+
end
|
235
271
|
end
|
236
272
|
|
237
273
|
it "should support #enum_context" do
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
require 'rdf/spec'
|
3
|
+
|
4
|
+
share_as :RDF_Graph do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
8
|
+
end
|
9
|
+
|
10
|
+
context "unnamed graphs" do
|
11
|
+
it "should be instantiable" do
|
12
|
+
lambda { @new.call }.should_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be unnamed" do
|
16
|
+
graph = @new.call
|
17
|
+
graph.unnamed?.should be_true
|
18
|
+
graph.named?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not have a context" do
|
22
|
+
graph = @new.call
|
23
|
+
graph.context.should be_nil
|
24
|
+
graph.contexts.size.should == 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "named graphs" do
|
29
|
+
it "should be instantiable" do
|
30
|
+
lambda { @new.call }.should_not raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be named" do
|
34
|
+
graph = @new.call("http://rdf.rubyforge.org/")
|
35
|
+
graph.unnamed?.should be_false
|
36
|
+
graph.named?.should be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a context" do
|
40
|
+
graph = @new.call("http://rdf.rubyforge.org/")
|
41
|
+
graph.context.should_not be_nil
|
42
|
+
graph.contexts.size.should == 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
require 'rdf/spec'
|
3
|
+
|
4
|
+
share_as :RDF_Literal do
|
5
|
+
|
6
|
+
XSD = RDF::XSD
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
10
|
+
end
|
11
|
+
|
12
|
+
context "plain literals" do
|
13
|
+
before :each do
|
14
|
+
@empty = @new.call('')
|
15
|
+
@hello = @new.call('Hello')
|
16
|
+
@all = [@empty, @hello]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be instantiable" do
|
20
|
+
lambda { @new.call('') }.should_not raise_error
|
21
|
+
@all.each do |literal|
|
22
|
+
literal.plain?.should be_true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not have a language" do
|
27
|
+
@all.each do |literal|
|
28
|
+
literal.language.should be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not have a datatype" do
|
33
|
+
@all.each do |literal|
|
34
|
+
literal.typed?.should be_false
|
35
|
+
literal.datatype.should be_nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should support equality comparisons" do
|
40
|
+
@all.each do |literal|
|
41
|
+
copy = @new.call(literal.value)
|
42
|
+
literal.should eql(copy)
|
43
|
+
literal.should == copy
|
44
|
+
|
45
|
+
literal.should_not eql(literal.value)
|
46
|
+
literal.should == literal.value # FIXME
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a string representation" do
|
51
|
+
@empty.to_s.should eql('""')
|
52
|
+
@hello.to_s.should eql('"Hello"')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "languaged-tagged literals" do
|
57
|
+
before :each do
|
58
|
+
@empty = @new.call('', :language => :en)
|
59
|
+
@hello = @new.call('Hello', :language => :en)
|
60
|
+
@all = [@empty, @hello]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be instantiable" do
|
64
|
+
lambda { @new.call('', :language => :en) }.should_not raise_error
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have a language" do
|
68
|
+
@all.each do |literal|
|
69
|
+
literal.language.should_not be_nil
|
70
|
+
literal.language.should == :en
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not have a datatype" do
|
75
|
+
@all.each do |literal|
|
76
|
+
literal.typed?.should be_false
|
77
|
+
literal.datatype.should be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should support equality comparisons" do
|
82
|
+
@all.each do |literal|
|
83
|
+
copy = @new.call(literal.value, :language => literal.language)
|
84
|
+
literal.should eql(copy)
|
85
|
+
literal.should == copy
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have a string representation" do
|
90
|
+
@empty.to_s.should eql('""@en')
|
91
|
+
@hello.to_s.should eql('"Hello"@en')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "datatyped literals" do
|
96
|
+
require 'date'
|
97
|
+
|
98
|
+
before :each do
|
99
|
+
@string = @new.call('')
|
100
|
+
@false = @new.call(false)
|
101
|
+
@true = @new.call(true)
|
102
|
+
@int = @new.call(123)
|
103
|
+
@long = @new.call(9223372036854775807)
|
104
|
+
@double = @new.call(3.1415)
|
105
|
+
@time = @new.call(Time.now)
|
106
|
+
@date = @new.call(Date.new(2010))
|
107
|
+
@datetime = @new.call(DateTime.new(2010))
|
108
|
+
@all = [@false, @true, @int, @long, @double, @time, @date, @datetime]
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should be instantiable" do
|
112
|
+
lambda { @new.call(123) }.should_not raise_error
|
113
|
+
lambda { @new.call(123, :datatype => XSD.int) }.should_not raise_error
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should not have a language" do
|
117
|
+
@all.each do |literal|
|
118
|
+
literal.language.should be_nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should have a datatype" do
|
123
|
+
@all.each do |literal|
|
124
|
+
literal.typed?.should be_true
|
125
|
+
literal.datatype.should_not be_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should support implicit datatyping" do
|
130
|
+
@string.datatype.should == nil
|
131
|
+
@false.datatype.should == XSD.boolean
|
132
|
+
@true.datatype.should == XSD.boolean
|
133
|
+
@int.datatype.should == XSD.integer
|
134
|
+
@long.datatype.should == XSD.integer
|
135
|
+
@double.datatype.should == XSD.double
|
136
|
+
@time.datatype.should == XSD.dateTime
|
137
|
+
@date.datatype.should == XSD.date
|
138
|
+
@datetime.datatype.should == XSD.dateTime
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should support equality comparisons" do
|
142
|
+
@all.each do |literal|
|
143
|
+
copy = @new.call(literal.value, :datatype => literal.datatype)
|
144
|
+
literal.should eql(copy)
|
145
|
+
literal.should == copy
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should have a string representation" do
|
150
|
+
@false.to_s.should eql('"false"^^<http://www.w3.org/2001/XMLSchema#boolean>')
|
151
|
+
@true.to_s.should eql('"true"^^<http://www.w3.org/2001/XMLSchema#boolean>')
|
152
|
+
@int.to_s.should eql('"123"^^<http://www.w3.org/2001/XMLSchema#integer>')
|
153
|
+
@long.to_s.should eql('"9223372036854775807"^^<http://www.w3.org/2001/XMLSchema#integer>')
|
154
|
+
@double.to_s.should eql('"3.1415"^^<http://www.w3.org/2001/XMLSchema#double>')
|
155
|
+
@date.to_s.should eql('"2010-01-01"^^<http://www.w3.org/2001/XMLSchema#date>')
|
156
|
+
@datetime.to_s.should eql('"2010-01-01T00:00:00+00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>') # FIXME
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
data/lib/rdf/spec/mutable.rb
CHANGED
@@ -59,11 +59,9 @@ share_as :RDF_Mutable do
|
|
59
59
|
@repository.should have_context @context
|
60
60
|
@repository.query(:context => @context).size.should == @repository.size
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
63
|
|
65
64
|
context "when inserting statements" do
|
66
|
-
|
67
65
|
before :each do
|
68
66
|
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
69
67
|
end
|
@@ -98,7 +96,6 @@ share_as :RDF_Mutable do
|
|
98
96
|
end
|
99
97
|
|
100
98
|
context "when deleting statements" do
|
101
|
-
|
102
99
|
before :each do
|
103
100
|
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
104
101
|
@repository.insert(*@statements)
|
@@ -122,6 +119,18 @@ share_as :RDF_Mutable do
|
|
122
119
|
@statements.find { |s| @repository.has_statement?(s) }.should be_false
|
123
120
|
end
|
124
121
|
|
122
|
+
it "should support wildcard deletions" do
|
123
|
+
# nothing deleted
|
124
|
+
require 'digest/sha1'
|
125
|
+
count = @repository.count
|
126
|
+
@repository.delete([nil, nil, random = Digest::SHA1.hexdigest(File.read(__FILE__))])
|
127
|
+
@repository.should_not be_empty
|
128
|
+
@repository.count.should == count
|
129
|
+
|
130
|
+
# everything deleted
|
131
|
+
@repository.delete([nil, nil, nil])
|
132
|
+
@repository.should be_empty
|
133
|
+
end
|
125
134
|
end
|
126
135
|
|
127
136
|
context "when clearing all statements" do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
require 'rdf/spec'
|
3
|
+
|
4
|
+
share_as :RDF_Node do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
it "should be instantiable" do
|
12
|
+
lambda { @new.call }.should_not raise_error
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'rdf/spec'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
share_as :RDF_Statement do
|
5
|
+
include RDF::Spec::Matchers
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
raise '+@n3+ must be defined in a before(:each) block' unless instance_variable_get('@n3')
|
9
|
+
raise '+@s+ must be defined in a before(:each) block' unless instance_variable_get('@s')
|
10
|
+
raise '+@p+ must be defined in a before(:each) block' unless instance_variable_get('@p')
|
11
|
+
raise '+@o+ must be defined in a before(:each) block' unless instance_variable_get('@o')
|
12
|
+
raise '+@stmt+ must be defined in a before(:each) block' unless instance_variable_get('@stmt')
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when initializing" do
|
16
|
+
it "should be instantiable with a hash argument" do
|
17
|
+
lambda { RDF::Statement.new(:subject => @s,
|
18
|
+
:predicate => @p,
|
19
|
+
:object => @o) }.should_not raise_error(ArgumentError)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not alter a hash argument" do
|
24
|
+
hash = { :subject => @s, :predicate => @p, :object => @o }
|
25
|
+
original_hash = hash.dup
|
26
|
+
stmt = RDF::Statement.new(hash)
|
27
|
+
original_hash.should == hash
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not alter its options argument" do
|
31
|
+
options = { :context => RDF::DOAP.name }
|
32
|
+
original_options = options.dup
|
33
|
+
stmt = RDF::Statement.new(@s, @p, @o, options)
|
34
|
+
options.should == original_options
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when created" do
|
39
|
+
it "should not require arguments" do
|
40
|
+
lambda { RDF::Statement.new }.should_not raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a subject" do
|
44
|
+
@stmt.has_subject?.should be_true
|
45
|
+
@stmt.subject.should_not be_nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have a predicate" do
|
49
|
+
@stmt.has_predicate?.should be_true
|
50
|
+
@stmt.predicate.should_not be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should have an object" do
|
54
|
+
@stmt.has_object?.should be_true
|
55
|
+
@stmt.object.should_not be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be asserted" do
|
59
|
+
@stmt.asserted?.should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not be quoted" do
|
63
|
+
@stmt.quoted?.should be_false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when created with a blank node subject" do
|
68
|
+
before :each do
|
69
|
+
@stmt = RDF::Statement.new(RDF::Node.new, @p, @o)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have a blank node" do
|
73
|
+
@stmt.has_blank_nodes?.should be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "when created with a blank node object" do
|
78
|
+
before :each do
|
79
|
+
@stmt = RDF::Statement.new(@s, @p, RDF::Node.new)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should have a blank node" do
|
83
|
+
@stmt.has_blank_nodes?.should be_true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when created without a context" do
|
88
|
+
it "should not have a context" do
|
89
|
+
@stmt = RDF::Statement.new(@s, @p, @o, :context => nil)
|
90
|
+
@stmt.context.should be_nil
|
91
|
+
@stmt.has_context?.should be_false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "when created with a context" do
|
96
|
+
it "should have a context" do
|
97
|
+
@stmt = RDF::Statement.new(@s, @p, @o, :context => @s)
|
98
|
+
@stmt.has_context?.should be_true
|
99
|
+
@stmt.context.should_not be_nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when used like an Array" do
|
104
|
+
it "should support #to_a" do
|
105
|
+
@stmt.should respond_to(:to_a)
|
106
|
+
@stmt.to_a.should eql([@stmt.subject, @stmt.predicate, @stmt.object])
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should support #[]" do
|
110
|
+
@stmt.should respond_to(:[])
|
111
|
+
@stmt[0].should equal(@stmt.subject)
|
112
|
+
@stmt[1].should equal(@stmt.predicate)
|
113
|
+
@stmt[2].should equal(@stmt.object)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should support #[]=" do
|
117
|
+
@stmt.should respond_to(:[]=)
|
118
|
+
# TODO
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when used like a Hash" do
|
123
|
+
it "should support #to_hash" do
|
124
|
+
@stmt.should respond_to(:to_hash)
|
125
|
+
@stmt.to_hash.should eql({
|
126
|
+
:subject => @stmt.subject,
|
127
|
+
:predicate => @stmt.predicate,
|
128
|
+
:object => @stmt.object,
|
129
|
+
})
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when used like a String" do
|
134
|
+
it "should support #to_s" do
|
135
|
+
@stmt.should respond_to(:to_s)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should have an N-Triples representation" do
|
139
|
+
@stmt.to_s.should eql(@n3)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "when comparing equality" do
|
144
|
+
before :each do
|
145
|
+
@c = RDF::URI.parse("http://example.org/context")
|
146
|
+
@other_stmt = RDF::Statement.new(@s, @p, @o, :context => @c)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should == regardless of context" do
|
150
|
+
@stmt.should == @other_stmt
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should not be eql? with differing contexts" do
|
154
|
+
@stmt.should_not be_eql @other_stmt
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should match (===) a statement with a missing component to one with that component" do
|
158
|
+
@stmt.should === @other_stmt
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should not match (===) a statement with a component to one which is missing that component" do
|
162
|
+
@other_stmt.should_not === @stmt
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should only equals? with object equality" do
|
166
|
+
@same_stmt = RDF::Statement.new @s, @p, @o
|
167
|
+
@stmt.should_not equal @same_stmt
|
168
|
+
@stmt.should equal @stmt
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
data/lib/rdf/spec/uri.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
require 'rdf/spec'
|
3
|
+
|
4
|
+
share_as :RDF_URI do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be instantiable" do
|
11
|
+
lambda { @new.call("http://rdf.rubyforge.org/") }.should_not raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return the root URI" do
|
15
|
+
uri = @new.call("http://rdf.rubyforge.org/RDF/URI.html")
|
16
|
+
uri.should respond_to(:root)
|
17
|
+
uri.root.should be_a_uri
|
18
|
+
uri.root.should == @new.call("http://rdf.rubyforge.org/")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should find the parent URI" do
|
22
|
+
uri = @new.call("http://rdf.rubyforge.org/RDF/URI.html")
|
23
|
+
uri.should respond_to(:parent)
|
24
|
+
uri.parent.should be_a_uri
|
25
|
+
uri.parent.should == @new.call("http://rdf.rubyforge.org/RDF/")
|
26
|
+
uri.parent.parent.should == @new.call("http://rdf.rubyforge.org/")
|
27
|
+
uri.parent.parent.parent.should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return a consistent hash code" do
|
31
|
+
hash1 = @new.call("http://rdf.rubyforge.org/").hash
|
32
|
+
hash2 = @new.call("http://rdf.rubyforge.org/").hash
|
33
|
+
hash1.should == hash2
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be duplicable" do
|
37
|
+
url = Addressable::URI.parse("http://rdf.rubyforge.org/")
|
38
|
+
uri2 = (uri1 = @new.call(url)).dup
|
39
|
+
|
40
|
+
uri1.should_not be_equal(uri2)
|
41
|
+
uri1.should be_eql(uri2)
|
42
|
+
uri1.should == uri2
|
43
|
+
|
44
|
+
url.path = '/rdf/'
|
45
|
+
uri1.should_not be_equal(uri2)
|
46
|
+
uri1.should_not be_eql(uri2)
|
47
|
+
uri1.should_not == uri2
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
require 'rdf/spec'
|
3
|
+
|
4
|
+
share_as :RDF_Value do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
raise '+@value+ must be defined in a before(:each) block' unless instance_variable_get('@value')
|
8
|
+
raise '+@resource+ must be defined in a before(:each) block' unless instance_variable_get('@resource')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe RDF::Value do
|
12
|
+
it "should not be instantiable" do
|
13
|
+
lambda { @value.call }.should raise_error(NoMethodError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe RDF::Resource do
|
18
|
+
it "should instantiate blank nodes" do
|
19
|
+
resource = @resource.call('_:foobar')
|
20
|
+
resource.class.should == RDF::Node
|
21
|
+
resource.id.should == 'foobar'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should instantiate URIs" do
|
25
|
+
resource = @resource.call('http://rdf.rubyforge.org/')
|
26
|
+
resource.class.should == RDF::URI
|
27
|
+
resource.to_s.should == 'http://rdf.rubyforge.org/'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/rdf/spec/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 6
|
9
|
+
version: 0.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Arto Bendiken
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-12 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 0
|
30
30
|
- 1
|
31
|
-
-
|
32
|
-
version: 0.1.
|
31
|
+
- 6
|
32
|
+
version: 0.1.6
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -90,10 +90,16 @@ files:
|
|
90
90
|
- etc/doap.nt
|
91
91
|
- lib/rdf/spec/durable.rb
|
92
92
|
- lib/rdf/spec/enumerable.rb
|
93
|
+
- lib/rdf/spec/graph.rb
|
94
|
+
- lib/rdf/spec/literal.rb
|
93
95
|
- lib/rdf/spec/matchers.rb
|
94
96
|
- lib/rdf/spec/mutable.rb
|
97
|
+
- lib/rdf/spec/node.rb
|
95
98
|
- lib/rdf/spec/queryable.rb
|
96
99
|
- lib/rdf/spec/repository.rb
|
100
|
+
- lib/rdf/spec/statement.rb
|
101
|
+
- lib/rdf/spec/uri.rb
|
102
|
+
- lib/rdf/spec/value.rb
|
97
103
|
- lib/rdf/spec/version.rb
|
98
104
|
- lib/rdf/spec.rb
|
99
105
|
- spec/enumerable_spec.rb
|