Skip to content
Browse files

Allow multiple arguments (and return an array) for the following methods

* Twitter::Client#accept
* Twitter::Client#block
* Twitter::Client#deny
* Twitter::Client#direct_message
* Twitter::Client#direct_message_destroy
* Twitter::Client#disable_notifications
* Twitter::Client#enable_notifications
* Twitter::Client#favorite
* Twitter::Client#follow
* Twitter::Client#oembed
* Twitter::Client#report_spam
* Twitter::Client#retweet
* Twitter::Client#saved_search
* Twitter::Client#saved_search_destroy
* Twitter::Client#status
* Twitter::Client#status_activity
* Twitter::Client#status_destroy
* Twitter::Client#status_with_activity
* Twitter::Client#unblock
* Twitter::Client#unfavorite
* Twitter::Client#unfollow
  • Loading branch information...
1 parent 9c29181 commit 78adf3833ebfcafda48d31dee7befdcfa76f2971 @sferik committed
View
29 README.md
@@ -41,11 +41,34 @@ wiki][apps]!
The Active Support dependency has been removed!
-The `Twitter::Client#follow` and `Twitter::Client#unfollow` methods now accept
-multiple users as arguments and return an array instead of a `Twitter::User`.
+The following methods now accept multiple users or ids as arguments and return
+arrays:
+
+* `Twitter::Client#accept`
+* `Twitter::Client#block`
+* `Twitter::Client#deny`
+* `Twitter::Client#direct_message`
+* `Twitter::Client#direct_message_destroy`
+* `Twitter::Client#disable_notifications`
+* `Twitter::Client#enable_notifications`
+* `Twitter::Client#favorite`
+* `Twitter::Client#follow`
+* `Twitter::Client#oembed`
+* `Twitter::Client#report_spam`
+* `Twitter::Client#retweet`
+* `Twitter::Client#saved_search`
+* `Twitter::Client#saved_search_destroy`
+* `Twitter::Client#status`
+* `Twitter::Client#status_activity`
+* `Twitter::Client#status_destroy`
+* `Twitter::Client#status_with_activity`
+* `Twitter::Client#unblock`
+* `Twitter::Client#unfavorite`
+* `Twitter::Client#unfollow`
+
Additionally, the `Twitter::Client#follow` method now checks to make sure the
user isn't already being followed. If you don't wish to perform that check
-(which requires an extra HTTP request), you can use the new
+(which does require an extra HTTP request), you can use the new
`Twitter::Client#follow!` method instead. **Note**: This may re-send an email
notification to the user, even if they are already being followed.
View
910 lib/twitter/client.rb
497 additions, 413 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 lib/twitter/status.rb
@@ -82,7 +82,7 @@ def metadata
# @return [Twitter::OEmbed]
def oembed(options={})
@client ||= Twitter::Client.new
- @client.oembed(@attrs['id'], options) unless @attrs['id'].nil?
+ @client.oembed(@attrs['id'], options).first unless @attrs['id'].nil?
end
# @return [Twitter::Place]
View
14 spec/twitter/client/block_spec.rb
@@ -78,9 +78,10 @@
should have_been_made
end
it "should return the blocked user" do
- user = @client.block("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.block("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
@@ -97,9 +98,10 @@
should have_been_made
end
it "should return the un-blocked user" do
- user = @client.unblock("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.unblock("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
View
12 spec/twitter/client/direct_messages_spec.rb
@@ -53,9 +53,10 @@
should have_been_made
end
it "should return the deleted message" do
- direct_message = @client.direct_message_destroy(1825785544)
- direct_message.should be_a Twitter::DirectMessage
- direct_message.text.should == "Creating a fixture for the Twitter gem"
+ direct_messages = @client.direct_message_destroy(1825785544)
+ direct_messages.should be_an Array
+ direct_messages.first.should be_a Twitter::DirectMessage
+ direct_messages.first.sender.name.should == "Erik Michaels-Ober"
end
end
@@ -90,8 +91,9 @@
end
it "should return the 20 most recent direct messages sent to the authenticating user" do
direct_messages = @client.direct_message(1825786345)
- direct_messages.should be_a Twitter::DirectMessage
- direct_messages.sender.name.should == "Erik Michaels-Ober"
+ direct_messages.should be_an Array
+ direct_messages.first.should be_a Twitter::DirectMessage
+ direct_messages.first.sender.name.should == "Erik Michaels-Ober"
end
end
View
14 spec/twitter/client/favorites_spec.rb
@@ -54,9 +54,10 @@
should have_been_made
end
it "should return the favorite status when successful" do
- status = @client.favorite(25938088801)
- status.should be_a Twitter::Status
- status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
+ statuses = @client.favorite(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
end
end
@@ -71,9 +72,10 @@
should have_been_made
end
it "should return the un-favorite status when successful" do
- status = @client.unfavorite(25938088801)
- status.should be_a Twitter::Status
- status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
+ statuses = @client.unfavorite(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
end
end
View
14 spec/twitter/client/friends_and_followers_spec.rb
@@ -629,9 +629,10 @@
should have_been_made
end
it "should return the accepted user" do
- user = @client.accept("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.accept("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
@@ -648,9 +649,10 @@
should have_been_made
end
it "should return the denied user" do
- user = @client.deny("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.deny("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
View
14 spec/twitter/client/notification_spec.rb
@@ -19,9 +19,10 @@
should have_been_made
end
it "should return the specified user when successful" do
- user = @client.enable_notifications("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.enable_notifications("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
@@ -38,9 +39,10 @@
should have_been_made
end
it "should return the specified user when successful" do
- user = @client.disable_notifications("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.disable_notifications("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
View
14 spec/twitter/client/saved_searches_spec.rb
@@ -35,9 +35,10 @@
should have_been_made
end
it "should return the data for a saved search owned by the authenticating user specified by the given id" do
- saved_search = @client.saved_search(16129012)
- saved_search.should be_a Twitter::SavedSearch
- saved_search.name.should == "twitter"
+ saved_searches = @client.saved_search(16129012)
+ saved_searches.should be_an Array
+ saved_searches.first.should be_a Twitter::SavedSearch
+ saved_searches.first.name.should == "twitter"
end
end
@@ -71,9 +72,10 @@
should have_been_made
end
it "should return the deleted saved search" do
- saved_search = @client.saved_search_destroy(16129012)
- saved_search.should be_a Twitter::SavedSearch
- saved_search.name.should == "twitter"
+ saved_searches = @client.saved_search_destroy(16129012)
+ saved_searches.should be_an Array
+ saved_searches.first.should be_a Twitter::SavedSearch
+ saved_searches.first.name.should == "twitter"
end
end
View
7 spec/twitter/client/spam_reporting_spec.rb
@@ -19,9 +19,10 @@
should have_been_made
end
it "should return the specified user" do
- user = @client.report_spam("sferik")
- user.should be_a Twitter::User
- user.name.should == "Erik Michaels-Ober"
+ users = @client.report_spam("sferik")
+ users.should be_an Array
+ users.first.should be_a Twitter::User
+ users.first.name.should == "Erik Michaels-Ober"
end
end
View
2 spec/twitter/client/suggested_users_spec.rb
@@ -56,7 +56,7 @@
end
it "should return users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user" do
suggest_users = @client.suggest_users("art-design")
- suggest_users.should be_a Array
+ suggest_users.should be_an Array
suggest_users.first.should be_a Twitter::User
suggest_users.first.name.should == "OMGFacts"
end
View
51 spec/twitter/client/tweets_spec.rb
@@ -71,9 +71,10 @@
should have_been_made
end
it "should return a single status" do
- status = @client.status(25938088801)
- status.should be_a Twitter::Status
- status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
+ statuses = @client.status(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
end
end
@@ -88,9 +89,10 @@
should have_been_made
end
it "should return a single status" do
- status = @client.status_activity(25938088801)
- status.should be_a Twitter::Status
- status.retweeters_count.should == "1"
+ statuses = @client.status_activity(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.retweeters_count.should == "1"
end
end
@@ -109,10 +111,11 @@
should have_been_made
end
it "should return a single status" do
- status = @client.status_with_activity(25938088801)
- status.should be_a Twitter::Status
- status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
- status.retweeters_count.should == "1"
+ statuses = @client.status_with_activity(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
+ statuses.first.retweeters_count.should == "1"
end
end
@@ -127,9 +130,10 @@
should have_been_made
end
it "should return a single status" do
- status = @client.status_destroy(25938088801)
- status.should be_a Twitter::Status
- status.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
+ statuses = @client.status_destroy(25938088801)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"
end
end
@@ -144,11 +148,12 @@
should have_been_made
end
it "should return the original Tweet with retweet details embedded" do
- status = @client.retweet(28561922516)
- status.should be_a Twitter::Status
- status.text.should == "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
- status.retweeted_status.text.should == "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
- status.retweeted_status.id.should_not == status.id
+ statuses = @client.retweet(28561922516)
+ statuses.should be_an Array
+ statuses.first.should be_a Twitter::Status
+ statuses.first.text.should == "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
+ statuses.first.retweeted_status.text.should == "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush."
+ statuses.first.retweeted_status.id.should_not == statuses.first.id
end
end
@@ -203,8 +208,9 @@
should have_been_made
end
it "should return an OEmbed instance" do
- oembed = @client.oembed(25938088801)
- oembed.should be_a Twitter::OEmbed
+ oembeds = @client.oembed(25938088801)
+ oembeds.should be_an Array
+ oembeds.first.should be_a Twitter::OEmbed
end
end
context "with url passed" do
@@ -218,8 +224,9 @@
should have_been_made
end
it "should return an OEmbed instance" do
- oembed = @client.oembed('https://twitter.com/#!/twitter/status/25938088801')
- oembed.should be_a Twitter::OEmbed
+ oembeds = @client.oembed('https://twitter.com/#!/twitter/status/25938088801')
+ oembeds.should be_an Array
+ oembeds.first.should be_a Twitter::OEmbed
end
end

0 comments on commit 78adf38

Please sign in to comment.
Something went wrong with that request. Please try again.