douban-ruby 0.0.5
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.tar.gz.sig +0 -0
- data/History.txt +40 -0
- data/Manifest.txt +34 -0
- data/README.txt +25 -0
- data/Rakefile +34 -0
- data/examples/example.rb +21 -0
- data/lib/douban.rb +57 -0
- data/lib/douban/author.rb +41 -0
- data/lib/douban/authorize.rb +1150 -0
- data/lib/douban/collection.rb +69 -0
- data/lib/douban/equal.rb +11 -0
- data/lib/douban/event.rb +80 -0
- data/lib/douban/mail.rb +56 -0
- data/lib/douban/miniblog.rb +59 -0
- data/lib/douban/note.rb +60 -0
- data/lib/douban/people.rb +48 -0
- data/lib/douban/recommendation.rb +47 -0
- data/lib/douban/recommendation_comment.rb +36 -0
- data/lib/douban/review.rb +66 -0
- data/lib/douban/subject.rb +87 -0
- data/lib/douban/tag.rb +39 -0
- data/spec/douban/author_spec.rb +32 -0
- data/spec/douban/authorize_spec.rb +508 -0
- data/spec/douban/collection_spec.rb +77 -0
- data/spec/douban/event_spec.rb +60 -0
- data/spec/douban/mail_spec.rb +98 -0
- data/spec/douban/miniblog_spec.rb +48 -0
- data/spec/douban/note_spec.rb +60 -0
- data/spec/douban/people_spec.rb +49 -0
- data/spec/douban/recommendation_comment_spec.rb +38 -0
- data/spec/douban/recommendation_spec.rb +48 -0
- data/spec/douban/review_spec.rb +76 -0
- data/spec/douban/tag_spec.rb +29 -0
- data/spec/douban_spec.rb +9 -0
- data/spec/spec_helper.rb +3 -0
- metadata +152 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/collection'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Collection do
|
7
|
+
before do
|
8
|
+
@s = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
10
|
+
<id>http://api.douban.com/collection/266618947</id>
|
11
|
+
<title>SJo1pHHJGmCx 看过 Cowboy Bebop</title>
|
12
|
+
<author>
|
13
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
14
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
15
|
+
<name>SJo1pHHJGmCx</name>
|
16
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
17
|
+
</author>
|
18
|
+
<updated>2010-07-02T21:48:29+08:00</updated>
|
19
|
+
<link href="http://api.douban.com/collection/266618947" rel="self"/>
|
20
|
+
<link href="http://api.douban.com/movie/subject/1424406" rel="http://www.douban.com/2007#subject"/>
|
21
|
+
<summary>a</summary>
|
22
|
+
<db:status>watched</db:status>
|
23
|
+
<db:subject>
|
24
|
+
<id>http://api.douban.com/movie/subject/1424406</id>
|
25
|
+
<title>Cowboy Bebop</title>
|
26
|
+
<category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#movie"/>
|
27
|
+
<author>
|
28
|
+
<name>渡边信一郎</name>
|
29
|
+
</author>
|
30
|
+
<link href="http://api.douban.com/movie/subject/1424406" rel="self"/>
|
31
|
+
<link href="http://movie.douban.com/subject/1424406/" rel="alternate"/>
|
32
|
+
<link href="http://t.douban.com/spic/s2975009.jpg" rel="image"/>
|
33
|
+
<link href="http://api.douban.com/collection/266618947" rel="collection"/>
|
34
|
+
<db:attribute name="website">http://www.cowboybebop.org/</db:attribute>
|
35
|
+
<db:attribute name="country">Japan</db:attribute>
|
36
|
+
<db:attribute name="pubdate">1998-04-03</db:attribute>
|
37
|
+
<db:attribute name="language">日语</db:attribute>
|
38
|
+
<db:attribute name="imdb">http://www.imdb.com/title/tt0213338/</db:attribute>
|
39
|
+
<db:attribute lang="zh_CN" name="aka">赏金猎人</db:attribute>
|
40
|
+
<db:attribute name="cast">山寺宏一</db:attribute>
|
41
|
+
<db:attribute name="cast">石冢运升</db:attribute>
|
42
|
+
<db:attribute name="cast">林原めぐみ</db:attribute>
|
43
|
+
<db:attribute name="cast">多田葵</db:attribute>
|
44
|
+
</db:subject>
|
45
|
+
<db:tag name="tag"/>
|
46
|
+
<gd:rating max="5" min="1" value="5"/>
|
47
|
+
</entry>}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should correct deserialize string" do
|
51
|
+
collection = Collection.new(@s)
|
52
|
+
collection.id.should == "http://api.douban.com/collection/266618947"
|
53
|
+
collection.collection_id.should == 266618947
|
54
|
+
collection.title.should == "SJo1pHHJGmCx 看过 Cowboy Bebop"
|
55
|
+
collection.author.class.should == Author
|
56
|
+
collection.updated.should == "2010-07-02T21:48:29+08:00"
|
57
|
+
collection.link.should == {"self" => "http://api.douban.com/collection/266618947",
|
58
|
+
"http://www.douban.com/2007#subject" => "http://api.douban.com/movie/subject/1424406"}
|
59
|
+
collection.tag.should == ["tag"]
|
60
|
+
collection.subject.kind_of?(Subject).should == true
|
61
|
+
collection.summary.should == "a"
|
62
|
+
collection.status.should == "watched"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should support ==" do
|
66
|
+
Collection.new(@s).should == Collection.new(@s)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should correct deserialize REXML::Document" do
|
70
|
+
Collection.new(REXML::Document.new(@s)).should == Collection.new(@s)
|
71
|
+
end
|
72
|
+
it "should correct deserialize REXML::Element" do
|
73
|
+
Collection.new(REXML::Document.new(@s).root).should == Collection.new(@s)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/event'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Event do
|
7
|
+
before do
|
8
|
+
@s = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
10
|
+
<id>http://api.douban.com/event/12171445</id>
|
11
|
+
<title>a</title>
|
12
|
+
<category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#event.party"/>
|
13
|
+
<author>
|
14
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
15
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
16
|
+
<name>SJo1pHHJGmCx</name>
|
17
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
18
|
+
</author>
|
19
|
+
<link href="http://api.douban.com/event/12171445" rel="self"/>
|
20
|
+
<link href="http://www.douban.com/event/12171445/" rel="alternate"/>
|
21
|
+
<summary>b</summary>
|
22
|
+
<content>b</content>
|
23
|
+
<db:attribute name="invite_only">no</db:attribute>
|
24
|
+
<db:attribute name="can_invite">yes</db:attribute>
|
25
|
+
<db:attribute name="participants">1</db:attribute>
|
26
|
+
<db:attribute name="wishers">0</db:attribute>
|
27
|
+
<db:attribute name="album">29707279</db:attribute>
|
28
|
+
<db:attribute name="status">participate</db:attribute>
|
29
|
+
<db:location id="beijing">北京</db:location>
|
30
|
+
<gd:when endTime="2010-07-07T22:39:38+08:00" startTime="2010-07-02T22:39:38+08:00"/>
|
31
|
+
<gd:where valueString="北京 大山子798艺术区 IT馆"/>
|
32
|
+
</entry>}
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should correct deserialize from string" do
|
36
|
+
event = Event.new(@s)
|
37
|
+
event.event_id.should == 12171445
|
38
|
+
event.id.should == "http://api.douban.com/event/12171445"
|
39
|
+
event.title.should == "a"
|
40
|
+
event.category.should == {"term"=>"http://www.douban.com/2007#event.party", "scheme"=>"http://www.douban.com/2007#kind"}
|
41
|
+
event.author.class.should == Author
|
42
|
+
event.link.should == {"self"=>"http://api.douban.com/event/12171445", "alternate"=>"http://www.douban.com/event/12171445/"}
|
43
|
+
event.summary.should == "b"
|
44
|
+
event.content.should == "b"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should support ==" do
|
48
|
+
Event.new(@s).should == Event.new(@s)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should correct deserialize from REXML::Document" do
|
52
|
+
Event.new(REXML::Document.new(@s)).should == Event.new(@s)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should correct deserialize from REXML::Element" do
|
56
|
+
Event.new(REXML::Document.new(@s).root).should == Event.new(@s)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/mail'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Mail do
|
7
|
+
before do
|
8
|
+
@mails_string = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
10
|
+
<title>SJo1pHHJGmCx的收件箱</title>
|
11
|
+
<author>
|
12
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
13
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
14
|
+
<name>SJo1pHHJGmCx</name>
|
15
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
16
|
+
</author>
|
17
|
+
<entry>
|
18
|
+
<id>http://api.douban.com/doumail/82937520</id>
|
19
|
+
<title>hello2</title>
|
20
|
+
<author>
|
21
|
+
<link href="http://api.douban.com/people/1018716" rel="self"/>
|
22
|
+
<link href="http://www.douban.com/people/lidaobing/" rel="alternate"/>
|
23
|
+
<name>LI Daobing</name>
|
24
|
+
<uri>http://api.douban.com/people/1018716</uri>
|
25
|
+
</author>
|
26
|
+
<published>2010-07-02T23:04:20+08:00</published>
|
27
|
+
<link href="http://api.douban.com/doumail/82937520" rel="self"/>
|
28
|
+
<link href="http://www.douban.com/doumail/82937520/" rel="alternate"/>
|
29
|
+
<db:attribute name="unread">true</db:attribute>
|
30
|
+
</entry>
|
31
|
+
<entry>
|
32
|
+
<id>http://api.douban.com/doumail/82937308</id>
|
33
|
+
<title>hello</title>
|
34
|
+
<author>
|
35
|
+
<link href="http://api.douban.com/people/1018716" rel="self"/>
|
36
|
+
<link href="http://www.douban.com/people/lidaobing/" rel="alternate"/>
|
37
|
+
<name>LI Daobing</name>
|
38
|
+
<uri>http://api.douban.com/people/1018716</uri>
|
39
|
+
</author>
|
40
|
+
<published>2010-07-02T23:02:57+08:00</published>
|
41
|
+
<link href="http://api.douban.com/doumail/82937308" rel="self"/>
|
42
|
+
<link href="http://www.douban.com/doumail/82937308/" rel="alternate"/>
|
43
|
+
<db:attribute name="unread">true</db:attribute>
|
44
|
+
</entry>
|
45
|
+
<openSearch:itemsPerPage>10</openSearch:itemsPerPage>
|
46
|
+
<openSearch:startIndex>1</openSearch:startIndex>
|
47
|
+
</feed>}
|
48
|
+
|
49
|
+
@single_mail = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
50
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
51
|
+
<id>http://api.douban.com/doumail/82937520</id>
|
52
|
+
<title>hello2</title>
|
53
|
+
<author>
|
54
|
+
<link href="http://api.douban.com/people/1018716" rel="self"/>
|
55
|
+
<link href="http://www.douban.com/people/lidaobing/" rel="alternate"/>
|
56
|
+
<name>LI Daobing</name>
|
57
|
+
<uri>http://api.douban.com/people/1018716</uri>
|
58
|
+
</author>
|
59
|
+
<published>2010-07-02T23:04:20+08:00</published>
|
60
|
+
<link href="http://api.douban.com/doumail/82937520" rel="self"/>
|
61
|
+
<link href="http://www.douban.com/doumail/82937520/" rel="alternate"/>
|
62
|
+
<content>world2</content>
|
63
|
+
<db:attribute name="unread">false</db:attribute>
|
64
|
+
<db:entity name="receiver">
|
65
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
66
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
67
|
+
<name>SJo1pHHJGmCx</name>
|
68
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
69
|
+
</db:entity>
|
70
|
+
</entry>}
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should correct deserialize from string" do
|
75
|
+
mail = Mail.new(@single_mail)
|
76
|
+
mail.id.should == 'http://api.douban.com/doumail/82937520'
|
77
|
+
mail.title.should == 'hello2'
|
78
|
+
mail.author.class.should == Author
|
79
|
+
mail.author.uri == "http://api.douban.com/people/1018716"
|
80
|
+
mail.published.should == '2010-07-02T23:04:20+08:00'
|
81
|
+
mail.link.should == {"self"=>"http://api.douban.com/doumail/82937520", "alternate"=>"http://www.douban.com/doumail/82937520/"}
|
82
|
+
mail.content.should == "world2"
|
83
|
+
mail.receiver.class.should == Author
|
84
|
+
mail.receiver.uri.should == "http://api.douban.com/people/41502874"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should correct deserialize from REXML::Element" do
|
88
|
+
feed = REXML::Document.new(@mails_string)
|
89
|
+
mails = []
|
90
|
+
REXML::XPath.each(feed, "//entry") do |entry|
|
91
|
+
mails << Mail.new(entry)
|
92
|
+
end
|
93
|
+
mails.size.should == 2
|
94
|
+
mails[0].id.should_not == mails[-1].id
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/miniblog'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Miniblog do
|
7
|
+
before do
|
8
|
+
@s = <<eos
|
9
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
10
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
11
|
+
<id>http://api.douban.com/miniblog/374100199</id>
|
12
|
+
<title><![CDATA[<b>单元测试0.921892231299059]]></title>
|
13
|
+
<category scheme="http://www.douban.com/2007#kind" term="http://www.douban.com/2007#miniblog.saying"/>
|
14
|
+
<author>
|
15
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
16
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
17
|
+
<name>SJo1pHHJGmCx</name>
|
18
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
19
|
+
</author>
|
20
|
+
<published>2010-06-30T19:27:41+08:00</published>
|
21
|
+
<content type="html">&lt;b&gt;单元测试0.921892231299059</content>
|
22
|
+
<db:attribute name="comments_count">0</db:attribute>
|
23
|
+
</entry>
|
24
|
+
eos
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should correct deserialize from string" do
|
28
|
+
miniblog = Douban::Miniblog.new(@s)
|
29
|
+
miniblog.id.should == "http://api.douban.com/miniblog/374100199"
|
30
|
+
miniblog.title.should == '<b>单元测试0.921892231299059'
|
31
|
+
miniblog.category.should == {"term"=>"http://www.douban.com/2007#miniblog.saying", "scheme"=>"http://www.douban.com/2007#kind"}
|
32
|
+
miniblog.published.should == "2010-06-30T19:27:41+08:00"
|
33
|
+
miniblog.link.should == nil
|
34
|
+
miniblog.content.should == "<b>单元测试0.921892231299059"
|
35
|
+
miniblog.attribute.should == {"comments_count" => "0"}
|
36
|
+
miniblog.author.nil?.should == false
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should support ==" do
|
40
|
+
Miniblog.new(@s).should == Miniblog.new(@s)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should correct deserialize from REXML::Document" do
|
44
|
+
Miniblog.new(REXML::Document.new(@s)).should == Miniblog.new(@s)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/note'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Note do
|
7
|
+
before do
|
8
|
+
@s = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
10
|
+
<id>http://api.douban.com/note/78970236</id>
|
11
|
+
<title>a</title>
|
12
|
+
<author>
|
13
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
14
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
15
|
+
<name>SJo1pHHJGmCx</name>
|
16
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
17
|
+
</author>
|
18
|
+
<published>2010-07-03T19:42:11+08:00</published>
|
19
|
+
<updated>2010-07-03T19:42:11+08:00</updated>
|
20
|
+
<link href="http://api.douban.com/note/78970236" rel="self"/>
|
21
|
+
<link href="http://www.douban.com/note/78970236/" rel="alternate"/>
|
22
|
+
<summary>b</summary>
|
23
|
+
<content>b</content>
|
24
|
+
<db:attribute name="privacy">public</db:attribute>
|
25
|
+
<db:attribute name="can_reply">yes</db:attribute>
|
26
|
+
<db:attribute name="comments_count">0</db:attribute>
|
27
|
+
<db:attribute name="recs_count">0</db:attribute>
|
28
|
+
</entry>}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should correct deserialize from string" do
|
32
|
+
note = Note.new(@s)
|
33
|
+
note.id.should == "http://api.douban.com/note/78970236"
|
34
|
+
note.note_id.should == 78970236
|
35
|
+
note.title.should == "a"
|
36
|
+
note.author.class.should == Author
|
37
|
+
note.published.should == "2010-07-03T19:42:11+08:00"
|
38
|
+
note.updated.should == "2010-07-03T19:42:11+08:00"
|
39
|
+
note.link.should == {"self"=>"http://api.douban.com/note/78970236",
|
40
|
+
"alternate"=>"http://www.douban.com/note/78970236/"}
|
41
|
+
note.summary.should == "b"
|
42
|
+
note.content.should == "b"
|
43
|
+
note.attribute.should == {"can_reply"=>"yes",
|
44
|
+
"comments_count"=>"0",
|
45
|
+
"privacy"=>"public",
|
46
|
+
"recs_count"=>"0"}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should support ==" do
|
50
|
+
Note.new(@s).should == Note.new(@s)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should correct deserialize from REXML::Element" do
|
54
|
+
Note.new(REXML::Document.new(@s)).should == Note.new(@s)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
2
|
+
|
3
|
+
require 'douban/people'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe People do
|
7
|
+
before do
|
8
|
+
@s = <<eos
|
9
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
10
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
11
|
+
<id>http://api.douban.com/people/41502874</id>
|
12
|
+
<title>SJo1pHHJGmCx</title>
|
13
|
+
<link href="http://api.douban.com/people/41502874" rel="self"/>
|
14
|
+
<link href="http://www.douban.com/people/41502874/" rel="alternate"/>
|
15
|
+
<link href="http://t.douban.com/icon/user.jpg" rel="icon"/>
|
16
|
+
<content></content>
|
17
|
+
<db:signature></db:signature>
|
18
|
+
<db:uid>41502874</db:uid>
|
19
|
+
<uri>http://api.douban.com/people/41502874</uri>
|
20
|
+
</entry>
|
21
|
+
eos
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should correct deserialize from string' do
|
25
|
+
people = Douban::People.new(@s)
|
26
|
+
people.id.should == "http://api.douban.com/people/41502874"
|
27
|
+
people.location.should == nil
|
28
|
+
people.title.should == 'SJo1pHHJGmCx'
|
29
|
+
people.link.should == {"self"=>"http://api.douban.com/people/41502874",
|
30
|
+
"alternate"=>"http://www.douban.com/people/41502874/",
|
31
|
+
"icon"=>"http://t.douban.com/icon/user.jpg"}
|
32
|
+
people.content.should == nil
|
33
|
+
people.uid.should == '41502874'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should support ==" do
|
37
|
+
People.new(@s).should == People.new(@s)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should support deserialize from REXML::Document" do
|
41
|
+
People.new(REXML::Document.new(@s)).should == People.new(@s)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should support deserialize from REXML::Element" do
|
45
|
+
People.new(REXML::Document.new(@s).root).should == People.new(@s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
require 'douban/recommendation_comment'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe RecommendationComment do
|
7
|
+
before do
|
8
|
+
@s = %Q{<entry>
|
9
|
+
<id>http://api.douban.com/recommendation/3673470/comment/178441</id>
|
10
|
+
<author>
|
11
|
+
<link href="http://api.douban.com/people/1177592" rel="self"/>
|
12
|
+
<link href="http://www.douban.com/people/Autorun/" rel="alternate"/>
|
13
|
+
<link href="http://t.douban.com/icon/u1177592-15.jpg" rel="icon"/>
|
14
|
+
<name>Autorun</name>
|
15
|
+
<uri>http://api.douban.com/people/1177592</uri>
|
16
|
+
</author>
|
17
|
+
<published>2008-11-07T10:19:54+08:00</published>
|
18
|
+
<content>对,这是刚捡回来的时候,呵呵,现在已经成大屁妹了</content>
|
19
|
+
</entry>}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should correct deserialize from string" do
|
23
|
+
comment = RecommendationComment.new(@s)
|
24
|
+
comment.id.should == "http://api.douban.com/recommendation/3673470/comment/178441"
|
25
|
+
comment.author.class.should == Douban::Author
|
26
|
+
comment.published.should == "2008-11-07T10:19:54+08:00"
|
27
|
+
comment.content.should == "对,这是刚捡回来的时候,呵呵,现在已经成大屁妹了"
|
28
|
+
|
29
|
+
comment.recommendation_id.should == 3673470
|
30
|
+
comment.comment_id.should == 178441
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should correct deserialize from REXML::Element" do
|
34
|
+
RecommendationComment.new(REXML::Document.new(@s)).should == RecommendationComment.new(@s)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
require 'douban/recommendation'
|
4
|
+
|
5
|
+
module Douban
|
6
|
+
describe Recommendation do
|
7
|
+
before do
|
8
|
+
@s = %Q{<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:db="http://www.douban.com/xmlns/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:opensearch="http://a9.com/-/spec/opensearchrss/1.0/">
|
10
|
+
<id>http://api.douban.com/recommendation/28732532</id>
|
11
|
+
<title>推荐小组话题:理证:试论阿赖耶识存在之必然性</title>
|
12
|
+
<author>
|
13
|
+
<link href="http://api.douban.com/people/1418737" rel="self"/>
|
14
|
+
<link href="http://www.douban.com/people/1418737/" rel="alternate"/>
|
15
|
+
<link href="http://t.douban.com/icon/u1418737-20.jpg" rel="icon"/>
|
16
|
+
<name>白微</name>
|
17
|
+
<uri>http://api.douban.com/people/1418737</uri>
|
18
|
+
</author>
|
19
|
+
<published>2010-07-01T19:41:33+08:00</published>
|
20
|
+
<content type="html"><![CDATA[推荐小组<a href="http://www.douban.com/group/165983/">唯識與中觀</a>的话题<a href="http://www.douban.com/group/topic/9754580/">理证:试论阿赖耶识存在之必然性</a>]]></content>
|
21
|
+
<db:attribute name="category">topic</db:attribute>
|
22
|
+
<db:attribute name="comment"></db:attribute>
|
23
|
+
<db:attribute name="comments_count">0</db:attribute>
|
24
|
+
</entry>
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should correct deserialize from string" do
|
29
|
+
recommendation = Recommendation.new(@s)
|
30
|
+
recommendation.id.should == "http://api.douban.com/recommendation/28732532"
|
31
|
+
recommendation.recommendation_id.should == 28732532
|
32
|
+
recommendation.title.should == "推荐小组话题:理证:试论阿赖耶识存在之必然性"
|
33
|
+
recommendation.author.class.should == Douban::Author
|
34
|
+
recommendation.published.should == "2010-07-01T19:41:33+08:00"
|
35
|
+
recommendation.content.should == '推荐小组<a href="http://www.douban.com/group/165983/">唯識與中觀</a>的话题<a href="http://www.douban.com/group/topic/9754580/">理证:试论阿赖耶识存在之必然性</a>'
|
36
|
+
recommendation.content_type.class.should == String
|
37
|
+
recommendation.content_type.should == "html"
|
38
|
+
recommendation.category.should == "topic"
|
39
|
+
recommendation.comment.should == ""
|
40
|
+
recommendation.comments_count.should == 0
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should correct deserialize from REXML::Element" do
|
44
|
+
Recommendation.new(REXML::Document.new(@s)).should == Recommendation.new(@s)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|