rdf-spec 0.1.10 → 0.2.0
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 +3 -3
- data/VERSION +1 -1
- data/etc/doap.nt +23 -0
- data/lib/rdf/spec/countable.rb +42 -0
- data/lib/rdf/spec/enumerable.rb +253 -124
- data/lib/rdf/spec/graph.rb +10 -0
- data/lib/rdf/spec/literal.rb +4 -0
- data/lib/rdf/spec/matchers.rb +37 -2
- data/lib/rdf/spec/mutable.rb +86 -45
- data/lib/rdf/spec/queryable.rb +93 -36
- data/lib/rdf/spec/repository.rb +21 -10
- data/lib/rdf/spec/statement.rb +46 -6
- data/lib/rdf/spec/uri.rb +36 -11
- data/lib/rdf/spec/version.rb +3 -4
- data/spec/countable_spec.rb +12 -0
- data/spec/enumerable_spec.rb +1 -1
- data/spec/queryable_spec.rb +4 -4
- metadata +15 -13
data/README
CHANGED
@@ -15,14 +15,14 @@ Documentation
|
|
15
15
|
Dependencies
|
16
16
|
------------
|
17
17
|
|
18
|
-
* [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.
|
18
|
+
* [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.2.0)
|
19
19
|
* [RSpec](http://gemcutter.org/gems/rspec) (>= 1.3.0)
|
20
20
|
|
21
21
|
Installation
|
22
22
|
------------
|
23
23
|
|
24
|
-
The recommended installation method is via RubyGems.
|
25
|
-
official release
|
24
|
+
The recommended installation method is via [RubyGems](http://rubygems.org/).
|
25
|
+
To install the latest official release of `RDF::Spec`, do:
|
26
26
|
|
27
27
|
% [sudo] gem install rdf-spec
|
28
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/etc/doap.nt
CHANGED
@@ -1,24 +1,47 @@
|
|
1
1
|
<http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
2
|
+
<http://ar.to/#self> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bendiken/foaf> .
|
3
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <http://ar.to/> .
|
2
4
|
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <http://rubygems.org/gems/rdf> .
|
3
5
|
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto.bendiken@gmail.com> .
|
6
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
|
7
|
+
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" .
|
4
8
|
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
|
5
9
|
<http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
10
|
+
<http://bhuga.net/#ben> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bhuga/foaf> .
|
11
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <http://bhuga.net/> .
|
6
12
|
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
|
13
|
+
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
|
7
14
|
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
|
8
15
|
<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
|
9
16
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
|
17
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
|
10
18
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/bendiken/rdf/issues> .
|
19
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Resource_Description_Framework> .
|
20
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
|
11
21
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
|
12
22
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
|
13
23
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
|
14
24
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
|
15
25
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
|
16
26
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
|
27
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
28
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
29
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
|
17
30
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
|
18
31
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
19
32
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
20
33
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
|
21
34
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
|
22
35
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
|
36
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#vendor> <http://datagraph.org/> .
|
23
37
|
<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
|
24
38
|
<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
|
39
|
+
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
40
|
+
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
|
41
|
+
_:genid1 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
|
42
|
+
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
43
|
+
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
|
44
|
+
_:genid2 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
|
45
|
+
_:genid3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
46
|
+
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
|
47
|
+
_:genid3 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rdf/spec'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
share_as :RDF_Countable do
|
5
|
+
include RDF::Spec::Matchers
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
raise '+@countable+ must be defined in a before(:each) block' unless instance_variable_get('@countable')
|
9
|
+
|
10
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
11
|
+
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
12
|
+
|
13
|
+
if @countable.empty?
|
14
|
+
if @countable.respond_to?(:<<)
|
15
|
+
@statements.each { |statement| @countable << statement }
|
16
|
+
else
|
17
|
+
raise "+@countable+ must respond to #<< or be pre-populated with the statements in #{@filename} in a before(:each) block"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when counting items" do
|
23
|
+
it "should respond to #empty?" do
|
24
|
+
@countable.should respond_to(:empty?)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should respond to #count and #size" do
|
28
|
+
@countable.should respond_to(*%w(count size))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should implement #empty?" do
|
32
|
+
([].extend(RDF::Countable)).empty?.should be_true
|
33
|
+
@countable.empty?.should be_false
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should implement #count and #size" do
|
37
|
+
%w(count size).each do |method|
|
38
|
+
@countable.send(method).should == @statements.size
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/rdf/spec/enumerable.rb
CHANGED
@@ -6,131 +6,202 @@ share_as :RDF_Enumerable do
|
|
6
6
|
|
7
7
|
before :each do
|
8
8
|
raise '+@enumerable+ must be defined in a before(:each) block' unless instance_variable_get('@enumerable')
|
9
|
-
raise '+@statements+ must be defined in a before(:each) block' unless instance_variable_get('@statements')
|
10
|
-
end
|
11
9
|
|
12
|
-
|
13
|
-
@
|
10
|
+
@filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
|
11
|
+
@statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
|
12
|
+
|
13
|
+
if @enumerable.empty?
|
14
|
+
if @enumerable.respond_to?(:<<)
|
15
|
+
@statements.each { |statement| @enumerable << statement }
|
16
|
+
else
|
17
|
+
raise "@enumerable must respond to #<< or be pre-populated with the statements in #{@filename} in a before(:each) block"
|
18
|
+
end
|
19
|
+
end
|
14
20
|
|
15
|
-
|
16
|
-
@enumerable.
|
21
|
+
# Assume contexts are supported unless declared otherwise:
|
22
|
+
@supports_context = @enumerable.respond_to?(:supports?) ? @enumerable.supports?(:context) : true
|
17
23
|
end
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
@enumerable.respond_to?
|
25
|
+
context "when counting statements" do
|
26
|
+
it "should respond to #empty?" do
|
27
|
+
@enumerable.should respond_to(:empty?)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should respond to #count and #size" do
|
31
|
+
@enumerable.should respond_to(*%w(count size length))
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should implement #empty?" do
|
35
|
+
([].extend(RDF::Enumerable)).empty?.should be_true
|
36
|
+
@enumerable.empty?.should be_false
|
37
|
+
end
|
22
38
|
|
23
|
-
|
39
|
+
it "should implement #count and #size" do
|
40
|
+
%w(count size length).each do |method|
|
41
|
+
@enumerable.send(method).should == @statements.size
|
42
|
+
end
|
24
43
|
end
|
25
44
|
end
|
26
45
|
|
27
|
-
context "statements" do
|
28
|
-
it "should
|
29
|
-
@enumerable.respond_to
|
46
|
+
context "when enumerating statements" do
|
47
|
+
it "should respond to #statements" do
|
48
|
+
@enumerable.should respond_to(:statements)
|
49
|
+
end
|
30
50
|
|
31
|
-
|
32
|
-
@enumerable.
|
33
|
-
@enumerable.statements.each { |statement| statement.should be_a_statement }
|
51
|
+
it "should respond to #has_statement?" do
|
52
|
+
@enumerable.should respond_to(:has_statement?)
|
34
53
|
end
|
35
54
|
|
36
|
-
it "should
|
37
|
-
@enumerable.respond_to
|
55
|
+
it "should respond to #each_statement" do
|
56
|
+
@enumerable.should respond_to(:each_statement)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should respond to #enum_statement" do
|
60
|
+
@enumerable.should respond_to(:enum_statement)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should implement #statements" do
|
64
|
+
@enumerable.statements.should be_an_enumerator
|
65
|
+
@enumerable.statements.to_a.size.should == @statements.size
|
66
|
+
@enumerable.statements.each { |statement| statement.should be_a_statement }
|
67
|
+
end
|
38
68
|
|
69
|
+
it "should implement #has_statement?" do
|
39
70
|
@statements.each do |statement|
|
40
71
|
@enumerable.has_statement?(statement).should be_true
|
41
72
|
end
|
42
73
|
|
74
|
+
context = RDF::URI.new("urn:context:1")
|
75
|
+
@statements.each do |statement|
|
76
|
+
s = statement.dup
|
77
|
+
s.context = context
|
78
|
+
@enumerable.has_statement?(s).should be_false
|
79
|
+
end
|
80
|
+
|
43
81
|
unknown_statement = RDF::Statement.new(RDF::Node.new, RDF::URI.new("http://example.org/unknown"), RDF::Node.new)
|
44
82
|
@enumerable.has_statement?(unknown_statement).should be_false
|
45
83
|
end
|
46
84
|
|
47
|
-
it "should
|
48
|
-
@enumerable.
|
49
|
-
|
50
|
-
@enumerable.each_statement.should be_instance_of(RDF::Enumerator)
|
85
|
+
it "should implement #each_statement" do
|
86
|
+
@enumerable.each_statement.should be_an_enumerator
|
51
87
|
@enumerable.each_statement { |statement| statement.should be_a_statement }
|
52
88
|
end
|
53
89
|
|
54
|
-
it "should
|
55
|
-
@enumerable.
|
56
|
-
|
57
|
-
@enumerable.enum_statement.should
|
90
|
+
it "should implement #enum_statement" do
|
91
|
+
@enumerable.enum_statement.should be_an_enumerator
|
92
|
+
@enumerable.enum_statement.should be_countable
|
93
|
+
@enumerable.enum_statement.should be_enumerable
|
94
|
+
@enumerable.enum_statement.should be_queryable
|
95
|
+
@enumerable.enum_statement.to_a.should == @enumerable.each_statement.to_a
|
58
96
|
end
|
59
97
|
end
|
60
98
|
|
61
|
-
context "triples" do
|
62
|
-
it "should
|
63
|
-
@enumerable.respond_to
|
99
|
+
context "when enumerating triples" do
|
100
|
+
it "should respond to #triples" do
|
101
|
+
@enumerable.should respond_to(:triples)
|
102
|
+
end
|
64
103
|
|
65
|
-
|
66
|
-
@enumerable.
|
67
|
-
|
104
|
+
it "should respond to #has_triple?" do
|
105
|
+
@enumerable.should respond_to(:has_triple?)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should respond to #each_triple" do
|
109
|
+
@enumerable.should respond_to(:each_triple)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should respond to #enum_triple" do
|
113
|
+
@enumerable.should respond_to(:enum_triple)
|
68
114
|
end
|
69
115
|
|
70
|
-
it "should
|
71
|
-
@enumerable.
|
116
|
+
it "should implement #triples" do
|
117
|
+
@enumerable.triples.should be_an_enumerator
|
118
|
+
@enumerable.triples.to_a.size.should == @statements.size
|
119
|
+
@enumerable.triples.each { |triple| triple.should be_a_triple }
|
120
|
+
end
|
72
121
|
|
122
|
+
it "should implement #has_triple?" do
|
73
123
|
@statements.each do |statement|
|
74
124
|
@enumerable.has_triple?(statement.to_triple).should be_true
|
75
125
|
end
|
76
126
|
end
|
77
127
|
|
78
|
-
it "should
|
79
|
-
@enumerable.
|
80
|
-
|
81
|
-
@enumerable.each_triple.should be_instance_of(RDF::Enumerator)
|
128
|
+
it "should implement #each_triple" do
|
129
|
+
@enumerable.each_triple.should be_an_enumerator
|
82
130
|
@enumerable.each_triple { |*triple| triple.should be_a_triple }
|
83
131
|
end
|
84
132
|
|
85
|
-
it "should
|
86
|
-
@enumerable.
|
87
|
-
|
88
|
-
@enumerable.enum_triple.should
|
133
|
+
it "should implement #enum_triple" do
|
134
|
+
@enumerable.enum_triple.should be_an_enumerator
|
135
|
+
@enumerable.enum_triple.should be_countable
|
136
|
+
@enumerable.enum_triple.to_a.should == @enumerable.each_triple.to_a
|
89
137
|
end
|
90
138
|
end
|
91
139
|
|
92
|
-
context "quads" do
|
93
|
-
it "should
|
94
|
-
@enumerable.respond_to
|
140
|
+
context "when enumerating quads" do
|
141
|
+
it "should respond to #quads" do
|
142
|
+
@enumerable.should respond_to(:quads)
|
143
|
+
end
|
95
144
|
|
96
|
-
|
97
|
-
@enumerable.
|
98
|
-
@enumerable.quads.each { |quad| quad.should be_a_quad }
|
145
|
+
it "should respond to #has_quad?" do
|
146
|
+
@enumerable.should respond_to(:has_quad?)
|
99
147
|
end
|
100
148
|
|
101
|
-
it "should
|
102
|
-
@enumerable.respond_to
|
149
|
+
it "should respond to #each_quad" do
|
150
|
+
@enumerable.should respond_to(:each_quad)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should respond to #enum_quad" do
|
154
|
+
@enumerable.should respond_to(:enum_quad)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should implement #quads" do
|
158
|
+
@enumerable.quads.should be_an_enumerator
|
159
|
+
@enumerable.quads.to_a.size.should == @statements.size
|
160
|
+
@enumerable.quads.each { |quad| quad.should be_a_quad }
|
161
|
+
end
|
103
162
|
|
163
|
+
it "should implement #has_quad?" do
|
104
164
|
@statements.each do |statement|
|
105
165
|
@enumerable.has_quad?(statement.to_quad).should be_true
|
106
166
|
end
|
107
167
|
end
|
108
168
|
|
109
|
-
it "should
|
110
|
-
@enumerable.
|
111
|
-
|
112
|
-
@enumerable.each_quad.should be_instance_of(RDF::Enumerator)
|
169
|
+
it "should implement #each_quad" do
|
170
|
+
@enumerable.each_quad.should be_an_enumerator
|
113
171
|
@enumerable.each_quad { |*quad| quad.should be_a_quad }
|
114
172
|
end
|
115
173
|
|
116
|
-
it "should
|
117
|
-
@enumerable.
|
118
|
-
|
119
|
-
@enumerable.enum_quad.should
|
174
|
+
it "should implement #enum_quad" do
|
175
|
+
@enumerable.enum_quad.should be_an_enumerator
|
176
|
+
@enumerable.enum_quad.should be_countable
|
177
|
+
@enumerable.enum_quad.to_a.should == @enumerable.each_quad.to_a
|
120
178
|
end
|
121
179
|
end
|
122
180
|
|
123
|
-
context "subjects" do
|
124
|
-
it "should
|
125
|
-
@enumerable.respond_to
|
181
|
+
context "when enumerating subjects" do
|
182
|
+
it "should respond to #subjects" do
|
183
|
+
@enumerable.should respond_to(:subjects)
|
184
|
+
end
|
126
185
|
|
127
|
-
|
128
|
-
@enumerable.
|
186
|
+
it "should respond to #has_subject?" do
|
187
|
+
@enumerable.should respond_to(:has_subject?)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should respond to #each_subject" do
|
191
|
+
@enumerable.should respond_to(:each_subject)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should respond to #enum_subject" do
|
195
|
+
@enumerable.should respond_to(:enum_subject)
|
129
196
|
end
|
130
197
|
|
131
|
-
it "should
|
132
|
-
@enumerable.
|
198
|
+
it "should implement #subjects" do
|
199
|
+
@enumerable.subjects.should be_an_enumerator
|
200
|
+
@enumerable.subjects.each { |value| value.should be_a_resource }
|
201
|
+
# TODO: subjects(:unique => false)
|
202
|
+
end
|
133
203
|
|
204
|
+
it "should implement #has_subject?" do
|
134
205
|
checked = []
|
135
206
|
@statements.each do |statement|
|
136
207
|
@enumerable.has_subject?(statement.subject).should be_true unless checked.include?(statement.subject)
|
@@ -140,10 +211,8 @@ share_as :RDF_Enumerable do
|
|
140
211
|
@enumerable.has_predicate?(uri).should be_false
|
141
212
|
end
|
142
213
|
|
143
|
-
it "should
|
144
|
-
@enumerable.
|
145
|
-
|
146
|
-
@enumerable.each_subject.should be_instance_of(RDF::Enumerator)
|
214
|
+
it "should implement #each_subject" do
|
215
|
+
@enumerable.each_subject.should be_an_enumerator
|
147
216
|
subjects = @statements.map { |s| s.subject }.uniq
|
148
217
|
@enumerable.each_subject.to_a.size.should == subjects.size
|
149
218
|
@enumerable.each_subject do |value|
|
@@ -152,24 +221,37 @@ share_as :RDF_Enumerable do
|
|
152
221
|
end
|
153
222
|
end
|
154
223
|
|
155
|
-
it "should
|
156
|
-
@enumerable.
|
157
|
-
|
158
|
-
@enumerable.enum_subject.should
|
224
|
+
it "should implement #enum_subject" do
|
225
|
+
@enumerable.enum_subject.should be_an_enumerator
|
226
|
+
@enumerable.enum_subject.should be_countable
|
227
|
+
@enumerable.enum_subject.to_a.should == @enumerable.each_subject.to_a
|
159
228
|
end
|
160
229
|
end
|
161
230
|
|
162
|
-
context "predicates" do
|
163
|
-
it "should
|
164
|
-
@enumerable.respond_to
|
231
|
+
context "when enumerating predicates" do
|
232
|
+
it "should respond to #predicates" do
|
233
|
+
@enumerable.should respond_to(:predicates)
|
234
|
+
end
|
165
235
|
|
166
|
-
|
167
|
-
@enumerable.
|
236
|
+
it "should respond to #has_predicate?" do
|
237
|
+
@enumerable.should respond_to(:has_predicate?)
|
168
238
|
end
|
169
239
|
|
170
|
-
it "should
|
171
|
-
@enumerable.respond_to
|
240
|
+
it "should respond to #each_predicate" do
|
241
|
+
@enumerable.should respond_to(:each_predicate)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should respond to #enum_predicate" do
|
245
|
+
@enumerable.should respond_to(:enum_predicate)
|
246
|
+
end
|
172
247
|
|
248
|
+
it "should implement #predicates" do
|
249
|
+
@enumerable.predicates.should be_an_enumerator
|
250
|
+
@enumerable.predicates.each { |value| value.should be_a_uri }
|
251
|
+
# TODO: predicates(:unique => false)
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should implement #has_predicate?" do
|
173
255
|
checked = []
|
174
256
|
@statements.each do |statement|
|
175
257
|
@enumerable.has_predicate?(statement.predicate).should be_true unless checked.include?(statement.object)
|
@@ -179,36 +261,47 @@ share_as :RDF_Enumerable do
|
|
179
261
|
@enumerable.has_predicate?(uri).should be_false
|
180
262
|
end
|
181
263
|
|
182
|
-
it "should
|
183
|
-
@enumerable.respond_to?(:each_predicate).should be_true
|
184
|
-
|
264
|
+
it "should implement #each_predicate" do
|
185
265
|
predicates = @statements.map { |s| s.predicate }.uniq
|
266
|
+
@enumerable.each_predicate.should be_an_enumerator
|
186
267
|
@enumerable.each_predicate.to_a.size.should == predicates.size
|
187
|
-
@enumerable.each_predicate
|
188
|
-
@enumerable.each_predicate do |value|
|
268
|
+
@enumerable.each_predicate do |value|
|
189
269
|
value.should be_a_uri
|
190
270
|
predicates.should include value
|
191
271
|
end
|
192
272
|
end
|
193
273
|
|
194
|
-
it "should
|
195
|
-
@enumerable.
|
196
|
-
|
197
|
-
@enumerable.enum_predicate.should
|
274
|
+
it "should implement #enum_predicate" do
|
275
|
+
@enumerable.enum_predicate.should be_an_enumerator
|
276
|
+
@enumerable.enum_predicate.should be_countable
|
277
|
+
@enumerable.enum_predicate.to_a.should == @enumerable.each_predicate.to_a
|
198
278
|
end
|
199
279
|
end
|
200
280
|
|
201
|
-
context "objects" do
|
202
|
-
it "should
|
203
|
-
@enumerable.respond_to
|
281
|
+
context "when enumerating objects" do
|
282
|
+
it "should respond to #objects" do
|
283
|
+
@enumerable.should respond_to(:objects)
|
284
|
+
end
|
204
285
|
|
205
|
-
|
206
|
-
@enumerable.
|
286
|
+
it "should respond to #has_object?" do
|
287
|
+
@enumerable.should respond_to(:has_object?)
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should respond to #each_object" do
|
291
|
+
@enumerable.should respond_to(:each_object)
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should respond to #enum_object" do
|
295
|
+
@enumerable.should respond_to(:enum_object)
|
207
296
|
end
|
208
297
|
|
209
|
-
it "should
|
210
|
-
@enumerable.
|
298
|
+
it "should implement #objects" do
|
299
|
+
@enumerable.objects.should be_an_enumerator
|
300
|
+
@enumerable.objects.each { |value| value.should be_a_value }
|
301
|
+
# TODO: objects(:unique => false)
|
302
|
+
end
|
211
303
|
|
304
|
+
it "should implement #has_object?" do
|
212
305
|
checked = []
|
213
306
|
@statements.each do |statement|
|
214
307
|
@enumerable.has_object?(statement.object).should be_true unless checked.include?(statement.object)
|
@@ -218,36 +311,47 @@ share_as :RDF_Enumerable do
|
|
218
311
|
@enumerable.has_object?(uri).should be_false
|
219
312
|
end
|
220
313
|
|
221
|
-
it "should
|
222
|
-
@enumerable.respond_to?(:each_object).should be_true
|
223
|
-
|
314
|
+
it "should implement #each_object" do
|
224
315
|
objects = @statements.map { |s| s.object }.uniq
|
316
|
+
@enumerable.each_object.should be_an_enumerator
|
225
317
|
@enumerable.each_object.to_a.size.should == objects.size
|
226
|
-
@enumerable.each_object
|
227
|
-
@enumerable.each_object do |value|
|
318
|
+
@enumerable.each_object do |value|
|
228
319
|
value.should be_a_value
|
229
320
|
objects.should include value
|
230
321
|
end
|
231
322
|
end
|
232
323
|
|
233
|
-
it "should
|
234
|
-
@enumerable.
|
235
|
-
|
236
|
-
@enumerable.enum_object.should
|
324
|
+
it "should implement #enum_object" do
|
325
|
+
@enumerable.enum_object.should be_an_enumerator
|
326
|
+
@enumerable.enum_object.should be_countable
|
327
|
+
@enumerable.enum_object.to_a.should == @enumerable.each_object.to_a
|
237
328
|
end
|
238
329
|
end
|
239
330
|
|
240
|
-
context "contexts" do
|
241
|
-
it "should
|
242
|
-
@enumerable.respond_to
|
331
|
+
context "when enumerating contexts" do
|
332
|
+
it "should respond to #contexts" do
|
333
|
+
@enumerable.should respond_to(:contexts)
|
334
|
+
end
|
243
335
|
|
244
|
-
|
245
|
-
@enumerable.
|
336
|
+
it "should respond to #has_context?" do
|
337
|
+
@enumerable.should respond_to(:has_context?)
|
246
338
|
end
|
247
339
|
|
248
|
-
it "should
|
249
|
-
@enumerable.respond_to
|
340
|
+
it "should respond to #each_context" do
|
341
|
+
@enumerable.should respond_to(:each_context)
|
342
|
+
end
|
343
|
+
|
344
|
+
it "should respond to #enum_context" do
|
345
|
+
@enumerable.should respond_to(:enum_context)
|
346
|
+
end
|
347
|
+
|
348
|
+
it "should implement #contexts" do
|
349
|
+
@enumerable.contexts.should be_an_enumerator
|
350
|
+
@enumerable.contexts.each { |value| value.should be_a_resource }
|
351
|
+
# TODO: contexts(:unique => false)
|
352
|
+
end
|
250
353
|
|
354
|
+
it "should implement #has_context?" do
|
251
355
|
@statements.each do |statement|
|
252
356
|
if statement.has_context?
|
253
357
|
@enumerable.has_context?(statement.context).should be_true
|
@@ -257,29 +361,54 @@ share_as :RDF_Enumerable do
|
|
257
361
|
@enumerable.has_context?(uri).should be_false
|
258
362
|
end
|
259
363
|
|
260
|
-
it "should
|
261
|
-
@enumerable.respond_to?(:each_context).should be_true
|
262
|
-
|
364
|
+
it "should implement #each_context" do
|
263
365
|
contexts = @statements.map { |s| s.context }.uniq
|
264
366
|
contexts.delete nil
|
367
|
+
@enumerable.each_context.should be_an_enumerator
|
265
368
|
@enumerable.each_context.to_a.size.should == contexts.size
|
266
|
-
@enumerable.each_context
|
267
|
-
|
268
|
-
value.should be_a_resource
|
369
|
+
@enumerable.each_context do |value|
|
370
|
+
value.should be_a_resource
|
269
371
|
contexts.should include value
|
270
372
|
end
|
271
373
|
end
|
272
374
|
|
273
|
-
it "should
|
274
|
-
@enumerable.
|
375
|
+
it "should implement #enum_context" do
|
376
|
+
@enumerable.enum_context.should be_an_enumerator
|
377
|
+
@enumerable.enum_context.should be_countable
|
378
|
+
@enumerable.enum_context.to_a.should == @enumerable.each_context.to_a
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
context "when enumerating graphs" do
|
383
|
+
it "should respond to #each_graph" do
|
384
|
+
@enumerable.should respond_to(:enum_graph)
|
385
|
+
end
|
275
386
|
|
276
|
-
|
387
|
+
it "should respond to #enum_graph" do
|
388
|
+
@enumerable.should respond_to(:enum_graph)
|
389
|
+
end
|
390
|
+
|
391
|
+
it "should implement #each_graph" do
|
392
|
+
@enumerable.each_graph.should be_an_enumerator
|
393
|
+
@enumerable.each_graph { |graph| graph.should be_a_graph }
|
394
|
+
# TODO: relying on #contexts, check that the returned values are correct.
|
395
|
+
end
|
396
|
+
|
397
|
+
it "should implement #enum_graph" do
|
398
|
+
@enumerable.enum_graph.should be_an_enumerator
|
399
|
+
@enumerable.enum_graph.should be_countable
|
400
|
+
@enumerable.enum_graph.to_a.should == @enumerable.each_graph.to_a
|
277
401
|
end
|
278
402
|
end
|
279
403
|
|
280
|
-
|
281
|
-
|
404
|
+
context "when converting" do
|
405
|
+
it "should respond to #to_hash" do
|
406
|
+
@enumerable.should respond_to(:to_hash)
|
407
|
+
end
|
282
408
|
|
283
|
-
#
|
409
|
+
it "should implement #to_hash" do
|
410
|
+
@enumerable.to_hash.should be_instance_of(Hash)
|
411
|
+
@enumerable.to_hash.keys.size.should == @enumerable.subjects.to_a.size
|
412
|
+
end
|
284
413
|
end
|
285
414
|
end
|