twitter 4.0.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.
Files changed (210) hide show
  1. data/CHANGELOG.md +673 -0
  2. data/LICENSE.md +20 -0
  3. data/README.md +415 -0
  4. data/Rakefile +11 -0
  5. data/lib/twitter.rb +29 -0
  6. data/lib/twitter/action/favorite.rb +19 -0
  7. data/lib/twitter/action/follow.rb +31 -0
  8. data/lib/twitter/action/list_member_added.rb +41 -0
  9. data/lib/twitter/action/mention.rb +48 -0
  10. data/lib/twitter/action/reply.rb +27 -0
  11. data/lib/twitter/action/retweet.rb +27 -0
  12. data/lib/twitter/action/tweet.rb +22 -0
  13. data/lib/twitter/action_factory.rb +22 -0
  14. data/lib/twitter/api.rb +2442 -0
  15. data/lib/twitter/base.rb +119 -0
  16. data/lib/twitter/basic_user.rb +8 -0
  17. data/lib/twitter/client.rb +96 -0
  18. data/lib/twitter/configurable.rb +67 -0
  19. data/lib/twitter/configuration.rb +20 -0
  20. data/lib/twitter/core_ext/array.rb +7 -0
  21. data/lib/twitter/core_ext/enumerable.rb +11 -0
  22. data/lib/twitter/core_ext/hash.rb +100 -0
  23. data/lib/twitter/core_ext/kernel.rb +15 -0
  24. data/lib/twitter/core_ext/string.rb +10 -0
  25. data/lib/twitter/creatable.rb +20 -0
  26. data/lib/twitter/cursor.rb +87 -0
  27. data/lib/twitter/default.rb +101 -0
  28. data/lib/twitter/direct_message.rb +21 -0
  29. data/lib/twitter/entity.rb +7 -0
  30. data/lib/twitter/entity/hashtag.rb +9 -0
  31. data/lib/twitter/entity/url.rb +9 -0
  32. data/lib/twitter/entity/user_mention.rb +9 -0
  33. data/lib/twitter/error.rb +34 -0
  34. data/lib/twitter/error/bad_gateway.rb +11 -0
  35. data/lib/twitter/error/bad_request.rb +10 -0
  36. data/lib/twitter/error/client_error.rb +35 -0
  37. data/lib/twitter/error/decode_error.rb +9 -0
  38. data/lib/twitter/error/forbidden.rb +10 -0
  39. data/lib/twitter/error/gateway_timeout.rb +11 -0
  40. data/lib/twitter/error/identity_map_key_error.rb +9 -0
  41. data/lib/twitter/error/internal_server_error.rb +11 -0
  42. data/lib/twitter/error/not_acceptable.rb +10 -0
  43. data/lib/twitter/error/not_found.rb +10 -0
  44. data/lib/twitter/error/rate_limited.rb +11 -0
  45. data/lib/twitter/error/server_error.rb +28 -0
  46. data/lib/twitter/error/service_unavailable.rb +11 -0
  47. data/lib/twitter/error/unauthorized.rb +10 -0
  48. data/lib/twitter/factory.rb +21 -0
  49. data/lib/twitter/geo.rb +15 -0
  50. data/lib/twitter/geo/point.rb +22 -0
  51. data/lib/twitter/geo/polygon.rb +8 -0
  52. data/lib/twitter/geo_factory.rb +18 -0
  53. data/lib/twitter/identity.rb +50 -0
  54. data/lib/twitter/identity_map.rb +22 -0
  55. data/lib/twitter/language.rb +7 -0
  56. data/lib/twitter/list.rb +18 -0
  57. data/lib/twitter/media/photo.rb +22 -0
  58. data/lib/twitter/media_factory.rb +17 -0
  59. data/lib/twitter/metadata.rb +7 -0
  60. data/lib/twitter/oembed.rb +8 -0
  61. data/lib/twitter/place.rb +34 -0
  62. data/lib/twitter/rate_limit.rb +45 -0
  63. data/lib/twitter/relationship.rb +36 -0
  64. data/lib/twitter/request/multipart_with_file.rb +41 -0
  65. data/lib/twitter/response/parse_json.rb +25 -0
  66. data/lib/twitter/response/raise_error.rb +30 -0
  67. data/lib/twitter/saved_search.rb +9 -0
  68. data/lib/twitter/search_results.rb +48 -0
  69. data/lib/twitter/settings.rb +17 -0
  70. data/lib/twitter/size.rb +24 -0
  71. data/lib/twitter/source_user.rb +15 -0
  72. data/lib/twitter/suggestion.rb +22 -0
  73. data/lib/twitter/target_user.rb +8 -0
  74. data/lib/twitter/trend.rb +14 -0
  75. data/lib/twitter/tweet.rb +145 -0
  76. data/lib/twitter/user.rb +97 -0
  77. data/lib/twitter/version.rb +18 -0
  78. data/spec/fixtures/about_me.json +1 -0
  79. data/spec/fixtures/activity_summary.json +1 -0
  80. data/spec/fixtures/all.json +1 -0
  81. data/spec/fixtures/bad_gateway.json +1 -0
  82. data/spec/fixtures/bad_request.json +1 -0
  83. data/spec/fixtures/by_friends.json +1 -0
  84. data/spec/fixtures/category.json +1 -0
  85. data/spec/fixtures/configuration.json +1 -0
  86. data/spec/fixtures/contributees.json +1 -0
  87. data/spec/fixtures/contributors.json +1 -0
  88. data/spec/fixtures/direct_message.json +1 -0
  89. data/spec/fixtures/direct_messages.json +1 -0
  90. data/spec/fixtures/end_session.json +1 -0
  91. data/spec/fixtures/enhance_your_calm.text +11 -0
  92. data/spec/fixtures/favorites.json +1 -0
  93. data/spec/fixtures/following.json +1 -0
  94. data/spec/fixtures/forbidden.json +1 -0
  95. data/spec/fixtures/friendships.json +1 -0
  96. data/spec/fixtures/ids.json +1 -0
  97. data/spec/fixtures/ids_list.json +1 -0
  98. data/spec/fixtures/ids_list2.json +1 -0
  99. data/spec/fixtures/image_facets.json +1 -0
  100. data/spec/fixtures/internal_server_error.json +1 -0
  101. data/spec/fixtures/languages.json +1 -0
  102. data/spec/fixtures/list.json +1 -0
  103. data/spec/fixtures/lists.json +1 -0
  104. data/spec/fixtures/locations.json +1 -0
  105. data/spec/fixtures/matching_trends.json +1 -0
  106. data/spec/fixtures/me.jpeg +0 -0
  107. data/spec/fixtures/media_timeline.json +1 -0
  108. data/spec/fixtures/members.json +1 -0
  109. data/spec/fixtures/no_user_matches.json +1 -0
  110. data/spec/fixtures/not_acceptable.json +1 -0
  111. data/spec/fixtures/not_following.json +1 -0
  112. data/spec/fixtures/not_found.json +1 -0
  113. data/spec/fixtures/oembed.json +1 -0
  114. data/spec/fixtures/pbjt.gif +0 -0
  115. data/spec/fixtures/pengwynn.json +1 -0
  116. data/spec/fixtures/phoenix_search.phoenix +1 -0
  117. data/spec/fixtures/place.json +1 -0
  118. data/spec/fixtures/places.json +1 -0
  119. data/spec/fixtures/privacy.json +1 -0
  120. data/spec/fixtures/profile_image.text +24 -0
  121. data/spec/fixtures/rate_limit_status.json +1 -0
  122. data/spec/fixtures/recommendations.json +1 -0
  123. data/spec/fixtures/related_results.json +1 -0
  124. data/spec/fixtures/resolve.json +1 -0
  125. data/spec/fixtures/retweet.json +1 -0
  126. data/spec/fixtures/retweeted_status.json +1 -0
  127. data/spec/fixtures/retweeters_of.json +1 -0
  128. data/spec/fixtures/retweets.json +1 -0
  129. data/spec/fixtures/saved_search.json +1 -0
  130. data/spec/fixtures/saved_searches.json +1 -0
  131. data/spec/fixtures/search.json +1 -0
  132. data/spec/fixtures/search_malformed.json +1 -0
  133. data/spec/fixtures/service_unavailable.json +1 -0
  134. data/spec/fixtures/settings.json +1 -0
  135. data/spec/fixtures/sferik.json +1 -0
  136. data/spec/fixtures/status.json +1 -0
  137. data/spec/fixtures/status_with_media.json +104 -0
  138. data/spec/fixtures/statuses.json +1 -0
  139. data/spec/fixtures/suggestions.json +1 -0
  140. data/spec/fixtures/tos.json +1 -0
  141. data/spec/fixtures/totals.json +1 -0
  142. data/spec/fixtures/trends.json +1 -0
  143. data/spec/fixtures/trends_current.json +1 -0
  144. data/spec/fixtures/trends_daily.json +1 -0
  145. data/spec/fixtures/trends_weekly.json +1 -0
  146. data/spec/fixtures/unauthorized.json +1 -0
  147. data/spec/fixtures/user_search.json +1 -0
  148. data/spec/fixtures/user_timeline.json +1 -0
  149. data/spec/fixtures/users.json +1 -0
  150. data/spec/fixtures/users_list.json +1 -0
  151. data/spec/fixtures/video_facets.json +1 -0
  152. data/spec/fixtures/we_concept_bg2.png +0 -0
  153. data/spec/fixtures/wildcomet2.jpe +0 -0
  154. data/spec/helper.rb +53 -0
  155. data/spec/twitter/action/favorite_spec.rb +29 -0
  156. data/spec/twitter/action/follow_spec.rb +29 -0
  157. data/spec/twitter/action/list_member_added_spec.rb +41 -0
  158. data/spec/twitter/action/mention_spec.rb +52 -0
  159. data/spec/twitter/action/reply_spec.rb +41 -0
  160. data/spec/twitter/action/retweet_spec.rb +41 -0
  161. data/spec/twitter/action_factory_spec.rb +37 -0
  162. data/spec/twitter/action_spec.rb +16 -0
  163. data/spec/twitter/api/account_spec.rb +148 -0
  164. data/spec/twitter/api/activity_spec.rb +41 -0
  165. data/spec/twitter/api/blocks_spec.rb +167 -0
  166. data/spec/twitter/api/direct_messages_spec.rb +142 -0
  167. data/spec/twitter/api/friendships_spec.rb +567 -0
  168. data/spec/twitter/api/geo_spec.rb +100 -0
  169. data/spec/twitter/api/help_spec.rb +76 -0
  170. data/spec/twitter/api/lists_spec.rb +900 -0
  171. data/spec/twitter/api/report_spam_spec.rb +29 -0
  172. data/spec/twitter/api/saved_searches_spec.rb +100 -0
  173. data/spec/twitter/api/search_spec.rb +68 -0
  174. data/spec/twitter/api/statuses_spec.rb +559 -0
  175. data/spec/twitter/api/trends_spec.rb +80 -0
  176. data/spec/twitter/api/users_spec.rb +419 -0
  177. data/spec/twitter/base_spec.rb +113 -0
  178. data/spec/twitter/basic_user_spec.rb +23 -0
  179. data/spec/twitter/client_spec.rb +175 -0
  180. data/spec/twitter/configuration_spec.rb +17 -0
  181. data/spec/twitter/cursor_spec.rb +102 -0
  182. data/spec/twitter/direct_message_spec.rb +56 -0
  183. data/spec/twitter/error/client_error_spec.rb +40 -0
  184. data/spec/twitter/error/server_error_spec.rb +24 -0
  185. data/spec/twitter/error_spec.rb +20 -0
  186. data/spec/twitter/geo/point_spec.rb +41 -0
  187. data/spec/twitter/geo/polygon_spec.rb +29 -0
  188. data/spec/twitter/geo_factory_spec.rb +21 -0
  189. data/spec/twitter/geo_spec.rb +29 -0
  190. data/spec/twitter/identifiable_spec.rb +54 -0
  191. data/spec/twitter/list_spec.rb +45 -0
  192. data/spec/twitter/media/photo_spec.rb +35 -0
  193. data/spec/twitter/media_factory_spec.rb +17 -0
  194. data/spec/twitter/oembed_spec.rb +146 -0
  195. data/spec/twitter/place_spec.rb +75 -0
  196. data/spec/twitter/rate_limit_spec.rb +76 -0
  197. data/spec/twitter/relationship_spec.rb +35 -0
  198. data/spec/twitter/saved_search_spec.rb +34 -0
  199. data/spec/twitter/search_results_spec.rb +89 -0
  200. data/spec/twitter/settings_spec.rb +16 -0
  201. data/spec/twitter/size_spec.rb +38 -0
  202. data/spec/twitter/source_user_spec.rb +23 -0
  203. data/spec/twitter/suggestion_spec.rb +50 -0
  204. data/spec/twitter/target_user_spec.rb +23 -0
  205. data/spec/twitter/trend_spec.rb +38 -0
  206. data/spec/twitter/tweet_spec.rb +307 -0
  207. data/spec/twitter/user_spec.rb +127 -0
  208. data/spec/twitter_spec.rb +93 -0
  209. data/twitter.gemspec +30 -0
  210. metadata +584 -0
