rdf-spec 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +20 -3
- data/VERSION +1 -1
- data/etc/doap.nt +14 -6
- data/lib/rdf/spec/countable.rb +13 -6
- data/lib/rdf/spec/durable.rb +2 -3
- data/lib/rdf/spec/graph.rb +0 -2
- data/lib/rdf/spec/list.rb +713 -0
- data/lib/rdf/spec/literal.rb +0 -1
- data/lib/rdf/spec/matchers.rb +7 -0
- data/lib/rdf/spec/node.rb +0 -2
- data/lib/rdf/spec/query.rb +8 -0
- data/lib/rdf/spec/readable.rb +8 -0
- data/lib/rdf/spec/resource.rb +8 -0
- data/lib/rdf/spec/value.rb +0 -1
- data/lib/rdf/spec/version.rb +1 -1
- data/lib/rdf/spec/vocab.rb +8 -0
- data/lib/rdf/spec/writable.rb +8 -0
- metadata +11 -5
data/README
CHANGED
@@ -15,7 +15,7 @@ Documentation
|
|
15
15
|
Dependencies
|
16
16
|
------------
|
17
17
|
|
18
|
-
* [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.2.
|
18
|
+
* [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.2.3)
|
19
19
|
* [RSpec](http://gemcutter.org/gems/rspec) (>= 1.3.0)
|
20
20
|
|
21
21
|
Installation
|
@@ -50,11 +50,28 @@ Contributors
|
|
50
50
|
* [Gregg Kellogg](mailto:gregg@kellogg-assoc.com) - <http://kellogg-assoc.com/>
|
51
51
|
* [John Fieber](mailto:jrf@ursamaris.org) - <http://github.com/jfieber>
|
52
52
|
|
53
|
+
Contributing
|
54
|
+
------------
|
55
|
+
* Do your best to adhere to the existing coding conventions and idioms.
|
56
|
+
* Don't use hard tabs, and don't leave trailing whitespace on any line.
|
57
|
+
* Do refer to the [RubySpec Style Guide][RubySpec] for best practices.
|
58
|
+
* Don't touch the `.gemspec` or `VERSION` files. If you need to change them,
|
59
|
+
do so on your private branch only.
|
60
|
+
* Do feel free to add yourself to the `CONTRIBUTORS` file and the
|
61
|
+
corresponding list in the the `README`. Alphabetical order applies.
|
62
|
+
* Don't touch the `AUTHORS` file. If your contributions are significant
|
63
|
+
enough, be assured we will eventually add you in there.
|
64
|
+
* Do note that in order for us to merge any non-trivial changes (as a rule
|
65
|
+
of thumb, additions larger than about 15 lines of code), we need an
|
66
|
+
explicit [public domain dedication][PDD] on record from you.
|
67
|
+
|
53
68
|
License
|
54
69
|
-------
|
55
70
|
|
56
71
|
`RDF::Spec` is free and unencumbered public domain software. For more
|
57
72
|
information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
|
58
73
|
|
59
|
-
[RDF.rb]:
|
60
|
-
[RSpec]:
|
74
|
+
[RDF.rb]: http://rdf.rubyforge.org/
|
75
|
+
[RSpec]: http://rspec.info/
|
76
|
+
[RubySpec]: http://rubyspec.org/wiki/rubyspec/Style_Guide
|
77
|
+
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/etc/doap.nt
CHANGED
@@ -27,6 +27,8 @@
|
|
27
27
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
28
28
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
29
29
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid3 .
|
30
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid4 .
|
31
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid5 .
|
30
32
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
|
31
33
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
32
34
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
@@ -37,11 +39,17 @@
|
|
37
39
|
<http://rubygems.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
|
38
40
|
<http://rubygems.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
|
39
41
|
_: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> "
|
41
|
-
_:genid1 <http://xmlns.com/foaf/0.1/name> "
|
42
|
+
_:genid1 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d31fdd6af7a279a89bf09fdc9f7c44d9d08bb930" .
|
43
|
+
_:genid1 <http://xmlns.com/foaf/0.1/name> "Fumihiro Kato" .
|
42
44
|
_: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> "
|
44
|
-
_:genid2 <http://xmlns.com/foaf/0.1/name> "
|
45
|
+
_:genid2 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
|
46
|
+
_:genid2 <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
|
45
47
|
_: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> "
|
47
|
-
_:genid3 <http://xmlns.com/foaf/0.1/name> "
|
48
|
+
_:genid3 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "c69f3255ff0639543cc5edfd8116eac8df16fab8" .
|
49
|
+
_:genid3 <http://xmlns.com/foaf/0.1/name> "Hellekin O. Wolf" .
|
50
|
+
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
51
|
+
_:genid4 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" .
|
52
|
+
_:genid4 <http://xmlns.com/foaf/0.1/name> "John Fieber" .
|
53
|
+
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
54
|
+
_:genid5 <http://xmlns.com/foaf/0.1/mbox_sha1sum> "bedbbf2451e5beb38d59687c0460032aff92cd3c" .
|
55
|
+
_:genid5 <http://xmlns.com/foaf/0.1/name> "Pius Uzamere" .
|
data/lib/rdf/spec/countable.rb
CHANGED
@@ -19,24 +19,31 @@ share_as :RDF_Countable do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
it "
|
22
|
+
describe "when counting items" do
|
23
|
+
it "responds to #empty?" do
|
24
24
|
@countable.should respond_to(:empty?)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
@countable.should respond_to(
|
27
|
+
it "responds to #count and #size" do
|
28
|
+
@countable.should respond_to(:count, :size)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "implements #empty?" do
|
32
32
|
([].extend(RDF::Countable)).empty?.should be_true
|
33
|
+
([42].extend(RDF::Countable)).empty?.should be_false
|
33
34
|
@countable.empty?.should be_false
|
34
35
|
end
|
35
36
|
|
36
|
-
it "
|
37
|
+
it "implements #count and #size" do
|
37
38
|
%w(count size).each do |method|
|
38
39
|
@countable.send(method).should == @statements.size
|
39
40
|
end
|
40
41
|
end
|
42
|
+
|
43
|
+
it "returns countable enumerators" do
|
44
|
+
@countable.to_enum.should be_countable
|
45
|
+
@countable.enum_for.should be_countable
|
46
|
+
@countable.enum_for(:each).should be_countable
|
47
|
+
end
|
41
48
|
end
|
42
49
|
end
|
data/lib/rdf/spec/durable.rb
CHANGED
@@ -39,12 +39,11 @@ share_as :RDF_Durable do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should not be both durable and nondurable" do
|
42
|
-
@load_durable.call.nondurable?.should_not == @load_durable.call.durable?
|
42
|
+
@load_durable.call.nondurable?.should_not == @load_durable.call.durable?
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should save contents between instantiations" do
|
46
46
|
@load_durable.call.load(@filename)
|
47
|
-
@load_durable.call.count.should == File.readlines(@filename).size
|
47
|
+
@load_durable.call.count.should == File.readlines(@filename).size
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
data/lib/rdf/spec/graph.rb
CHANGED
@@ -2,7 +2,6 @@ require 'rdf'
|
|
2
2
|
require 'rdf/spec'
|
3
3
|
|
4
4
|
share_as :RDF_Graph do
|
5
|
-
|
6
5
|
before :each do
|
7
6
|
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
8
7
|
end
|
@@ -52,5 +51,4 @@ share_as :RDF_Graph do
|
|
52
51
|
graph.should_not be_anonymous
|
53
52
|
end
|
54
53
|
end
|
55
|
-
|
56
54
|
end
|
@@ -0,0 +1,713 @@
|
|
1
|
+
require 'rdf/spec'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
share_as :RDF_List do
|
5
|
+
before :all do
|
6
|
+
@nil = RDF::List::NIL
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@abc = RDF::List[
|
11
|
+
@a = RDF::Literal.new('a'),
|
12
|
+
@b = RDF::Literal.new('b'),
|
13
|
+
@c = RDF::Literal.new('c')]
|
14
|
+
@ten = RDF::List[*(1..10)]
|
15
|
+
end
|
16
|
+
|
17
|
+
ORDINALS = %w(first second third fourth fifth sixth seventh eighth ninth tenth)
|
18
|
+
|
19
|
+
it "is comparable" do
|
20
|
+
RDF::List.new.should be_a_kind_of(::Comparable)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is enumerable" do
|
24
|
+
RDF::List.new.should be_a_kind_of(::Enumerable)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe RDF::List, "[] without arguments" do
|
28
|
+
it "constructs a new empty list" do
|
29
|
+
RDF::List[].should be_an(RDF::List)
|
30
|
+
RDF::List[].should be_empty
|
31
|
+
RDF::List[].should == RDF::List::NIL
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe RDF::List, "[] with arguments" do
|
36
|
+
it "constructs a new non-empty list" do
|
37
|
+
RDF::List[1, 2, 3].should be_an(RDF::List)
|
38
|
+
RDF::List[1, 2, 3].should_not be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
it "accepts list arguments" do
|
42
|
+
lambda { RDF::List[RDF::List[]] }.should_not raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "accepts array arguments" do
|
46
|
+
lambda { RDF::List[[]] }.should_not raise_error
|
47
|
+
RDF::List[[]].should == RDF::List[RDF::List[]]
|
48
|
+
end
|
49
|
+
|
50
|
+
it "accepts blank node arguments" do
|
51
|
+
lambda { RDF::List[RDF::Node.new] }.should_not raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
it "accepts URI arguments" do
|
55
|
+
lambda { RDF::List[RDF.nil] }.should_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "accepts nil arguments" do
|
59
|
+
lambda { RDF::List[nil] }.should_not raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it "accepts literal arguments" do
|
63
|
+
lambda { RDF::List[RDF::Literal.new("Hello, world!", :language => :en)] }.should_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it "accepts boolean arguments" do
|
67
|
+
lambda { RDF::List[true, false] }.should_not raise_error
|
68
|
+
end
|
69
|
+
|
70
|
+
it "accepts string arguments" do
|
71
|
+
lambda { RDF::List["foo", "bar"] }.should_not raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "accepts integer arguments" do
|
75
|
+
lambda { RDF::List[1, 2, 3] }.should_not raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "accepts float arguments" do
|
79
|
+
lambda { RDF::List[3.1415] }.should_not raise_error
|
80
|
+
end
|
81
|
+
|
82
|
+
it "accepts decimal arguments" do
|
83
|
+
lambda { RDF::List[BigDecimal("3.1415")] }.should_not raise_error
|
84
|
+
end
|
85
|
+
|
86
|
+
it "accepts time arguments" do
|
87
|
+
lambda { RDF::List[Time.now] }.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "accepts date arguments" do
|
91
|
+
lambda { RDF::List[Date.new(2010)] }.should_not raise_error
|
92
|
+
end
|
93
|
+
|
94
|
+
it "accepts datetime arguments" do
|
95
|
+
lambda { RDF::List[DateTime.new(2010)] }.should_not raise_error
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe RDF::List, "#subject" do
|
100
|
+
it "requires no arguments" do
|
101
|
+
lambda { @nil.subject }.should_not raise_error(ArgumentError)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "returns a resource" do
|
105
|
+
@nil.subject.should be_a_resource
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe RDF::List, "#graph" do
|
110
|
+
it "requires no arguments" do
|
111
|
+
lambda { @nil.graph }.should_not raise_error(ArgumentError)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "returns a graph" do
|
115
|
+
@nil.graph.should be_a_graph
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe RDF::List, "#&" do
|
120
|
+
it "accepts one argument" do
|
121
|
+
lambda { @nil & @nil }.should_not raise_error(ArgumentError)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "rejects fewer arguments" do
|
125
|
+
lambda { @nil.__send__(:&) }.should raise_error(ArgumentError)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns the set intersection of self and the given argument" do
|
129
|
+
(RDF::List[1, 2] & RDF::List[1, 2]).should == RDF::List[1, 2]
|
130
|
+
(RDF::List[1, 2] & RDF::List[2, 3]).should == RDF::List[2]
|
131
|
+
(RDF::List[1, 2] & RDF::List[3, 4]).should == RDF::List[]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe RDF::List, "#|" do
|
136
|
+
it "accepts one argument" do
|
137
|
+
lambda { @nil | @nil }.should_not raise_error(ArgumentError)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "rejects fewer arguments" do
|
141
|
+
lambda { @nil.__send__(:|) }.should raise_error(ArgumentError)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "returns the set union of self and the given argument" do
|
145
|
+
(RDF::List[1, 2] | RDF::List[1, 2]).should == RDF::List[1, 2]
|
146
|
+
(RDF::List[1, 2] | RDF::List[2, 3]).should == RDF::List[1, 2, 3]
|
147
|
+
(RDF::List[1, 2] | RDF::List[3, 4]).should == RDF::List[1, 2, 3, 4]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe RDF::List, "#+" do
|
152
|
+
it "accepts one argument" do
|
153
|
+
lambda { @nil + @nil }.should_not raise_error(ArgumentError)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "rejects fewer arguments" do
|
157
|
+
lambda { @nil.__send__(:+) }.should raise_error(ArgumentError)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "returns the concatenation of self and the given argument" do
|
161
|
+
(RDF::List[1, 2] + RDF::List[3, 4]).should == RDF::List[1, 2, 3, 4]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe RDF::List, "#-" do
|
166
|
+
it "accepts one argument" do
|
167
|
+
lambda { @nil - @nil }.should_not raise_error(ArgumentError)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "rejects fewer arguments" do
|
171
|
+
lambda { @nil.__send__(:-) }.should raise_error(ArgumentError)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns the difference between self and the given argument" do
|
175
|
+
(RDF::List[1, 2, 2, 3] - RDF::List[2]).should == RDF::List[1, 3]
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe RDF::List, "#*" do
|
180
|
+
it "accepts one argument" do
|
181
|
+
lambda { @nil * 1 }.should_not raise_error(ArgumentError)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "rejects fewer arguments" do
|
185
|
+
lambda { @nil.__send__(:*) }.should raise_error(ArgumentError)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe RDF::List, "#* with an integer argument" do
|
190
|
+
it "returns a repetition of self" do
|
191
|
+
(RDF::List[1, 2, 3] * 2).should == RDF::List[1, 2, 3, 1, 2, 3]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe RDF::List, "#* with a string argument" do
|
196
|
+
it "returns the string concatenation of all elements" do
|
197
|
+
(RDF::List[1, 2, 3] * ",").should == "1,2,3"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe RDF::List, "#[]" do
|
202
|
+
it "accepts one argument" do
|
203
|
+
lambda { @nil[0] }.should_not raise_error(ArgumentError)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "rejects fewer arguments" do
|
207
|
+
lambda { @nil.__send__(:[]) }.should raise_error(ArgumentError)
|
208
|
+
end
|
209
|
+
|
210
|
+
it "returns a value for valid indexes" do
|
211
|
+
@ten[0].should be_a_value
|
212
|
+
end
|
213
|
+
|
214
|
+
it "returns nil for invalid indexes" do
|
215
|
+
@nil[0].should be_nil
|
216
|
+
@ten[20].should be_nil
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe RDF::List, "#[]=" do
|
221
|
+
# TODO
|
222
|
+
end
|
223
|
+
|
224
|
+
describe RDF::List, "#<<" do
|
225
|
+
it "accepts one argument" do
|
226
|
+
lambda { @ten << 11 }.should_not raise_error(ArgumentError)
|
227
|
+
end
|
228
|
+
|
229
|
+
it "rejects fewer arguments" do
|
230
|
+
lambda { @ten.__send__(:<<) }.should raise_error(ArgumentError)
|
231
|
+
end
|
232
|
+
|
233
|
+
it "appends the new value at the tail of the list" do
|
234
|
+
@ten << 11
|
235
|
+
@ten.last.should == RDF::Literal.new(11)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "increments the length of the list by one" do
|
239
|
+
@ten << 11
|
240
|
+
@ten.length.should == 11
|
241
|
+
end
|
242
|
+
|
243
|
+
it "returns self" do
|
244
|
+
(@ten << 11).should equal(@ten)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe RDF::List, "#shift" do
|
249
|
+
# TODO
|
250
|
+
end
|
251
|
+
|
252
|
+
describe RDF::List, "#unshift" do
|
253
|
+
# TODO
|
254
|
+
end
|
255
|
+
|
256
|
+
describe RDF::List, "#clear" do
|
257
|
+
# TODO
|
258
|
+
end
|
259
|
+
|
260
|
+
describe RDF::List, "#eql?" do
|
261
|
+
it "requires an argument" do
|
262
|
+
lambda { @nil.send(:eql?) }.should raise_error(ArgumentError)
|
263
|
+
end
|
264
|
+
|
265
|
+
it "returns true when given the same list" do
|
266
|
+
@ten.should eql(@ten)
|
267
|
+
end
|
268
|
+
|
269
|
+
# TODO
|
270
|
+
end
|
271
|
+
|
272
|
+
describe RDF::List, "#<=>" do
|
273
|
+
it "requires an argument" do
|
274
|
+
lambda { @nil.send(:<=>) }.should raise_error(ArgumentError)
|
275
|
+
end
|
276
|
+
|
277
|
+
it "returns 0 when given the same list" do
|
278
|
+
@ten.should == @ten
|
279
|
+
end
|
280
|
+
|
281
|
+
# TODO
|
282
|
+
end
|
283
|
+
|
284
|
+
describe RDF::List, "#==" do
|
285
|
+
it "requires an argument" do
|
286
|
+
lambda { @nil.send(:==) }.should raise_error(ArgumentError)
|
287
|
+
end
|
288
|
+
|
289
|
+
it "returns true when given the same list" do
|
290
|
+
@ten.should == @ten
|
291
|
+
end
|
292
|
+
|
293
|
+
# TODO
|
294
|
+
end
|
295
|
+
|
296
|
+
describe RDF::List, "#===" do
|
297
|
+
it "requires an argument" do
|
298
|
+
lambda { @nil.send(:===) }.should raise_error(ArgumentError)
|
299
|
+
end
|
300
|
+
|
301
|
+
it "returns true when given the same list" do
|
302
|
+
@ten.should == @ten
|
303
|
+
end
|
304
|
+
|
305
|
+
# TODO
|
306
|
+
end
|
307
|
+
|
308
|
+
describe RDF::List, "#empty?" do
|
309
|
+
it "requires no arguments" do
|
310
|
+
lambda { @nil.empty? }.should_not raise_error(ArgumentError)
|
311
|
+
end
|
312
|
+
|
313
|
+
it "returns a boolean" do
|
314
|
+
@nil.empty?.should be_true
|
315
|
+
@abc.empty?.should be_false
|
316
|
+
@ten.empty?.should be_false
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
describe RDF::List, "#length" do
|
321
|
+
it "requires no arguments" do
|
322
|
+
lambda { @nil.length }.should_not raise_error(ArgumentError)
|
323
|
+
end
|
324
|
+
|
325
|
+
it "returns an integer" do
|
326
|
+
@nil.length.should be_an(Integer)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "returns the length of the list" do
|
330
|
+
@nil.length.should == 0
|
331
|
+
@abc.length.should == 3
|
332
|
+
@ten.length.should == 10
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe RDF::List, "#size" do
|
337
|
+
it "aliases #length" do
|
338
|
+
@nil.size.should == @nil.length
|
339
|
+
@ten.size.should == @ten.length
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe RDF::List, "#index" do
|
344
|
+
it "accepts one argument" do
|
345
|
+
lambda { @ten.index(nil) }.should_not raise_error(ArgumentError)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe RDF::List, "#slice using an element index" do
|
350
|
+
it "accepts one argument" do
|
351
|
+
lambda { @ten.slice(0) }.should_not raise_error(ArgumentError)
|
352
|
+
end
|
353
|
+
|
354
|
+
it "returns a value" do
|
355
|
+
@ten.slice(0).should be_a_value
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
describe RDF::List, "#slice using a start index and a length" do
|
360
|
+
it "accepts two arguments" do
|
361
|
+
lambda { @ten.slice(0, 9) }.should_not raise_error(ArgumentError)
|
362
|
+
end
|
363
|
+
|
364
|
+
it "returns a value" do
|
365
|
+
@ten.slice(0).should be_a_value
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe RDF::List, "#slice using a range" do
|
370
|
+
it "accepts one argument" do
|
371
|
+
lambda { @ten.slice(0..9) }.should_not raise_error(ArgumentError)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe RDF::List, "#fetch" do
|
376
|
+
it "requires one argument" do
|
377
|
+
lambda { @ten.fetch }.should raise_error(ArgumentError)
|
378
|
+
lambda { @ten.fetch(0) }.should_not raise_error(ArgumentError)
|
379
|
+
end
|
380
|
+
|
381
|
+
it "returns a value" do
|
382
|
+
@ten.fetch(0).should be_a_value
|
383
|
+
end
|
384
|
+
|
385
|
+
it "returns the value at the given index" do
|
386
|
+
@ten.fetch(0).should == RDF::Literal.new(1)
|
387
|
+
@ten.fetch(9).should == RDF::Literal.new(10)
|
388
|
+
end
|
389
|
+
|
390
|
+
it "raises IndexError for invalid indexes" do
|
391
|
+
lambda { @ten.fetch(20) }.should raise_error(IndexError)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
describe RDF::List, "#fetch with a default value" do
|
396
|
+
it "accepts two arguments" do
|
397
|
+
lambda { @ten.fetch(0, nil) }.should_not raise_error(ArgumentError)
|
398
|
+
end
|
399
|
+
|
400
|
+
it "returns the second argument for invalid indexes" do
|
401
|
+
lambda { @ten.fetch(20, nil) }.should_not raise_error(IndexError)
|
402
|
+
@ten.fetch(20, true).should == true
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
describe RDF::List, "#fetch with a block" do
|
407
|
+
it "yields to the given block for invalid indexes" do
|
408
|
+
lambda { @ten.fetch(20) { |index| } }.should_not raise_error(IndexError)
|
409
|
+
@ten.fetch(20) { |index| true }.should == true
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
describe RDF::List, "#at" do
|
414
|
+
it "accepts one argument" do
|
415
|
+
lambda { @ten.at(0) }.should_not raise_error(ArgumentError)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
describe RDF::List, "#nth" do
|
420
|
+
it "aliases #at" do
|
421
|
+
(1..10).each do |n|
|
422
|
+
@ten.nth(n).should == @ten.at(n)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
ORDINALS.each_with_index do |ordinal, index|
|
428
|
+
describe RDF::List, "##{ordinal}" do
|
429
|
+
it "requires no arguments" do
|
430
|
+
lambda { @ten.__send__(ordinal.to_sym) }.should_not raise_error(ArgumentError)
|
431
|
+
end
|
432
|
+
|
433
|
+
it "returns a value" do
|
434
|
+
@ten.__send__(ordinal.to_sym).should be_a_value
|
435
|
+
end
|
436
|
+
|
437
|
+
it "returns the #{ordinal} value in the list" do
|
438
|
+
@ten.__send__(ordinal.to_sym).should == RDF::Literal.new(index + 1)
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
describe RDF::List, "#last" do
|
444
|
+
it "requires no arguments" do
|
445
|
+
lambda { @ten.last }.should_not raise_error(ArgumentError)
|
446
|
+
end
|
447
|
+
|
448
|
+
# TODO
|
449
|
+
end
|
450
|
+
|
451
|
+
describe RDF::List, "#rest" do
|
452
|
+
it "requires no arguments" do
|
453
|
+
lambda { @ten.rest }.should_not raise_error(ArgumentError)
|
454
|
+
end
|
455
|
+
|
456
|
+
# TODO
|
457
|
+
end
|
458
|
+
|
459
|
+
describe RDF::List, "#tail" do
|
460
|
+
it "requires no arguments" do
|
461
|
+
lambda { @ten.tail }.should_not raise_error(ArgumentError)
|
462
|
+
end
|
463
|
+
|
464
|
+
# TODO
|
465
|
+
end
|
466
|
+
|
467
|
+
describe RDF::List, "#first_subject" do
|
468
|
+
it "requires no arguments" do
|
469
|
+
lambda { @ten.first_subject }.should_not raise_error(ArgumentError)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
describe RDF::List, "#rest_subject" do
|
474
|
+
it "requires no arguments" do
|
475
|
+
lambda { @ten.rest_subject }.should_not raise_error(ArgumentError)
|
476
|
+
end
|
477
|
+
|
478
|
+
# TODO
|
479
|
+
end
|
480
|
+
|
481
|
+
describe RDF::List, "#last_subject" do
|
482
|
+
it "requires no arguments" do
|
483
|
+
lambda { @ten.last_subject }.should_not raise_error(ArgumentError)
|
484
|
+
end
|
485
|
+
|
486
|
+
# TODO
|
487
|
+
end
|
488
|
+
|
489
|
+
describe RDF::List, "#each_subject without a block" do
|
490
|
+
it "requires no arguments" do
|
491
|
+
lambda { @ten.each_subject }.should_not raise_error(ArgumentError)
|
492
|
+
end
|
493
|
+
|
494
|
+
it "returns an enumerator" do
|
495
|
+
@abc.each_subject.should be_an_enumerator
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
describe RDF::List, "#each_subject with a block" do
|
500
|
+
it "requires no arguments" do
|
501
|
+
lambda { @ten.each_subject { |subject| } }.should_not raise_error(ArgumentError)
|
502
|
+
end
|
503
|
+
|
504
|
+
it "yields all subject terms in the list" do
|
505
|
+
count = 0
|
506
|
+
@ten.each_subject { |subject| count += 1 }
|
507
|
+
count.should == 10
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
describe RDF::List, "#each without a block" do
|
512
|
+
it "requires no arguments" do
|
513
|
+
lambda { @ten.each }.should_not raise_error(ArgumentError)
|
514
|
+
end
|
515
|
+
|
516
|
+
it "returns an enumerator" do
|
517
|
+
@abc.each_subject.should be_an_enumerator
|
518
|
+
end
|
519
|
+
end
|
520
|
+
|
521
|
+
describe RDF::List, "#each with a block" do
|
522
|
+
it "requires no arguments" do
|
523
|
+
lambda { @ten.each { |value| } }.should_not raise_error(ArgumentError)
|
524
|
+
end
|
525
|
+
|
526
|
+
it "yields the correct number of times" do
|
527
|
+
@abc.each.count.should == 3
|
528
|
+
@ten.each.count.should == 10
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
describe RDF::List, "#each_statement without a block" do
|
533
|
+
it "requires no arguments" do
|
534
|
+
lambda { @ten.each_statement }.should_not raise_error(ArgumentError)
|
535
|
+
end
|
536
|
+
|
537
|
+
it "returns an enumerator" do
|
538
|
+
@abc.each_subject.should be_an_enumerator
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
describe RDF::List, "#each_statement with a block" do
|
543
|
+
it "requires no arguments" do
|
544
|
+
lambda { @ten.each_statement { |statement| } }.should_not raise_error(ArgumentError)
|
545
|
+
end
|
546
|
+
|
547
|
+
it "yields the correct number of times" do
|
548
|
+
@abc.each_statement.count.should == 3 * 3
|
549
|
+
@ten.each_statement.count.should == 10 * 3
|
550
|
+
end
|
551
|
+
|
552
|
+
it "yields statements" do
|
553
|
+
@ten.each_statement do |statement|
|
554
|
+
statement.should be_a_statement
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
describe RDF::List, "#join" do
|
560
|
+
it "requires no arguments" do
|
561
|
+
lambda { @nil.join }.should_not raise_error(ArgumentError)
|
562
|
+
end
|
563
|
+
|
564
|
+
it "accepts one argument" do
|
565
|
+
lambda { @nil.join(', ') }.should_not raise_error(ArgumentError)
|
566
|
+
end
|
567
|
+
|
568
|
+
it "returns a string" do
|
569
|
+
@ten.join.should be_a(String)
|
570
|
+
end
|
571
|
+
|
572
|
+
it "returns a particular string" do
|
573
|
+
@ten.join.should == '12345678910'
|
574
|
+
@ten.join(',').should == '1,2,3,4,5,6,7,8,9,10'
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
describe RDF::List, "#reverse" do
|
579
|
+
it "requires no arguments" do
|
580
|
+
lambda { @nil.reverse }.should_not raise_error(ArgumentError)
|
581
|
+
end
|
582
|
+
|
583
|
+
it "returns a list" do
|
584
|
+
@ten.reverse.should be_a_list
|
585
|
+
end
|
586
|
+
|
587
|
+
it "returns the values reversed" do
|
588
|
+
@ten.reverse.first.should == RDF::Literal.new(10)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
describe RDF::List, "#sort without a block" do
|
593
|
+
it "requires no arguments" do
|
594
|
+
lambda { @nil.sort }.should_not raise_error(ArgumentError)
|
595
|
+
end
|
596
|
+
|
597
|
+
it "returns a list" do
|
598
|
+
@ten.sort.should be_a_list
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
describe RDF::List, "#sort with a block" do
|
603
|
+
it "requires no arguments" do
|
604
|
+
lambda { @nil.sort { |a, b| } }.should_not raise_error(ArgumentError)
|
605
|
+
end
|
606
|
+
|
607
|
+
it "returns a list" do
|
608
|
+
@ten.sort { |a, b| a <=> b }.should be_a_list
|
609
|
+
end
|
610
|
+
end
|
611
|
+
|
612
|
+
describe RDF::List, "#sort_by with a block" do
|
613
|
+
it "requires no arguments" do
|
614
|
+
lambda { @nil.sort_by { |value| } }.should_not raise_error(ArgumentError)
|
615
|
+
end
|
616
|
+
|
617
|
+
it "returns a list" do
|
618
|
+
@ten.sort_by(&:to_i).should be_a_list
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
622
|
+
describe RDF::List, "#uniq" do
|
623
|
+
it "requires no arguments" do
|
624
|
+
lambda { @nil.uniq }.should_not raise_error(ArgumentError)
|
625
|
+
end
|
626
|
+
|
627
|
+
it "returns a list" do
|
628
|
+
@ten.uniq.should be_a_list
|
629
|
+
end
|
630
|
+
|
631
|
+
it "returns a list with duplicate values removed" do
|
632
|
+
RDF::List[1, 2, 2, 3].uniq.should == RDF::List[1, 2, 3]
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
describe RDF::List, "#to_a" do
|
637
|
+
it "requires no arguments" do
|
638
|
+
lambda { @nil.to_a }.should_not raise_error(ArgumentError)
|
639
|
+
end
|
640
|
+
|
641
|
+
it "returns an array" do
|
642
|
+
@nil.to_a.should be_an(Array)
|
643
|
+
end
|
644
|
+
|
645
|
+
it "returns an array of the correct size" do
|
646
|
+
@nil.to_a.size.should == @nil.length
|
647
|
+
@abc.to_a.size.should == @abc.length
|
648
|
+
@ten.to_a.size.should == @ten.length
|
649
|
+
end
|
650
|
+
end
|
651
|
+
|
652
|
+
describe RDF::List, "#to_set" do
|
653
|
+
it "requires no arguments" do
|
654
|
+
lambda { @nil.to_set }.should_not raise_error(ArgumentError)
|
655
|
+
end
|
656
|
+
|
657
|
+
it "returns a set" do
|
658
|
+
@nil.to_set.should be_a(Set)
|
659
|
+
end
|
660
|
+
|
661
|
+
it "returns a set of the correct size" do
|
662
|
+
@nil.to_set.size.should == @nil.length
|
663
|
+
@abc.to_set.size.should == @abc.length
|
664
|
+
@ten.to_set.size.should == @ten.length
|
665
|
+
end
|
666
|
+
|
667
|
+
it "returns a set without duplicates" do
|
668
|
+
RDF::List[1, 2, 2, 3].to_set.map(&:to_i).sort.should == [1, 2, 3]
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
describe RDF::List, "#to_s" do
|
673
|
+
it "requires no arguments" do
|
674
|
+
lambda { @nil.to_s }.should_not raise_error(ArgumentError)
|
675
|
+
end
|
676
|
+
|
677
|
+
it "returns a string" do
|
678
|
+
@nil.to_s.should be_a(String)
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
describe RDF::List, "#inspect" do
|
683
|
+
it "requires no arguments" do
|
684
|
+
lambda { @nil.inspect }.should_not raise_error(ArgumentError)
|
685
|
+
end
|
686
|
+
|
687
|
+
it "returns a string" do
|
688
|
+
@nil.inspect.should be_a(String)
|
689
|
+
end
|
690
|
+
end
|
691
|
+
end
|
692
|
+
|
693
|
+
share_as :RDF_List_NIL do
|
694
|
+
it "#subject returns rdf:nil" do
|
695
|
+
RDF::List::NIL.subject.should == RDF.nil
|
696
|
+
end
|
697
|
+
|
698
|
+
it "#frozen? returns true" do
|
699
|
+
RDF::List::NIL.frozen?.should be_true
|
700
|
+
end
|
701
|
+
|
702
|
+
it "#empty? returns true" do
|
703
|
+
RDF::List::NIL.empty?.should be_true
|
704
|
+
end
|
705
|
+
|
706
|
+
it "#[] returns an empty array" do
|
707
|
+
RDF::List::NIL.to_a.should == []
|
708
|
+
end
|
709
|
+
|
710
|
+
it "#inspect returns the constant name" do
|
711
|
+
RDF::List::NIL.inspect.should == 'RDF::List::NIL'
|
712
|
+
end
|
713
|
+
end
|
data/lib/rdf/spec/literal.rb
CHANGED
data/lib/rdf/spec/matchers.rb
CHANGED
@@ -113,6 +113,13 @@ module RDF; module Spec
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
+
define :be_a_list do
|
117
|
+
match do |value|
|
118
|
+
value.should be_an(RDF::List)
|
119
|
+
true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
116
123
|
define :be_a_vocabulary do |base_uri|
|
117
124
|
match do |vocabulary|
|
118
125
|
vocabulary.should be_a_kind_of(Module)
|
data/lib/rdf/spec/node.rb
CHANGED
@@ -2,12 +2,10 @@ require 'rdf'
|
|
2
2
|
require 'rdf/spec'
|
3
3
|
|
4
4
|
share_as :RDF_Node do
|
5
|
-
|
6
5
|
before :each do
|
7
6
|
raise '+@new+ must be defined in a before(:each) block' unless instance_variable_get('@new')
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
9
|
it "should be instantiable" do
|
12
10
|
lambda { @new.call }.should_not raise_error
|
13
11
|
end
|
data/lib/rdf/spec/value.rb
CHANGED
@@ -2,7 +2,6 @@ require 'rdf'
|
|
2
2
|
require 'rdf/spec'
|
3
3
|
|
4
4
|
share_as :RDF_Value do
|
5
|
-
|
6
5
|
before :each do
|
7
6
|
raise '+@value+ must be defined in a before(:each) block' unless instance_variable_get('@value')
|
8
7
|
raise '+@resource+ must be defined in a before(:each) block' unless instance_variable_get('@resource')
|
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
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
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-
|
18
|
+
date: 2010-08-26 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -56,8 +56,8 @@ dependencies:
|
|
56
56
|
segments:
|
57
57
|
- 0
|
58
58
|
- 2
|
59
|
-
-
|
60
|
-
version: 0.2.
|
59
|
+
- 3
|
60
|
+
version: 0.2.3
|
61
61
|
type: :development
|
62
62
|
version_requirements: *id003
|
63
63
|
- !ruby/object:Gem::Dependency
|
@@ -94,17 +94,23 @@ files:
|
|
94
94
|
- lib/rdf/spec/enumerable.rb
|
95
95
|
- lib/rdf/spec/format.rb
|
96
96
|
- lib/rdf/spec/graph.rb
|
97
|
+
- lib/rdf/spec/list.rb
|
97
98
|
- lib/rdf/spec/literal.rb
|
98
99
|
- lib/rdf/spec/matchers.rb
|
99
100
|
- lib/rdf/spec/mutable.rb
|
100
101
|
- lib/rdf/spec/node.rb
|
102
|
+
- lib/rdf/spec/query.rb
|
101
103
|
- lib/rdf/spec/queryable.rb
|
104
|
+
- lib/rdf/spec/readable.rb
|
102
105
|
- lib/rdf/spec/reader.rb
|
103
106
|
- lib/rdf/spec/repository.rb
|
107
|
+
- lib/rdf/spec/resource.rb
|
104
108
|
- lib/rdf/spec/statement.rb
|
105
109
|
- lib/rdf/spec/uri.rb
|
106
110
|
- lib/rdf/spec/value.rb
|
107
111
|
- lib/rdf/spec/version.rb
|
112
|
+
- lib/rdf/spec/vocab.rb
|
113
|
+
- lib/rdf/spec/writable.rb
|
108
114
|
- lib/rdf/spec/writer.rb
|
109
115
|
- lib/rdf/spec.rb
|
110
116
|
- spec/countable_spec.rb
|