mida 0.3.9 → 0.4.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +8 -3
- data/lib/mida/datatype/enumeration.rb +2 -4
- data/lib/mida/datatype/generic.rb +1 -3
- data/lib/mida/datatype/iso8601date.rb +1 -1
- data/lib/mida/document.rb +1 -1
- data/lib/mida/version.rb +1 -1
- data/mida.gemspec +2 -3
- data/spec/datatype/boolean_spec.rb +8 -8
- data/spec/datatype/enumeration_spec.rb +3 -3
- data/spec/datatype/float_spec.rb +3 -3
- data/spec/datatype/generic_spec.rb +9 -9
- data/spec/datatype/integer_spec.rb +4 -4
- data/spec/datatype/iso8601date_spec.rb +3 -3
- data/spec/datatype/number_spec.rb +3 -3
- data/spec/datatype/text_spec.rb +2 -2
- data/spec/datatype/url_spec.rb +4 -4
- data/spec/document_spec.rb +30 -23
- data/spec/item_spec.rb +80 -80
- data/spec/itemprop_spec.rb +13 -12
- data/spec/itemscope_spec.rb +21 -21
- data/spec/propertydesc_spec.rb +6 -6
- data/spec/vocabulary_spec.rb +35 -35
- metadata +7 -22
- data/Gemfile.lock +0 -38
data/spec/item_spec.rb
CHANGED
@@ -4,73 +4,73 @@ require 'mida/vocabulary'
|
|
4
4
|
|
5
5
|
describe Mida::Item, 'when initialized with an incomplete itemscope' do
|
6
6
|
before do
|
7
|
-
itemscope =
|
8
|
-
itemscope.
|
9
|
-
itemscope.
|
10
|
-
itemscope.
|
7
|
+
itemscope = double(Mida::Itemscope)
|
8
|
+
allow(itemscope).to receive(:type).and_return(nil)
|
9
|
+
allow(itemscope).to receive(:id).and_return(nil)
|
10
|
+
allow(itemscope).to receive(:properties).and_return({})
|
11
11
|
@item = Mida::Item.new(itemscope)
|
12
12
|
end
|
13
13
|
|
14
14
|
it '#type should return the same type as the itemscope' do
|
15
|
-
@item.type.
|
15
|
+
expect(@item.type).to eq(nil)
|
16
16
|
end
|
17
17
|
|
18
18
|
it '#vocabulary should return the correct vocabulary' do
|
19
|
-
@item.vocabulary.
|
19
|
+
expect(@item.vocabulary).to eq(Mida::GenericVocabulary)
|
20
20
|
end
|
21
21
|
|
22
22
|
it '#id should return the same id as the itemscope' do
|
23
|
-
@item.id.
|
23
|
+
expect(@item.id).to eq(nil)
|
24
24
|
end
|
25
25
|
|
26
26
|
it '#properties should return the same properties as the itemscope' do
|
27
|
-
@item.properties.
|
27
|
+
expect(@item.properties).to eq({})
|
28
28
|
end
|
29
29
|
|
30
30
|
it '#to_h should return an empty hash' do
|
31
|
-
@item.to_h.
|
31
|
+
expect(@item.to_h).to eq({})
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe Mida::Item, 'when initialized with a complete itemscope of an unknown type' do
|
36
36
|
before do
|
37
|
-
itemscope =
|
38
|
-
itemscope.
|
39
|
-
itemscope.
|
40
|
-
itemscope.
|
37
|
+
itemscope = double(Mida::Itemscope)
|
38
|
+
allow(itemscope).to receive(:type).and_return("book")
|
39
|
+
allow(itemscope).to receive(:id).and_return("urn:isbn:978-1-849510-50-9")
|
40
|
+
allow(itemscope).to receive(:properties).and_return(
|
41
41
|
{'first_name' => ['Lorry'], 'last_name' => ['Woodman']}
|
42
42
|
)
|
43
43
|
@item = Mida::Item.new(itemscope)
|
44
44
|
end
|
45
45
|
|
46
46
|
it '#type should return the same type as the itemscope' do
|
47
|
-
@item.type.
|
47
|
+
expect(@item.type).to eq("book")
|
48
48
|
end
|
49
49
|
|
50
50
|
it '#vocabulary should return the correct vocabulary' do
|
51
|
-
@item.vocabulary.
|
51
|
+
expect(@item.vocabulary).to eq(Mida::GenericVocabulary)
|
52
52
|
end
|
53
53
|
|
54
54
|
it '#id should return the same id as the itemscope' do
|
55
|
-
@item.id.
|
55
|
+
expect(@item.id).to eq("urn:isbn:978-1-849510-50-9")
|
56
56
|
end
|
57
57
|
|
58
58
|
it '#properties should return the same properties as the itemscope' do
|
59
|
-
@item.properties.
|
59
|
+
expect(@item.properties).to eq({
|
60
60
|
'first_name' => ['Lorry'],
|
61
61
|
'last_name' => ['Woodman']
|
62
|
-
}
|
62
|
+
})
|
63
63
|
end
|
64
64
|
|
65
65
|
it '#to_h should return the correct type, id and properties' do
|
66
|
-
@item.to_h.
|
66
|
+
expect(@item.to_h).to eq({
|
67
67
|
type: 'book',
|
68
68
|
id: "urn:isbn:978-1-849510-50-9",
|
69
69
|
properties: {
|
70
70
|
'first_name' => ['Lorry'],
|
71
71
|
'last_name' => ['Woodman']
|
72
72
|
}
|
73
|
-
}
|
73
|
+
})
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -87,10 +87,10 @@ describe Mida::Item, 'when initialized with an itemscope of a known type' do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
itemscope =
|
91
|
-
itemscope.
|
92
|
-
itemscope.
|
93
|
-
itemscope.
|
90
|
+
itemscope = double(Mida::Itemscope)
|
91
|
+
allow(itemscope).to receive(:type).and_return("http://example.com/vocab/person")
|
92
|
+
allow(itemscope).to receive(:id).and_return(nil)
|
93
|
+
allow(itemscope).to receive(:properties).and_return(
|
94
94
|
{ 'name' => ['Lorry Woodman'],
|
95
95
|
'date' => ['2nd October 2009', '2009-10-02'],
|
96
96
|
'url' => ['http://example.com/user/lorry']
|
@@ -100,36 +100,36 @@ describe Mida::Item, 'when initialized with an itemscope of a known type' do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it '#vocabulary should return the correct vocabulary' do
|
103
|
-
@item.vocabulary.
|
103
|
+
expect(@item.vocabulary).to eq(Person)
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should return has_one properties as a single value' do
|
107
|
-
@item.properties['name'].
|
107
|
+
expect(@item.properties['name']).to eq('Lorry Woodman')
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'should return has_many properties as an array' do
|
111
111
|
@item.properties['url'].length == 1
|
112
|
-
@item.properties['url'].first.to_s.
|
112
|
+
expect(@item.properties['url'].first.to_s).to eq('http://example.com/user/lorry')
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should accept datatypes that are valid' do
|
116
|
-
@item.properties['date'][0].
|
116
|
+
expect(@item.properties['date'][0]).to eq('2nd October 2009')
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'should accept datatypes that are valid' do
|
120
|
-
@item.properties['date'][1].
|
120
|
+
expect(@item.properties['date'][1].to_s).to eq Date.iso8601('2009-10-02').rfc822
|
121
121
|
end
|
122
122
|
|
123
123
|
it '#properties should return the same properties as the itemscope' do
|
124
|
-
@item.properties.keys.
|
124
|
+
expect(@item.properties.keys).to eq(['name', 'date', 'url'])
|
125
125
|
@item.properties['date'].length == 2
|
126
126
|
end
|
127
127
|
|
128
128
|
it '#to_h should return the correct type and properties' do
|
129
|
-
@item.to_h.
|
129
|
+
expect(@item.to_h).to eq({
|
130
130
|
type: 'http://example.com/vocab/person',
|
131
131
|
properties: @item.properties
|
132
|
-
}
|
132
|
+
})
|
133
133
|
end
|
134
134
|
|
135
135
|
end
|
@@ -149,10 +149,10 @@ describe Mida::Item, 'when initialized with an itemscope of a known type that do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
itemscope =
|
153
|
-
itemscope.
|
154
|
-
itemscope.
|
155
|
-
itemscope.
|
152
|
+
itemscope = double(Mida::Itemscope)
|
153
|
+
allow(itemscope).to receive(:type).and_return("http://example.com/vocab/person")
|
154
|
+
allow(itemscope).to receive(:id).and_return(nil)
|
155
|
+
allow(itemscope).to receive(:properties).and_return(
|
156
156
|
{ 'name' => ['Lorry Woodman'],
|
157
157
|
'tel' => ['000004847582', '111111857485'],
|
158
158
|
'url' => ['http://example.com/user/lorry'],
|
@@ -164,15 +164,15 @@ describe Mida::Item, 'when initialized with an itemscope of a known type that do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
it '#vocabulary should return the correct vocabulary' do
|
167
|
-
@item.vocabulary.
|
167
|
+
expect(@item.vocabulary).to eq(Person)
|
168
168
|
end
|
169
169
|
|
170
170
|
it 'should not keep properties that have too many values' do
|
171
|
-
@item.properties.
|
171
|
+
expect(@item.properties).not_to have_key('tel')
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'should not keep properties that have the wrong DataType' do
|
175
|
-
@item.properties.
|
175
|
+
expect(@item.properties).not_to have_key('dob')
|
176
176
|
end
|
177
177
|
|
178
178
|
end
|
@@ -192,19 +192,19 @@ describe Mida::Item, 'when initialized with an itemscope containing another corr
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
tel_itemscope =
|
196
|
-
tel_itemscope.
|
197
|
-
tel_itemscope.
|
198
|
-
tel_itemscope.
|
199
|
-
tel_itemscope.
|
195
|
+
tel_itemscope = double(Mida::Itemscope)
|
196
|
+
allow(tel_itemscope).to receive(:kind_of?).with(Mida::Itemscope).and_return(true)
|
197
|
+
allow(tel_itemscope).to receive(:type).and_return("http://example.com/vocab/tel")
|
198
|
+
allow(tel_itemscope).to receive(:id).and_return(nil)
|
199
|
+
allow(tel_itemscope).to receive(:properties).and_return(
|
200
200
|
{ 'dial_code' => ['0248583'],
|
201
201
|
'number' => ['000004847582'],
|
202
202
|
}
|
203
203
|
)
|
204
|
-
person_itemscope =
|
205
|
-
person_itemscope.
|
206
|
-
person_itemscope.
|
207
|
-
person_itemscope.
|
204
|
+
person_itemscope = double(Mida::Itemscope)
|
205
|
+
allow(person_itemscope).to receive(:type).and_return("http://example.com/vocab/person")
|
206
|
+
allow(person_itemscope).to receive(:id).and_return(nil)
|
207
|
+
allow(person_itemscope).to receive(:properties).and_return(
|
208
208
|
{ 'name' => ['Lorry Woodman'],
|
209
209
|
'tel' => ['000004847582', tel_itemscope],
|
210
210
|
}
|
@@ -213,23 +213,23 @@ describe Mida::Item, 'when initialized with an itemscope containing another corr
|
|
213
213
|
end
|
214
214
|
|
215
215
|
it '#vocabulary should return the correct vocabulary' do
|
216
|
-
@item.vocabulary.
|
216
|
+
expect(@item.vocabulary).to eq(Person)
|
217
217
|
end
|
218
218
|
|
219
219
|
it 'should validate and convert the nested itemscope' do
|
220
|
-
@item.properties['tel'][1].vocabulary.
|
221
|
-
@item.properties['tel'][1].properties.
|
220
|
+
expect(@item.properties['tel'][1].vocabulary).to eq(Tel)
|
221
|
+
expect(@item.properties['tel'][1].properties).to eq({
|
222
222
|
'dial_code' => '0248583',
|
223
223
|
'number' => '000004847582',
|
224
|
-
}
|
224
|
+
})
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'should accept the text tel' do
|
228
|
-
@item.properties['tel'][0].
|
228
|
+
expect(@item.properties['tel'][0]).to eq('000004847582')
|
229
229
|
end
|
230
230
|
|
231
231
|
it "#to_h shouldnt return nested items properly" do
|
232
|
-
@item.to_h.
|
232
|
+
expect(@item.to_h).to eq({
|
233
233
|
type: 'http://example.com/vocab/person',
|
234
234
|
properties: {
|
235
235
|
'name' => 'Lorry Woodman',
|
@@ -241,7 +241,7 @@ describe Mida::Item, 'when initialized with an itemscope containing another corr
|
|
241
241
|
}
|
242
242
|
]
|
243
243
|
}
|
244
|
-
}
|
244
|
+
})
|
245
245
|
end
|
246
246
|
|
247
247
|
end
|
@@ -268,22 +268,22 @@ describe Mida::Item, 'when initialized with an itemscope that has a property typ
|
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
271
|
-
student_itemscope =
|
272
|
-
student_itemscope.
|
273
|
-
student_itemscope.
|
274
|
-
student_itemscope.
|
275
|
-
student_itemscope.
|
271
|
+
student_itemscope = double(Mida::Itemscope)
|
272
|
+
allow(student_itemscope).to receive(:kind_of?).with(Mida::Itemscope).and_return(true)
|
273
|
+
allow(student_itemscope).to receive(:type).and_return("http://example.com/vocab/student")
|
274
|
+
allow(student_itemscope).to receive(:id).and_return(nil)
|
275
|
+
allow(student_itemscope).to receive(:properties).and_return(
|
276
276
|
{ 'name' => ['Lorry Woodman'],
|
277
277
|
'tel' => ['000004847582'],
|
278
278
|
'studying' => ['Classics']
|
279
279
|
}
|
280
280
|
)
|
281
281
|
|
282
|
-
org_itemscope =
|
283
|
-
org_itemscope.
|
284
|
-
org_itemscope.
|
285
|
-
org_itemscope.
|
286
|
-
org_itemscope.
|
282
|
+
org_itemscope = double(Mida::Itemscope)
|
283
|
+
allow(org_itemscope).to receive(:kind_of?).with(Mida::Itemscope).and_return(true)
|
284
|
+
allow(org_itemscope).to receive(:type).and_return("http://example.com/vocab/organization")
|
285
|
+
allow(org_itemscope).to receive(:id).and_return(nil)
|
286
|
+
allow(org_itemscope).to receive(:properties).and_return(
|
287
287
|
{ 'name' => ['Acme Inc.'],
|
288
288
|
'employee' => [student_itemscope]
|
289
289
|
}
|
@@ -292,13 +292,13 @@ describe Mida::Item, 'when initialized with an itemscope that has a property typ
|
|
292
292
|
end
|
293
293
|
|
294
294
|
it 'should recognise an itemtype that is the child of that specified' do
|
295
|
-
@item.properties['employee'][0].vocabulary.
|
296
|
-
@item.properties['employee'][0].type.
|
297
|
-
@item.properties['employee'][0].properties.
|
295
|
+
expect(@item.properties['employee'][0].vocabulary).to eq(Student)
|
296
|
+
expect(@item.properties['employee'][0].type).to eq('http://example.com/vocab/student')
|
297
|
+
expect(@item.properties['employee'][0].properties).to eq({
|
298
298
|
'name' => 'Lorry Woodman',
|
299
299
|
'tel' => ['000004847582'],
|
300
300
|
'studying' => 'Classics'
|
301
|
-
}
|
301
|
+
})
|
302
302
|
end
|
303
303
|
|
304
304
|
end
|
@@ -315,19 +315,19 @@ describe Mida::Item, 'when initialized with an itemscope containing another inva
|
|
315
315
|
has_many 'tel'
|
316
316
|
end
|
317
317
|
|
318
|
-
tel_itemscope =
|
319
|
-
tel_itemscope.
|
320
|
-
tel_itemscope.
|
321
|
-
tel_itemscope.
|
322
|
-
tel_itemscope.
|
318
|
+
tel_itemscope = double(Mida::Itemscope)
|
319
|
+
allow(tel_itemscope).to receive(:kind_of?).with(Mida::Itemscope).and_return(true)
|
320
|
+
allow(tel_itemscope).to receive(:type).and_return("http://example.com/vocab/tel")
|
321
|
+
allow(tel_itemscope).to receive(:id).and_return(nil)
|
322
|
+
allow(tel_itemscope).to receive(:properties).and_return(
|
323
323
|
{ 'dial_code' => ['0248583'],
|
324
324
|
'number' => ['000004847582'],
|
325
325
|
}
|
326
326
|
)
|
327
|
-
person_itemscope =
|
328
|
-
person_itemscope.
|
329
|
-
person_itemscope.
|
330
|
-
person_itemscope.
|
327
|
+
person_itemscope = double(Mida::Itemscope)
|
328
|
+
allow(person_itemscope).to receive(:type).and_return("http://example.com/vocab/person")
|
329
|
+
allow(person_itemscope).to receive(:id).and_return(nil)
|
330
|
+
allow(person_itemscope).to receive(:properties).and_return(
|
331
331
|
{ 'name' => ['Lorry Woodman'],
|
332
332
|
'tel' => ['000004847582', tel_itemscope],
|
333
333
|
}
|
@@ -336,8 +336,8 @@ describe Mida::Item, 'when initialized with an itemscope containing another inva
|
|
336
336
|
end
|
337
337
|
|
338
338
|
it 'should only accept values of the correct type' do
|
339
|
-
@item.properties['tel'].size.
|
340
|
-
@item.properties['tel'][0].
|
339
|
+
expect(@item.properties['tel'].size).to eq(1)
|
340
|
+
expect(@item.properties['tel'][0]).to eq('000004847582')
|
341
341
|
end
|
342
342
|
|
343
343
|
end
|
data/spec/itemprop_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Mida::Itemprop, 'when parsing an element without an itemprop attribute'
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it '#parse should return an empty Hash' do
|
12
|
-
Mida::Itemprop.parse(@element).
|
12
|
+
expect(Mida::Itemprop.parse(@element)).to eq({})
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -20,7 +20,7 @@ describe Mida::Itemprop, 'when parsing an element with one itemprop name' do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it '#parse should return a Hash with the correct name/value pair' do
|
23
|
-
Mida::Itemprop.parse(@element).
|
23
|
+
expect(Mida::Itemprop.parse(@element)).to eq({'reviewer' => 'Lorry Woodman'})
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -32,7 +32,7 @@ describe Mida::Itemprop, "when parsing an element who's inner text contains\
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it '#parse should return a Hash with the correct name/value pair' do
|
35
|
-
Mida::Itemprop.parse(@itemprop).
|
35
|
+
expect(Mida::Itemprop.parse(@itemprop)).to eq({'reviewer' => 'Lorry Woodman'})
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -51,7 +51,7 @@ describe Mida::Itemprop, 'when parsing an itemscope element that has a relative
|
|
51
51
|
|
52
52
|
it 'should create an absolute url' do
|
53
53
|
url = @properties['reviewer'].properties['url']
|
54
|
-
url.
|
54
|
+
expect(url).to eq(['http://example.com/home/LorryWoodman'])
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -63,11 +63,11 @@ describe Mida::Itemprop, 'when parsing an element with multiple itemprop names'
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'it should return a Hash with the each of the itemprop names as keys' do
|
66
|
-
@properties.
|
66
|
+
expect(@properties).to eq({
|
67
67
|
'reviewer' => 'some text',
|
68
68
|
'friend' => 'some text',
|
69
69
|
'person' => 'some text'
|
70
|
-
}
|
70
|
+
})
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -90,7 +90,7 @@ describe Mida::Itemprop, 'when parsing an element with non text content url valu
|
|
90
90
|
URL_ELEMENTS.each do |tag, attr|
|
91
91
|
html = html_wrap %Q{<#{tag} itemprop="url" #{attr}="#{url}">The url</#{tag}>}
|
92
92
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
93
|
-
Mida::Itemprop.parse(element).
|
93
|
+
expect(Mida::Itemprop.parse(element)).to eq({'url' => ''})
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -105,7 +105,7 @@ describe Mida::Itemprop, 'when parsing an element with non text content url valu
|
|
105
105
|
URL_ELEMENTS.each do |tag, attr|
|
106
106
|
html = html_wrap %Q{<#{tag} itemprop="url" #{attr}="#{url}">The url</#{tag}>}
|
107
107
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
108
|
-
Mida::Itemprop.parse(element).
|
108
|
+
expect(Mida::Itemprop.parse(element)).to eq({'url' => url})
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
@@ -121,8 +121,9 @@ describe Mida::Itemprop, 'when parsing an element with non text content url valu
|
|
121
121
|
URL_ELEMENTS.each do |tag, attr|
|
122
122
|
html = html_wrap %Q{<#{tag} itemprop="url" #{attr}="#{url}">The url</#{tag}>}
|
123
123
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
124
|
-
Mida::Itemprop.parse(element, @page_url).
|
124
|
+
expect(Mida::Itemprop.parse(element, @page_url)).to eq(
|
125
125
|
{'url' => 'http://example.com/test/register/index.html'}
|
126
|
+
)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -137,7 +138,7 @@ describe Mida::Itemprop, 'when parsing an element with non text content url valu
|
|
137
138
|
URL_ELEMENTS.each do |tag, attr|
|
138
139
|
html = html_wrap %Q{<#{tag} itemprop="url" #{attr}="#{url}">The url</#{tag}>}
|
139
140
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
140
|
-
Mida::Itemprop.parse(element, @page_url).
|
141
|
+
expect(Mida::Itemprop.parse(element, @page_url)).to eq({'url' => url})
|
141
142
|
end
|
142
143
|
end
|
143
144
|
end
|
@@ -149,12 +150,12 @@ describe Mida::Itemprop, 'when parsing an element with non text content non url
|
|
149
150
|
it 'should get values from a meta content attribute' do
|
150
151
|
html = html_wrap %q{<meta itemprop="reviewer" content="Lorry Woodman"/>}
|
151
152
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
152
|
-
Mida::Itemprop.parse(element).
|
153
|
+
expect(Mida::Itemprop.parse(element)).to eq({'reviewer' => 'Lorry Woodman'})
|
153
154
|
end
|
154
155
|
|
155
156
|
it 'should get time from an time datatime attribute' do
|
156
157
|
html = html_wrap %q{<time itemprop="dtreviewed" datetime="2011-05-04"/>}
|
157
158
|
element = Nokogiri(html).search('//*[@itemprop]').first
|
158
|
-
Mida::Itemprop.parse(element).
|
159
|
+
expect(Mida::Itemprop.parse(element)).to eq({'dtreviewed' => '2011-05-04'})
|
159
160
|
end
|
160
161
|
end
|
data/spec/itemscope_spec.rb
CHANGED
@@ -14,10 +14,10 @@ describe Mida::Itemscope, 'when initialized with an itemscope_node containing ju
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it '#properties should return the correct name/value pairs' do
|
17
|
-
@itemscope.properties.
|
17
|
+
expect(@itemscope.properties).to eq({
|
18
18
|
'first_name' => ['Lorry'],
|
19
19
|
'last_name' => ['Woodman']
|
20
|
-
}
|
20
|
+
})
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -35,7 +35,7 @@ describe Mida::Itemscope, 'when initialized with an itemscope_node not containin
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it '#type should return nil' do
|
38
|
-
@itemscope.type.
|
38
|
+
expect(@itemscope.type).to eq(nil)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -52,7 +52,7 @@ describe Mida::Itemscope, 'when initialized with an itemscope_node containing an
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it '#type should return nil' do
|
55
|
-
@itemscope.type.
|
55
|
+
expect(@itemscope.type).to eq("person")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -72,7 +72,7 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing an item
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should return the url as an absolute url' do
|
75
|
-
@itemscope.properties['url'].
|
75
|
+
expect(@itemscope.properties['url']).to eq([''])
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,7 +82,7 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing an item
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should return the url as an absolute url' do
|
85
|
-
@itemscope.properties['url'].
|
85
|
+
expect(@itemscope.properties['url']).to eq(['http://example.com/home/lorry'])
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -101,10 +101,10 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing itempro
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it '#properties should return the correct name/value pairs' do
|
104
|
-
@itemscope.properties.
|
104
|
+
expect(@itemscope.properties).to eq({
|
105
105
|
'first_name' => ['Lorry'],
|
106
106
|
'last_name' => ['Woodman']
|
107
|
-
}
|
107
|
+
})
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
@@ -122,9 +122,9 @@ describe Mida::Itemscope, "when initialized with an itemscope containing itempro
|
|
122
122
|
end
|
123
123
|
|
124
124
|
it '#properties should return the correct name/value pairs' do
|
125
|
-
@itemscope.properties.
|
125
|
+
expect(@itemscope.properties).to eq({
|
126
126
|
'reviewer' => ['Lorry Woodman']
|
127
|
-
}
|
127
|
+
})
|
128
128
|
end
|
129
129
|
|
130
130
|
end
|
@@ -142,10 +142,10 @@ describe Mida::Itemscope, "when initialized with an itemscope containing an item
|
|
142
142
|
end
|
143
143
|
|
144
144
|
it '#properties should return both properties' do
|
145
|
-
@itemscope.properties.
|
145
|
+
expect(@itemscope.properties).to eq({
|
146
146
|
'description' => ['The animal is a green parrot.'],
|
147
147
|
'colour' => ['green']
|
148
|
-
}
|
148
|
+
})
|
149
149
|
end
|
150
150
|
|
151
151
|
end
|
@@ -173,13 +173,13 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing itempro
|
|
173
173
|
end
|
174
174
|
|
175
175
|
it '#properties should return the correct name/value pairs' do
|
176
|
-
@itemscope.properties.
|
176
|
+
expect(@itemscope.properties).to eq({
|
177
177
|
'flavour' => [
|
178
178
|
'Lemon Sorbet',
|
179
179
|
'Apricot Sorbet',
|
180
180
|
@strawberry_itemscope
|
181
181
|
]
|
182
|
-
}
|
182
|
+
})
|
183
183
|
end
|
184
184
|
|
185
185
|
end
|
@@ -213,11 +213,11 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing itemref
|
|
213
213
|
end
|
214
214
|
|
215
215
|
it '#properties should return the correct name/value pairs' do
|
216
|
-
@itemscope.properties.
|
216
|
+
expect(@itemscope.properties).to eq({
|
217
217
|
'age' => ['30'],
|
218
218
|
'name' => ['Amanda'],
|
219
219
|
'band' => [@empty_band_itemscope]
|
220
|
-
}
|
220
|
+
})
|
221
221
|
end
|
222
222
|
|
223
223
|
end
|
@@ -237,7 +237,7 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing an item
|
|
237
237
|
end
|
238
238
|
|
239
239
|
it '#id should return the correct id' do
|
240
|
-
@itemscope.id.
|
240
|
+
expect(@itemscope.id).to eq('urn:isbn:978-1-849510-50-9')
|
241
241
|
end
|
242
242
|
|
243
243
|
end
|
@@ -269,19 +269,19 @@ describe Mida::Itemscope, 'when initialized with an itemscope containing itemsco
|
|
269
269
|
end
|
270
270
|
|
271
271
|
it '#type should return the correct type' do
|
272
|
-
@itemscope.type.
|
272
|
+
expect(@itemscope.type).to eq('review')
|
273
273
|
end
|
274
274
|
|
275
275
|
it '#id should return the correct id' do
|
276
|
-
@itemscope.id.
|
276
|
+
expect(@itemscope.id).to eq(nil)
|
277
277
|
end
|
278
278
|
|
279
279
|
it '#properties should return the correct name/value pairs' do
|
280
|
-
@itemscope.properties.
|
280
|
+
expect(@itemscope.properties).to eq({
|
281
281
|
'item_name' => ['Acme Anvil'],
|
282
282
|
'rating' => ['5'],
|
283
283
|
'reviewer' => [@reviewer_itemscope]
|
284
|
-
}
|
284
|
+
})
|
285
285
|
end
|
286
286
|
|
287
287
|
end
|