-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
status_spec.rb
137 lines (99 loc) · 3.13 KB
/
status_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
require 'helper'
describe Twitter::Status do
describe "#==" do
it "should return true when ids are equal" do
status = Twitter::Status.new(:id => 1)
other = Twitter::Status.new(:id => 1)
(status == other).should be_true
end
it "should return false when ids are not equal" do
status = Twitter::Status.new(:id => 1)
other = Twitter::Status.new(:id => 2)
(status == other).should be_false
end
end
describe "#created_at" do
it "should return a Time when set" do
status = Twitter::Status.new(:created_at => "Mon Jul 16 12:59:01 +0000 2007")
status.created_at.should be_a Time
end
it "should return nil when not set" do
status = Twitter::Status.new
status.created_at.should be_nil
end
end
describe "#geo" do
it "should return a Twitter::Point when set" do
status = Twitter::Status.new(:geo => {:type => "Point"})
status.geo.should be_a Twitter::Point
end
it "should return nil when not set" do
status = Twitter::Status.new
status.geo.should be_nil
end
end
describe "#hashtags" do
it "should return hashtags" do
hashtags = Twitter::Status.new(:text => "This tweet contains a #hashtag.").hashtags
hashtags.should be_an Array
hashtags.first.should == "hashtag"
end
it "should return nil when not set" do
hashtags = Twitter::Status.new.hashtags
hashtags.should be_nil
end
end
describe "#media" do
it "should return media" do
media = Twitter::Status.new(:entities => {'media' => [{'type' => 'photo'}]}).media
media.should be_an Array
media.first['type'].should == 'photo'
end
it "should return nil when not set" do
media = Twitter::Status.new.media
media.should be_nil
end
end
describe "#place" do
it "should return a Twitter::Place when set" do
status = Twitter::Status.new(:place => {})
status.place.should be_a Twitter::Place
end
it "should return nil when not set" do
status = Twitter::Status.new
status.place.should be_nil
end
end
describe "#url" do
it "should return urls" do
urls = Twitter::Status.new(:text => "This tweet contains a http://example.com.").urls
urls.should be_an Array
urls.first.should == "http://example.com"
end
it "should return nil when not set" do
urls = Twitter::Status.new.urls
urls.should be_nil
end
end
describe "#user" do
it "should return a User when user is set" do
user = Twitter::Status.new(:user => {}).user
user.should be_a Twitter::User
end
it "should return nil when user is not set" do
user = Twitter::Status.new.user
user.should be_nil
end
end
describe "#user_mentions" do
it "should return urls" do
user_mentions = Twitter::Status.new(:text => "This tweet contains a @mention.").user_mentions
user_mentions.should be_an Array
user_mentions.first.should == "mention"
end
it "should return nil when not set" do
user_mentions = Twitter::Status.new.user_mentions
user_mentions.should be_nil
end
end
end