rdf 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,248 +0,0 @@
1
- require 'rdf/spec'
2
-
3
- share_as :RDF_Enumerable do
4
- include RDF::Spec::Matchers
5
-
6
- before :each do
7
- raise '+@enumerable+ must be defined in a before(:each) block' unless instance_variable_get('@enumerable')
8
- raise '+@statements+ must be defined in a before(:each) block' unless instance_variable_get('@statements')
9
- end
10
-
11
- it "should support #empty?" do
12
- @enumerable.respond_to?(:empty?).should be_true
13
-
14
- ([].extend(RDF::Enumerable)).empty?.should be_true
15
- @enumerable.empty?.should be_false
16
- end
17
-
18
- it "should support #count and #size" do
19
- [:count, :size, :length].each do |method|
20
- @enumerable.respond_to?(method).should be_true
21
-
22
- @enumerable.send(method).should == @statements.size
23
- end
24
- end
25
-
26
- context "statements" do
27
- it "should support #statements" do
28
- @enumerable.respond_to?(:statements).should be_true
29
-
30
- @enumerable.statements.should be_instance_of(Array)
31
- @enumerable.statements.size.should == @statements.size
32
- @enumerable.statements.each { |statement| statement.should be_a_statement }
33
- end
34
-
35
- it "should support #has_statement?" do
36
- @enumerable.respond_to?(:has_statement?).should be_true
37
-
38
- @statements.each do |statement|
39
- @enumerable.has_statement?(statement).should be_true
40
- end
41
-
42
- @enumerable.has_statement?([RDF::Node.new, RDF::URI.new("http://example.org/unknown"), RDF::Node.new]).should be_false
43
- end
44
-
45
- it "should support #each_statement" do
46
- @enumerable.respond_to?(:each_statement).should be_true
47
-
48
- @enumerable.each_statement.should be_instance_of(Enumerable::Enumerator)
49
- @enumerable.each_statement { |statement| statement.should be_a_statement }
50
- end
51
-
52
- it "should support #enum_statement" do
53
- @enumerable.respond_to?(:enum_statement).should be_true
54
-
55
- @enumerable.enum_statement.should be_instance_of(Enumerable::Enumerator)
56
- end
57
- end
58
-
59
- context "triples" do
60
- it "should support #triples" do
61
- @enumerable.respond_to?(:triples).should be_true
62
-
63
- @enumerable.triples.should be_instance_of(Array)
64
- @enumerable.triples.size.should == @statements.size
65
- @enumerable.triples.each { |triple| triple.should be_a_triple }
66
- end
67
-
68
- it "should support #has_triple?" do
69
- @enumerable.respond_to?(:has_triple?).should be_true
70
-
71
- @statements.each do |statement|
72
- @enumerable.has_triple?(statement.to_triple).should be_true
73
- end
74
- end
75
-
76
- it "should support #each_triple" do
77
- @enumerable.respond_to?(:each_triple).should be_true
78
-
79
- @enumerable.each_triple.should be_instance_of(Enumerable::Enumerator)
80
- @enumerable.each_triple { |*triple| triple.should be_a_triple }
81
- end
82
-
83
- it "should support #enum_triple" do
84
- @enumerable.respond_to?(:enum_triple).should be_true
85
-
86
- @enumerable.enum_triple.should be_instance_of(Enumerable::Enumerator)
87
- end
88
- end
89
-
90
- context "quads" do
91
- it "should support #quads" do
92
- @enumerable.respond_to?(:quads).should be_true
93
-
94
- @enumerable.quads.should be_instance_of(Array)
95
- @enumerable.quads.size.should == @statements.size
96
- @enumerable.quads.each { |quad| quad.should be_a_quad }
97
- end
98
-
99
- it "should support #has_quad?" do
100
- @enumerable.respond_to?(:has_quad?).should be_true
101
-
102
- @statements.each do |statement|
103
- @enumerable.has_quad?(statement.to_quad).should be_true
104
- end
105
- end
106
-
107
- it "should support #each_quad" do
108
- @enumerable.respond_to?(:each_quad).should be_true
109
-
110
- @enumerable.each_quad.should be_instance_of(Enumerable::Enumerator)
111
- @enumerable.each_quad { |*quad| quad.should be_a_quad }
112
- end
113
-
114
- it "should support #enum_quad" do
115
- @enumerable.respond_to?(:enum_quad).should be_true
116
-
117
- @enumerable.enum_quad.should be_instance_of(Enumerable::Enumerator)
118
- end
119
- end
120
-
121
- context "subjects" do
122
- it "should support #subjects" do
123
- @enumerable.respond_to?(:subjects).should be_true
124
-
125
- @enumerable.subjects.should be_instance_of(Array)
126
- @enumerable.subjects.each { |value| value.should be_a_resource }
127
- end
128
-
129
- it "should support #has_subject?" do
130
- @enumerable.respond_to?(:has_subject?).should be_true
131
-
132
- @statements.each do |statement|
133
- @enumerable.has_subject?(statement.subject).should be_true
134
- end
135
- end
136
-
137
- it "should support #each_subject" do
138
- @enumerable.respond_to?(:each_subject).should be_true
139
-
140
- @enumerable.each_subject.should be_instance_of(Enumerable::Enumerator)
141
- @enumerable.each_subject { |value| value.should be_a_resource }
142
- end
143
-
144
- it "should support #enum_subject" do
145
- @enumerable.respond_to?(:enum_subject).should be_true
146
-
147
- @enumerable.enum_subject.should be_instance_of(Enumerable::Enumerator)
148
- end
149
- end
150
-
151
- context "predicates" do
152
- it "should support #predicates" do
153
- @enumerable.respond_to?(:predicates).should be_true
154
-
155
- @enumerable.predicates.should be_instance_of(Array)
156
- @enumerable.predicates.each { |value| value.should be_a_uri }
157
- end
158
-
159
- it "should support #has_predicate?" do
160
- @enumerable.respond_to?(:has_predicate?).should be_true
161
-
162
- @statements.each do |statement|
163
- @enumerable.has_predicate?(statement.predicate).should be_true
164
- end
165
- end
166
-
167
- it "should support #each_predicate" do
168
- @enumerable.respond_to?(:each_predicate).should be_true
169
-
170
- @enumerable.each_predicate.should be_instance_of(Enumerable::Enumerator)
171
- @enumerable.each_predicate { |value| value.should be_a_uri }
172
- end
173
-
174
- it "should support #enum_predicate" do
175
- @enumerable.respond_to?(:enum_predicate).should be_true
176
-
177
- @enumerable.enum_predicate.should be_instance_of(Enumerable::Enumerator)
178
- end
179
- end
180
-
181
- context "objects" do
182
- it "should support #objects" do
183
- @enumerable.respond_to?(:objects).should be_true
184
-
185
- @enumerable.objects.should be_instance_of(Array)
186
- @enumerable.objects.each { |value| value.should be_a_value }
187
- end
188
-
189
- it "should support #has_object?" do
190
- @enumerable.respond_to?(:has_object?).should be_true
191
-
192
- @statements.each do |statement|
193
- @enumerable.has_object?(statement.object).should be_true
194
- end
195
- end
196
-
197
- it "should support #each_object" do
198
- @enumerable.respond_to?(:each_object).should be_true
199
-
200
- @enumerable.each_object.should be_instance_of(Enumerable::Enumerator)
201
- @enumerable.each_object { |value| value.should be_a_value }
202
- end
203
-
204
- it "should support #enum_object" do
205
- @enumerable.respond_to?(:enum_object).should be_true
206
-
207
- @enumerable.enum_object.should be_instance_of(Enumerable::Enumerator)
208
- end
209
- end
210
-
211
- context "contexts" do
212
- it "should support #contexts" do
213
- @enumerable.respond_to?(:contexts).should be_true
214
-
215
- @enumerable.contexts.should be_instance_of(Array)
216
- @enumerable.contexts.each { |value| value.should be_a_resource }
217
- end
218
-
219
- it "should support #has_context?" do
220
- @enumerable.respond_to?(:has_context?).should be_true
221
-
222
- @statements.each do |statement|
223
- if statement.has_context?
224
- @enumerable.has_context?(statement.context).should be_true
225
- end
226
- end
227
- end
228
-
229
- it "should support #each_context" do
230
- @enumerable.respond_to?(:each_context).should be_true
231
-
232
- @enumerable.each_context.should be_instance_of(Enumerable::Enumerator)
233
- @enumerable.each_context { |value| value.should be_a_resource }
234
- end
235
-
236
- it "should support #enum_context" do
237
- @enumerable.respond_to?(:enum_context).should be_true
238
-
239
- @enumerable.enum_context.should be_instance_of(Enumerable::Enumerator)
240
- end
241
- end
242
-
243
- it "should support #to_hash" do
244
- @enumerable.respond_to?(:to_hash).should be_true
245
-
246
- # TODO
247
- end
248
- end
@@ -1,77 +0,0 @@
1
- require 'rdf/spec'
2
-
3
- share_as :RDF_Repository do
4
- include RDF::Spec::Matchers
5
-
6
- before :each do
7
- raise '+@repository+ must be defined in a before(:each) block' unless instance_variable_get('@repository')
8
- @filename = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'etc', 'doap.nt'))
9
- @statements = RDF::NTriples::Reader.new(File.open(@filename)).to_a
10
- @enumerable = @repository
11
- end
12
-
13
- it "should be empty initially" do
14
- @repository.empty?.should be_true
15
- @repository.count.should be_zero
16
- end
17
-
18
- it "should be readable" do
19
- @repository.readable?.should be_true
20
- end
21
-
22
- it "should be mutable" do
23
- @repository.immutable?.should be_false
24
- @repository.mutable?.should be_true
25
- end
26
-
27
- context "when inserting statements" do
28
- it "should support #insert" do
29
- @repository.should respond_to(:insert)
30
- end
31
-
32
- it "should not raise errors" do
33
- lambda { @repository.insert(@statements.first) }.should_not raise_error
34
- end
35
-
36
- it "should support inserting one statement at a time" do
37
- @repository.insert(@statements.first)
38
- end
39
-
40
- it "should support inserting multiple statements at a time" do
41
- @repository.insert(*@statements)
42
- end
43
-
44
- it "should insert statements successfully" do
45
- @repository.insert(*@statements)
46
- @repository.count.should == @statements.size
47
- end
48
- end
49
-
50
- context "when deleting statements" do
51
- it "should support #delete" do
52
- @repository.should respond_to(:delete)
53
- end
54
-
55
- it "should not raise errors"
56
- it "should support deleting one statement at a time"
57
- it "should support deleting multiple statements at a time"
58
- it "should delete statements successfully"
59
- end
60
-
61
- context "when clearing all statements" do
62
- it "should support #clear" do
63
- @repository.should respond_to(:clear)
64
- end
65
- end
66
-
67
- context "when enumerating statements" do
68
- require 'rdf/spec/enumerable'
69
-
70
- before :each do
71
- @repository.insert(*@statements)
72
- @enumerable = @repository
73
- end
74
-
75
- it_should_behave_like RDF_Enumerable
76
- end
77
- end