opensocial 0.0.4
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/LICENSE +202 -0
- data/NOTICE +60 -0
- data/README +108 -0
- data/lib/opensocial.rb +29 -0
- data/lib/opensocial/activity.rb +116 -0
- data/lib/opensocial/appdata.rb +117 -0
- data/lib/opensocial/auth/action_controller_request.rb +87 -0
- data/lib/opensocial/auth/base.rb +114 -0
- data/lib/opensocial/base.rb +54 -0
- data/lib/opensocial/connection.rb +146 -0
- data/lib/opensocial/group.rb +83 -0
- data/lib/opensocial/person.rb +198 -0
- data/lib/opensocial/request.rb +273 -0
- data/lib/opensocial/string/merb_string.rb +32 -0
- data/lib/opensocial/string/os_string.rb +23 -0
- data/tests/activity_test.rb +107 -0
- data/tests/appdata_test.rb +59 -0
- data/tests/connection_test.rb +54 -0
- data/tests/fixtures/activities.json +28 -0
- data/tests/fixtures/activity.json +13 -0
- data/tests/fixtures/appdata.json +6 -0
- data/tests/fixtures/appdatum.json +5 -0
- data/tests/fixtures/group.json +7 -0
- data/tests/fixtures/groups.json +16 -0
- data/tests/fixtures/people.json +20 -0
- data/tests/fixtures/person.json +9 -0
- data/tests/fixtures/person_appdata_rpc.json +1 -0
- data/tests/fixtures/person_rpc.json +1 -0
- data/tests/group_test.rb +72 -0
- data/tests/online_test.rb +56 -0
- data/tests/person_test.rb +109 -0
- data/tests/request_test.rb +51 -0
- data/tests/rpcrequest_test.rb +95 -0
- data/tests/test.rb +41 -0
- data/tests/test_helper.rb +39 -0
- metadata +129 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (c) 2008 Engine Yard
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
class String #:nodoc:
|
23
|
+
def snake_case
|
24
|
+
gsub(/\B[A-Z]/, '_\&').downcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def camel_case
|
28
|
+
words = split('_')
|
29
|
+
camel = words[1..-1].map{|e| e.capitalize}.join
|
30
|
+
words[0] + camel
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (c) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
class String #:nodoc:
|
16
|
+
# Removes backslash escaping.
|
17
|
+
def os_unescape
|
18
|
+
unescaped = self.gsub(/\\\"/, '"')
|
19
|
+
unescaped = unescaped.gsub('"{', "{")
|
20
|
+
unescaped = unescaped.gsub('}"', "}")
|
21
|
+
unescaped = unescaped.gsub(/\"\"/, "\"")
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright (c) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
16
|
+
|
17
|
+
class ActivityTest < Test::Unit::TestCase #:nodoc:
|
18
|
+
include TestHelper
|
19
|
+
|
20
|
+
def test_initialization
|
21
|
+
json = load_json('activity.json')
|
22
|
+
activity = OpenSocial::Activity.new(json['entry'])
|
23
|
+
|
24
|
+
assert_equal 'http://example.org/activities/example.org:87ead8dead6beef/self/af3778', activity.id
|
25
|
+
assert_equal String, activity.id.class
|
26
|
+
|
27
|
+
assert_equal Hash, activity.title.class
|
28
|
+
assert_equal 'html', activity.title['type']
|
29
|
+
assert_equal '<a href="foo">some activity</a>', activity.title['value']
|
30
|
+
|
31
|
+
assert_equal String, activity.updated.class
|
32
|
+
assert_equal '2008-02-20T23:35:37.266Z', activity.updated
|
33
|
+
|
34
|
+
assert_equal String, activity.body.class
|
35
|
+
assert_equal 'Some details for some activity', activity.body
|
36
|
+
|
37
|
+
assert_equal String, activity.body_id.class
|
38
|
+
assert_equal '383777272', activity.body_id
|
39
|
+
|
40
|
+
assert_equal String, activity.url.class
|
41
|
+
assert_equal 'http://api.example.org/activity/feeds/.../af3778', activity.url
|
42
|
+
|
43
|
+
assert_equal String, activity.user_id.class
|
44
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394', activity.user_id
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_fetch_groups_request
|
48
|
+
json = load_json('activities.json')
|
49
|
+
|
50
|
+
c = OpenSocial::Connection.new(NO_AUTH)
|
51
|
+
request = OpenSocial::FetchActivitiesRequest.new(c)
|
52
|
+
request.stubs(:send_request).returns(json)
|
53
|
+
activities = request.send
|
54
|
+
|
55
|
+
# Check properties of the collection
|
56
|
+
assert_equal OpenSocial::Collection, activities.class
|
57
|
+
assert_equal 2, activities.length
|
58
|
+
|
59
|
+
# Check properties of the first activity
|
60
|
+
first = activities['http://example.org/activities/example.org:87ead8dead6beef/self/af3778']
|
61
|
+
assert_equal 'http://example.org/activities/example.org:87ead8dead6beef/self/af3778', first.id
|
62
|
+
assert_equal String, first.id.class
|
63
|
+
|
64
|
+
assert_equal Hash, first.title.class
|
65
|
+
assert_equal 'html', first.title['type']
|
66
|
+
assert_equal '<a href="foo">some activity</a>', first.title['value']
|
67
|
+
|
68
|
+
assert_equal String, first.updated.class
|
69
|
+
assert_equal '2008-02-20T23:35:37.266Z', first.updated
|
70
|
+
|
71
|
+
assert_equal String, first.body.class
|
72
|
+
assert_equal 'Some details for some activity', first.body
|
73
|
+
|
74
|
+
assert_equal String, first.body_id.class
|
75
|
+
assert_equal '383777272', first.body_id
|
76
|
+
|
77
|
+
assert_equal String, first.url.class
|
78
|
+
assert_equal 'http://api.example.org/activity/feeds/.../af3778', first.url
|
79
|
+
|
80
|
+
assert_equal String, first.user_id.class
|
81
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394', first.user_id
|
82
|
+
|
83
|
+
# Check properties of the second activity
|
84
|
+
second = activities['http://example.org/activities/example.org:87ead8dead6beef/self/af3779']
|
85
|
+
assert_equal 'http://example.org/activities/example.org:87ead8dead6beef/self/af3779', second.id
|
86
|
+
assert_equal String, second.id.class
|
87
|
+
|
88
|
+
assert_equal Hash, second.title.class
|
89
|
+
assert_equal 'html', second.title['type']
|
90
|
+
assert_equal '<a href="foo">some activity</a>', second.title['value']
|
91
|
+
|
92
|
+
assert_equal String, second.updated.class
|
93
|
+
assert_equal '2008-02-20T23:35:38.266Z', second.updated
|
94
|
+
|
95
|
+
assert_equal String, second.body.class
|
96
|
+
assert_equal 'Some details for some second activity', second.body
|
97
|
+
|
98
|
+
assert_equal String, second.body_id.class
|
99
|
+
assert_equal '383777273', second.body_id
|
100
|
+
|
101
|
+
assert_equal String, second.url.class
|
102
|
+
assert_equal 'http://api.example.org/activity/feeds/.../af3779', second.url
|
103
|
+
|
104
|
+
assert_equal String, second.user_id.class
|
105
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394', second.user_id
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
16
|
+
|
17
|
+
class AppDataTest < Test::Unit::TestCase #:nodoc:
|
18
|
+
include TestHelper
|
19
|
+
|
20
|
+
def test_initialization
|
21
|
+
json = load_json('appdatum.json')
|
22
|
+
appdata = OpenSocial::AppData.new('test', json['entry']['example.org:34KJDCSKJN2HHF0DW20394'])
|
23
|
+
|
24
|
+
assert_equal Fixnum, appdata.pokes.class
|
25
|
+
assert_equal 3, appdata.pokes
|
26
|
+
|
27
|
+
assert_equal String, appdata.last_poke.class
|
28
|
+
assert_equal "2008-02-13T18:30:02Z", appdata.last_poke
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_fetch_appdata_request
|
32
|
+
json = load_json('appdata.json')
|
33
|
+
|
34
|
+
c = OpenSocial::Connection.new(NO_AUTH)
|
35
|
+
request = OpenSocial::FetchAppDataRequest.new(c)
|
36
|
+
request.stubs(:send_request).returns(json)
|
37
|
+
appdata = request.send
|
38
|
+
|
39
|
+
# Check properties of the collection
|
40
|
+
assert_equal OpenSocial::Collection, appdata.class
|
41
|
+
assert_equal 2, appdata.length
|
42
|
+
|
43
|
+
# Check properties of the first appdatum
|
44
|
+
first = appdata['example.org:34KJDCSKJN2HHF0DW20394']
|
45
|
+
assert_equal Fixnum, first.pokes.class
|
46
|
+
assert_equal 3, first.pokes
|
47
|
+
|
48
|
+
assert_equal String, first.last_poke.class
|
49
|
+
assert_equal "2008-02-13T18:30:02Z", first.last_poke
|
50
|
+
|
51
|
+
# Check properties of the second appdatum
|
52
|
+
second = appdata['example.org:58UIDCSIOP233FDKK3HD44']
|
53
|
+
assert_equal Fixnum, second.pokes.class
|
54
|
+
assert_equal 2, second.pokes
|
55
|
+
|
56
|
+
assert_equal String, second.last_poke.class
|
57
|
+
assert_equal "2007-12-16T18:30:02Z", second.last_poke
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
16
|
+
|
17
|
+
class ConnectionTest < Test::Unit::TestCase #:nodoc:
|
18
|
+
include TestHelper
|
19
|
+
|
20
|
+
# Tests that a connection properly throws an exception invalid parameters are
|
21
|
+
# supplied
|
22
|
+
def test_invalid_connection_parameters
|
23
|
+
non_blank = 'foo'
|
24
|
+
|
25
|
+
pass_invalid_hmac_parameters(non_blank, '', '')
|
26
|
+
pass_invalid_hmac_parameters('', non_blank, '')
|
27
|
+
pass_invalid_hmac_parameters('', '', non_blank)
|
28
|
+
|
29
|
+
assert_nothing_raised ArgumentError do
|
30
|
+
c = OpenSocial::Connection.new(:consumer_key => non_blank,
|
31
|
+
:consumer_secret => non_blank,
|
32
|
+
:xoauth_requestor_id => '')
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_raise ArgumentError do
|
36
|
+
c = OpenSocial::Connection.new(:auth => OpenSocial::Connection::AUTH_ST,
|
37
|
+
:st => '')
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_raise ArgumentError do
|
41
|
+
c = OpenSocial::Connection.new(:auth => 1234124)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def pass_invalid_hmac_parameters(key, secret, id)
|
48
|
+
assert_raise ArgumentError do
|
49
|
+
c = OpenSocial::Connection.new(:consumer_key => key,
|
50
|
+
:consumer_secret => secret,
|
51
|
+
:xoauth_requestor_id => id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"totalResults" : 2,
|
3
|
+
"startIndex" : 0,
|
4
|
+
"entry" : [
|
5
|
+
{
|
6
|
+
"id" : "http://example.org/activities/example.org:87ead8dead6beef/self/af3778",
|
7
|
+
"title" : { "type" : "html",
|
8
|
+
"value" : "<a href=\"foo\">some activity</a>"
|
9
|
+
},
|
10
|
+
"updated" : "2008-02-20T23:35:37.266Z",
|
11
|
+
"body" : "Some details for some activity",
|
12
|
+
"bodyId" : "383777272",
|
13
|
+
"url" : "http://api.example.org/activity/feeds/.../af3778",
|
14
|
+
"userId" : "example.org:34KJDCSKJN2HHF0DW20394"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"id" : "http://example.org/activities/example.org:87ead8dead6beef/self/af3779",
|
18
|
+
"title" : { "type" : "html",
|
19
|
+
"value" : "<a href=\"foo\">some activity</a>"
|
20
|
+
},
|
21
|
+
"updated" : "2008-02-20T23:35:38.266Z",
|
22
|
+
"body" : "Some details for some second activity",
|
23
|
+
"bodyId" : "383777273",
|
24
|
+
"url" : "http://api.example.org/activity/feeds/.../af3779",
|
25
|
+
"userId" : "example.org:34KJDCSKJN2HHF0DW20394"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"entry" : {
|
3
|
+
"id" : "http://example.org/activities/example.org:87ead8dead6beef/self/af3778",
|
4
|
+
"title" : { "type" : "html",
|
5
|
+
"value" : "<a href=\"foo\">some activity</a>"
|
6
|
+
},
|
7
|
+
"updated" : "2008-02-20T23:35:37.266Z",
|
8
|
+
"body" : "Some details for some activity",
|
9
|
+
"bodyId" : "383777272",
|
10
|
+
"url" : "http://api.example.org/activity/feeds/.../af3778",
|
11
|
+
"userId" : "example.org:34KJDCSKJN2HHF0DW20394"
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"totalResults" : 2,
|
3
|
+
"startIndex" : 0,
|
4
|
+
"entry" : [
|
5
|
+
{
|
6
|
+
"id" : "example.org:34KJDCSKJN2HHF0DW20394/friends",
|
7
|
+
"title" : "Peeps",
|
8
|
+
"link" : {"rel" : "alternate", "href" : "http://api.example.org/people/example.org:34KJDCSKJN2HHF0DW20394/@friends" }
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id" : "example.org:34KJDCSKJN2HHF0DW20394/family",
|
12
|
+
"title" : "Family",
|
13
|
+
"link" : {"rel" : "alternate", "href" : "http://api.example.org/people/example.org:34KJDCSKJN2HHF0DW20394/@family" }
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"totalResults" : 2,
|
3
|
+
"startIndex" : 0,
|
4
|
+
"entry" : [
|
5
|
+
{
|
6
|
+
"id" : "example.org:34KJDCSKJN2HHF0DW20394",
|
7
|
+
"name" : {"unstructured" : "Jane Doe"},
|
8
|
+
"gender" : {"displayvalue" : "女性", "key" : "FEMALE"},
|
9
|
+
"isOwner" : true,
|
10
|
+
"isViewer" : true
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"id" : "example.org:34KJDCSKJN2HHF0DW20395",
|
14
|
+
"name" : {"unstructured" : "Jane Doe2"},
|
15
|
+
"gender" : {"displayvalue" : "女性", "key" : "FEMALE"},
|
16
|
+
"isOwner" : false,
|
17
|
+
"isViewer" : false
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"id":"data","data":{"orkut.com:242412":{"token":"{\"hash\":{\"key\":\"value\",\"key2\":2},\"integer\":1241}"}}},{"id":"me","data":{"photos":[{"value":"http://www.orkut.com/img/i_nophoto64.gif","type":"thumbnail"}],"id":"orkut.com:242412","isViewer":true,"thumbnailUrl":"http://www.orkut.com/img/i_nophoto64.gif","name":{"familyName":"Testington","givenName":"Sample"},"isOwner":false}}]
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"id":"me","data":{"photos":[{"value":"http://www.orkut.com/img/i_nophoto64.gif","type":"thumbnail"}],"id":"orkut.com:242412","isViewer":true,"thumbnailUrl":"http://www.orkut.com/img/i_nophoto64.gif","name":{"familyName":"Testington","givenName":"Sample"},"isOwner":false}}]
|
data/tests/group_test.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Copyright (c) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
16
|
+
|
17
|
+
class GroupTest < Test::Unit::TestCase #:nodoc:
|
18
|
+
include TestHelper
|
19
|
+
|
20
|
+
# Tests construction of a group from a JSON entry
|
21
|
+
def test_initialization
|
22
|
+
json = load_json('group.json')
|
23
|
+
group = OpenSocial::Group.new(json['entry'])
|
24
|
+
|
25
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394/friends', group.id
|
26
|
+
assert_equal String, group.id.class
|
27
|
+
|
28
|
+
assert_equal 'Peeps', group.title
|
29
|
+
assert_equal String, group.title.class
|
30
|
+
|
31
|
+
assert_equal Hash, group.link.class
|
32
|
+
assert_equal 'alternate', group.link['rel']
|
33
|
+
assert_equal 'http://api.example.org/people/example.org:34KJDCSKJN2HHF0DW20394/@friends', group.link['href']
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_fetch_groups_request
|
37
|
+
json = load_json('groups.json')
|
38
|
+
|
39
|
+
c = OpenSocial::Connection.new(NO_AUTH)
|
40
|
+
request = OpenSocial::FetchGroupsRequest.new(c)
|
41
|
+
request.stubs(:send_request).returns(json)
|
42
|
+
groups = request.send
|
43
|
+
|
44
|
+
# Check properties of the collection
|
45
|
+
assert_equal OpenSocial::Collection, groups.class
|
46
|
+
assert_equal 2, groups.length
|
47
|
+
|
48
|
+
# Check properties of the first group
|
49
|
+
first = groups['example.org:34KJDCSKJN2HHF0DW20394/friends']
|
50
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394/friends', first.id
|
51
|
+
assert_equal String, first.id.class
|
52
|
+
|
53
|
+
assert_equal 'Peeps', first.title
|
54
|
+
assert_equal String, first.title.class
|
55
|
+
|
56
|
+
assert_equal Hash, first.link.class
|
57
|
+
assert_equal 'alternate', first.link['rel']
|
58
|
+
assert_equal 'http://api.example.org/people/example.org:34KJDCSKJN2HHF0DW20394/@friends', first.link['href']
|
59
|
+
|
60
|
+
# Check properties of the second group
|
61
|
+
second = groups['example.org:34KJDCSKJN2HHF0DW20394/family']
|
62
|
+
assert_equal 'example.org:34KJDCSKJN2HHF0DW20394/family', second.id
|
63
|
+
assert_equal String, second.id.class
|
64
|
+
|
65
|
+
assert_equal 'Family', second.title
|
66
|
+
assert_equal String, second.title.class
|
67
|
+
|
68
|
+
assert_equal Hash, second.link.class
|
69
|
+
assert_equal 'alternate', second.link['rel']
|
70
|
+
assert_equal 'http://api.example.org/people/example.org:34KJDCSKJN2HHF0DW20394/@family', second.link['href']
|
71
|
+
end
|
72
|
+
end
|