@@ -0,0 +1,29 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action::Follow do
4
+
5
+ describe "#sources" do
6
+ it "returns a collection of users who followed a user" do
7
+ sources = Twitter::Action::Follow.new(:sources => [{:id => 7505382}]).sources
8
+ sources.should be_an Array
9
+ sources.first.should be_a Twitter::User
10
+ end
11
+ it "is empty when not set" do
12
+ sources = Twitter::Action::Follow.new.sources
13
+ sources.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#targets" do
18
+ it "returns a collection containing the followed user" do
19
+ targets = Twitter::Action::Follow.new(:targets => [{:id => 7505382}]).targets
20
+ targets.should be_an Array
21
+ targets.first.should be_a Twitter::User
22
+ end
23
+ it "is empty when not set" do
24
+ targets = Twitter::Action::Follow.new.targets
25
+ targets.should be_empty
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action::ListMemberAdded do
4
+
5
+ describe "#sources" do
6
+ it "returns a collection of users who added a user to a list" do
7
+ sources = Twitter::Action::ListMemberAdded.new(:sources => [{:id => 7505382}]).sources
8
+ sources.should be_an Array
9
+ sources.first.should be_a Twitter::User
10
+ end
11
+ it "is empty when not set" do
12
+ sources = Twitter::Action::ListMemberAdded.new.sources
13
+ sources.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#target_objects" do
18
+ it "returns a collection of lists that were added to" do
19
+ targets = Twitter::Action::ListMemberAdded.new(:target_objects => [{:id => 8863586}]).target_objects
20
+ targets.should be_an Array
21
+ targets.first.should be_a Twitter::List
22
+ end
23
+ it "is empty when not set" do
24
+ targets = Twitter::Action::ListMemberAdded.new.target_objects
25
+ targets.should be_empty
26
+ end
27
+ end
28
+
29
+ describe "#targets" do
30
+ it "returns a collection of users who were added to a list" do
31
+ targets = Twitter::Action::ListMemberAdded.new(:targets => [{:id => 7505382}]).targets
32
+ targets.should be_an Array
33
+ targets.first.should be_a Twitter::User
34
+ end
35
+ it "is empty when not set" do
36
+ targets = Twitter::Action::ListMemberAdded.new.targets
37
+ targets.should be_empty
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,52 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action::Mention do
4
+
5
+ describe "#sources" do
6
+ it "returns a collection of users who mentioned a user" do
7
+ sources = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).sources
8
+ sources.should be_an Array
9
+ sources.first.should be_a Twitter::User
10
+ end
11
+ it "is empty when not set" do
12
+ sources = Twitter::Action::Mention.new.sources
13
+ sources.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#source" do
18
+ it "returns the user who mentioned a user" do
19
+ source = Twitter::Action::Mention.new(:sources => [{:id => 7505382}]).source
20
+ source.should be_a Twitter::User
21
+ end
22
+ it "returns nil when not set" do
23
+ source = Twitter::Action::Mention.new.source
24
+ source.should be_nil
25
+ end
26
+ end
27
+
28
+ describe "#target_objects" do
29
+ it "returns a collection of Tweets that mention a user" do
30
+ targets = Twitter::Action::Mention.new(:target_objects => [{:id => 25938088801}]).target_objects
31
+ targets.should be_an Array
32
+ targets.first.should be_a Twitter::Tweet
33
+ end
34
+ it "is empty when not set" do
35
+ targets = Twitter::Action::Mention.new.target_objects
36
+ targets.should be_empty
37
+ end
38
+ end
39
+
40
+ describe "#targets" do
41
+ it "returns a collection containing the mentioned user" do
42
+ targets = Twitter::Action::Mention.new(:targets => [{:id => 7505382}]).targets
43
+ targets.should be_an Array
44
+ targets.first.should be_a Twitter::User
45
+ end
46
+ it "is empty when not set" do
47
+ targets = Twitter::Action::Mention.new.targets
48
+ targets.should be_empty
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action::Reply do
4
+
5
+ describe "#sources" do
6
+ it "returns a collection of users who replied to a user" do
7
+ sources = Twitter::Action::Reply.new(:sources => [{:id => 7505382}]).sources
8
+ sources.should be_an Array
9
+ sources.first.should be_a Twitter::User
10
+ end
11
+ it "is empty when not set" do
12
+ sources = Twitter::Action::Reply.new.sources
13
+ sources.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#target_objects" do
18
+ it "returns a collection of Tweets that reply to a user" do
19
+ targets = Twitter::Action::Reply.new(:target_objects => [{:id => 25938088801}]).target_objects
20
+ targets.should be_an Array
21
+ targets.first.should be_a Twitter::Tweet
22
+ end
23
+ it "is empty when not set" do
24
+ targets = Twitter::Action::Reply.new.target_objects
25
+ targets.should be_empty
26
+ end
27
+ end
28
+
29
+ describe "#targets" do
30
+ it "returns a collection that contains the replied-to status" do
31
+ targets = Twitter::Action::Reply.new(:targets => [{:id => 25938088801}]).targets
32
+ targets.should be_an Array
33
+ targets.first.should be_a Twitter::Tweet
34
+ end
35
+ it "is empty when not set" do
36
+ targets = Twitter::Action::Reply.new.targets
37
+ targets.should be_empty
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action::Retweet do
4
+
5
+ describe "#sources" do
6
+ it "returns a collection of users who retweeted a user" do
7
+ sources = Twitter::Action::Retweet.new(:sources => [{:id => 7505382}]).sources
8
+ sources.should be_an Array
9
+ sources.first.should be_a Twitter::User
10
+ end
11
+ it "is empty when not set" do
12
+ sources = Twitter::Action::Retweet.new.sources
13
+ sources.should be_empty
14
+ end
15
+ end
16
+
17
+ describe "#target_objects" do
18
+ it "returns a collection of retweets" do
19
+ targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects
20
+ targets.should be_an Array
21
+ targets.first.should be_a Twitter::Tweet
22
+ end
23
+ it "is empty when not set" do
24
+ targets = Twitter::Action::Retweet.new.target_objects
25
+ targets.should be_empty
26
+ end
27
+ end
28
+
29
+ describe "#targets" do
30
+ it "returns a collection containing the retweeted user" do
31
+ targets = Twitter::Action::Retweet.new(:targets => [{:id => 7505382}]).targets
32
+ targets.should be_an Array
33
+ targets.first.should be_a Twitter::User
34
+ end
35
+ it "is empty when not set" do
36
+ targets = Twitter::Action::Retweet.new.targets
37
+ targets.should be_empty
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::ActionFactory do
4
+
5
+ describe ".new" do
6
+ it "generates a Favorite" do
7
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'favorite')
8
+ action.should be_a Twitter::Action::Favorite
9
+ end
10
+ it "generates a Follow" do
11
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'follow')
12
+ action.should be_a Twitter::Action::Follow
13
+ end
14
+ it "generates a ListMemberAdded" do
15
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'list_member_added')
16
+ action.should be_a Twitter::Action::ListMemberAdded
17
+ end
18
+ it "generates a Mention" do
19
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'mention')
20
+ action.should be_a Twitter::Action::Mention
21
+ end
22
+ it "generates a Reply" do
23
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'reply')
24
+ action.should be_a Twitter::Action::Reply
25
+ end
26
+ it "generates a Retweet" do
27
+ action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet')
28
+ action.should be_a Twitter::Action::Retweet
29
+ end
30
+ it "raises an ArgumentError when action is not specified" do
31
+ lambda do
32
+ Twitter::ActionFactory.fetch_or_new
33
+ end.should raise_error(ArgumentError, "argument must have :action key")
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,16 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::Action do
4
+
5
+ describe "#created_at" do
6
+ it "returns a Time when created_at is set" do
7
+ user = Twitter::User.new(:id => 7505382, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
8
+ user.created_at.should be_a Time
9
+ end
10
+ it "returns nil when created_at is not set" do
11
+ user = Twitter::User.new(:id => 7505382)
12
+ user.created_at.should be_nil
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,148 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::API do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe "#verify_credentials" do
10
+ before do
11
+ stub_get("/1.1/account/verify_credentials.json").
12
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "requests the correct resource" do
15
+ @client.verify_credentials
16
+ a_get("/1.1/account/verify_credentials.json").
17
+ should have_been_made
18
+ end
19
+ it "returns the requesting user" do
20
+ user = @client.verify_credentials
21
+ user.should be_a Twitter::User
22
+ user.id.should eq 7505382
23
+ end
24
+ end
25
+
26
+ describe "#update_delivery_device" do
27
+ before do
28
+ stub_post("/1.1/account/update_delivery_device.json").
29
+ with(:body => {:device => "sms"}).
30
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
31
+ end
32
+ it "requests the correct resource" do
33
+ @client.update_delivery_device("sms")
34
+ a_post("/1.1/account/update_delivery_device.json").
35
+ with(:body => {:device => "sms"}).
36
+ should have_been_made
37
+ end
38
+ it "returns a user" do
39
+ user = @client.update_delivery_device("sms")
40
+ user.should be_a Twitter::User
41
+ user.id.should eq 7505382
42
+ end
43
+ end
44
+
45
+ describe "#update_profile" do
46
+ before do
47
+ stub_post("/1.1/account/update_profile.json").
48
+ with(:body => {:url => "http://github.com/sferik/"}).
49
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
50
+ end
51
+ it "requests the correct resource" do
52
+ @client.update_profile(:url => "http://github.com/sferik/")
53
+ a_post("/1.1/account/update_profile.json").
54
+ with(:body => {:url => "http://github.com/sferik/"}).
55
+ should have_been_made
56
+ end
57
+ it "returns a user" do
58
+ user = @client.update_profile(:url => "http://github.com/sferik/")
59
+ user.should be_a Twitter::User
60
+ user.id.should eq 7505382
61
+ end
62
+ end
63
+
64
+ describe "#update_profile_background_image" do
65
+ before do
66
+ stub_post("/1.1/account/update_profile_background_image.json").
67
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
68
+ end
69
+ it "requests the correct resource" do
70
+ @client.update_profile_background_image(fixture("we_concept_bg2.png"))
71
+ a_post("/1.1/account/update_profile_background_image.json").
72
+ should have_been_made
73
+ end
74
+ it "returns a user" do
75
+ user = @client.update_profile_background_image(fixture("we_concept_bg2.png"))
76
+ user.should be_a Twitter::User
77
+ user.id.should eq 7505382
78
+ end
79
+ end
80
+
81
+ describe "#update_profile_colors" do
82
+ before do
83
+ stub_post("/1.1/account/update_profile_colors.json").
84
+ with(:body => {:profile_background_color => "000000"}).
85
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
86
+ end
87
+ it "requests the correct resource" do
88
+ @client.update_profile_colors(:profile_background_color => "000000")
89
+ a_post("/1.1/account/update_profile_colors.json").
90
+ with(:body => {:profile_background_color => "000000"}).
91
+ should have_been_made
92
+ end
93
+ it "returns a user" do
94
+ user = @client.update_profile_colors(:profile_background_color => "000000")
95
+ user.should be_a Twitter::User
96
+ user.id.should eq 7505382
97
+ end
98
+ end
99
+
100
+ describe "#update_profile_image" do
101
+ before do
102
+ stub_post("/1.1/account/update_profile_image.json").
103
+ to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
104
+ end
105
+ it "requests the correct resource" do
106
+ @client.update_profile_image(fixture("me.jpeg"))
107
+ a_post("/1.1/account/update_profile_image.json").
108
+ should have_been_made
109
+ end
110
+ it "returns a user" do
111
+ user = @client.update_profile_image(fixture("me.jpeg"))
112
+ user.should be_a Twitter::User
113
+ user.id.should eq 7505382
114
+ end
115
+ end
116
+
117
+ describe "#settings" do
118
+ before do
119
+ stub_get("/1.1/account/settings.json").
120
+ to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
121
+ stub_post("/1.1/account/settings.json").
122
+ with(:body => {:trend_location_woeid => "23424803"}).
123
+ to_return(:body => fixture("settings.json"), :headers => {:content_type => "application/json; charset=utf-8"})
124
+ end
125
+ it "requests the correct resource on GET" do
126
+ @client.settings
127
+ a_get("/1.1/account/settings.json").
128
+ should have_been_made
129
+ end
130
+ it "returns settings" do
131
+ settings = @client.settings
132
+ settings.should be_a Twitter::Settings
133
+ settings.language.should eq 'en'
134
+ end
135
+ it "requests the correct resource on POST" do
136
+ @client.settings(:trend_location_woeid => "23424803")
137
+ a_post("/1.1/account/settings.json").
138
+ with(:body => {:trend_location_woeid => "23424803"}).
139
+ should have_been_made
140
+ end
141
+ it "returns settings" do
142
+ settings = @client.settings(:trend_location_woeid => "23424803")
143
+ settings.should be_a Twitter::Settings
144
+ settings.language.should eq 'en'
145
+ end
146
+ end
147
+
148
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ describe Twitter::API do
4
+
5
+ before do
6
+ @client = Twitter::Client.new
7
+ end
8
+
9
+ describe "#activity_about_me" do
10
+ before do
11
+ stub_get("/i/activity/about_me.json").
12
+ to_return(:body => fixture("about_me.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+ it "requests the correct resource" do
15
+ @client.activity_about_me
16
+ a_get("/i/activity/about_me.json").
17
+ should have_been_made
18
+ end
19
+ it "returns activity about me" do
20
+ activity_about_me = @client.activity_about_me
21
+ activity_about_me.first.should be_a Twitter::Action::Mention
22
+ end
23
+ end
24
+
25
+ describe "#activity_by_friends" do
26
+ before do
27
+ stub_get("/i/activity/by_friends.json").
28
+ to_return(:body => fixture("by_friends.json"), :headers => {:content_type => "application/json; charset=utf-8"})
29
+ end
30
+ it "requests the correct resource" do
31
+ @client.activity_by_friends
32
+ a_get("/i/activity/by_friends.json").
33
+ should have_been_made
34
+ end
35
+ it "returns activity by friends" do
36
+ activity_by_friends = @client.activity_by_friends
37
+ activity_by_friends.first.should be_a Twitter::Action::Favorite
38
+ end
39
+ end
40
+
41
+ end