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 CHANGED
@@ -15,14 +15,14 @@ Documentation
15
15
  Dependencies
16
16
  ------------
17
17
 
18
- * [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.1.9)
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. To install the latest
25
- official release from Gemcutter, do:
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.10
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
@@ -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
- it "should support #empty?" do
13
- @enumerable.respond_to?(:empty?).should be_true
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
- ([].extend(RDF::Enumerable)).empty?.should be_true
16
- @enumerable.empty?.should be_false
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
- it "should support #count and #size" do
20
- [:count, :size, :length].each do |method|
21
- @enumerable.respond_to?(method).should be_true
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
- @enumerable.send(method).should == @statements.size
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 support #statements" do
29
- @enumerable.respond_to?(:statements).should be_true
46
+ context "when enumerating statements" do
47
+ it "should respond to #statements" do
48
+ @enumerable.should respond_to(:statements)
49
+ end
30
50
 
31
- @enumerable.statements.should be_instance_of(Array)
32
- @enumerable.statements.size.should == @statements.size
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 support #has_statement?" do
37
- @enumerable.respond_to?(:has_statement?).should be_true
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 support #each_statement" do
48
- @enumerable.respond_to?(:each_statement).should be_true
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 support #enum_statement" do
55
- @enumerable.respond_to?(:enum_statement).should be_true
56
-
57
- @enumerable.enum_statement.should be_instance_of(RDF::Enumerator)
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 support #triples" do
63
- @enumerable.respond_to?(:triples).should be_true
99
+ context "when enumerating triples" do
100
+ it "should respond to #triples" do
101
+ @enumerable.should respond_to(:triples)
102
+ end
64
103
 
65
- @enumerable.triples.should be_instance_of(Array)
66
- @enumerable.triples.size.should == @statements.size
67
- @enumerable.triples.each { |triple| triple.should be_a_triple }
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 support #has_triple?" do
71
- @enumerable.respond_to?(:has_triple?).should be_true
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 support #each_triple" do
79
- @enumerable.respond_to?(:each_triple).should be_true
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 support #enum_triple" do
86
- @enumerable.respond_to?(:enum_triple).should be_true
87
-
88
- @enumerable.enum_triple.should be_instance_of(RDF::Enumerator)
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 support #quads" do
94
- @enumerable.respond_to?(:quads).should be_true
140
+ context "when enumerating quads" do
141
+ it "should respond to #quads" do
142
+ @enumerable.should respond_to(:quads)
143
+ end
95
144
 
96
- @enumerable.quads.should be_instance_of(Array)
97
- @enumerable.quads.size.should == @statements.size
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 support #has_quad?" do
102
- @enumerable.respond_to?(:has_quad?).should be_true
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 support #each_quad" do
110
- @enumerable.respond_to?(:each_quad).should be_true
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 support #enum_quad" do
117
- @enumerable.respond_to?(:enum_quad).should be_true
118
-
119
- @enumerable.enum_quad.should be_instance_of(RDF::Enumerator)
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 support #subjects" do
125
- @enumerable.respond_to?(:subjects).should be_true
181
+ context "when enumerating subjects" do
182
+ it "should respond to #subjects" do
183
+ @enumerable.should respond_to(:subjects)
184
+ end
126
185
 
127
- @enumerable.subjects.should be_instance_of(Array)
128
- @enumerable.subjects.each { |value| value.should be_a_resource }
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 support #has_subject?" do
132
- @enumerable.respond_to?(:has_subject?).should be_true
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 support #each_subject" do
144
- @enumerable.respond_to?(:each_subject).should be_true
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 support #enum_subject" do
156
- @enumerable.respond_to?(:enum_subject).should be_true
157
-
158
- @enumerable.enum_subject.should be_instance_of(RDF::Enumerator)
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 support #predicates" do
164
- @enumerable.respond_to?(:predicates).should be_true
231
+ context "when enumerating predicates" do
232
+ it "should respond to #predicates" do
233
+ @enumerable.should respond_to(:predicates)
234
+ end
165
235
 
166
- @enumerable.predicates.should be_instance_of(Array)
167
- @enumerable.predicates.each { |value| value.should be_a_uri }
236
+ it "should respond to #has_predicate?" do
237
+ @enumerable.should respond_to(:has_predicate?)
168
238
  end
169
239
 
170
- it "should support #has_predicate?" do
171
- @enumerable.respond_to?(:has_predicate?).should be_true
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 support #each_predicate" do
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.should be_instance_of(RDF::Enumerator)
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 support #enum_predicate" do
195
- @enumerable.respond_to?(:enum_predicate).should be_true
196
-
197
- @enumerable.enum_predicate.should be_instance_of(RDF::Enumerator)
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 support #objects" do
203
- @enumerable.respond_to?(:objects).should be_true
281
+ context "when enumerating objects" do
282
+ it "should respond to #objects" do
283
+ @enumerable.should respond_to(:objects)
284
+ end
204
285
 
205
- @enumerable.objects.should be_instance_of(Array)
206
- @enumerable.objects.each { |value| value.should be_a_value }
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 support #has_object?" do
210
- @enumerable.respond_to?(:has_object?).should be_true
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 support #each_object" do
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.should be_instance_of(RDF::Enumerator)
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 support #enum_object" do
234
- @enumerable.respond_to?(:enum_object).should be_true
235
-
236
- @enumerable.enum_object.should be_instance_of(RDF::Enumerator)
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 support #contexts" do
242
- @enumerable.respond_to?(:contexts).should be_true
331
+ context "when enumerating contexts" do
332
+ it "should respond to #contexts" do
333
+ @enumerable.should respond_to(:contexts)
334
+ end
243
335
 
244
- @enumerable.contexts.should be_instance_of(Array)
245
- @enumerable.contexts.each { |value| value.should be_a_resource }
336
+ it "should respond to #has_context?" do
337
+ @enumerable.should respond_to(:has_context?)
246
338
  end
247
339
 
248
- it "should support #has_context?" do
249
- @enumerable.respond_to?(:has_context?).should be_true
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 support #each_context" do
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.should be_instance_of(RDF::Enumerator)
267
- @enumerable.each_context do |value|
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 support #enum_context" do
274
- @enumerable.respond_to?(:enum_context).should be_true
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
- @enumerable.enum_context.should be_instance_of(RDF::Enumerator)
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
- it "should support #to_hash" do
281
- @enumerable.respond_to?(:to_hash).should be_true
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
- # TODO
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