diff --git a/lib/twitter/client/tweets.rb b/lib/twitter/client/tweets.rb
index 48133f9e9..19c9ab94b 100644
--- a/lib/twitter/client/tweets.rb
+++ b/lib/twitter/client/tweets.rb
@@ -45,7 +45,7 @@ def update(status, options={})
response = post('statuses/update', options.merge(:status => status))
format.to_s.downcase == 'xml' ? response['status'] : response
end
-
+
# Updates with media the authenticating user's status
#
# @format :json, :xml
@@ -72,7 +72,7 @@ def update(status, options={})
# Twitter.update("I just posted a status update with a pic via the Twitter Ruby Gem!", {'io' => StringIO.new(pic), 'type' => 'jpg'})
def update_with_media(status, image, options={})
response = post('statuses/update_with_media', options.merge('media[]' => image, 'status' => status), format, media_endpoint)
- format.to_s.downcase == 'xml' ? response['user'] : response
+ format.to_s.downcase == 'xml' ? response['status'] : response
end
# Destroys the specified status
diff --git a/spec/fixtures/status_with_media.json b/spec/fixtures/status_with_media.json
new file mode 100644
index 000000000..1ae5c4db9
--- /dev/null
+++ b/spec/fixtures/status_with_media.json
@@ -0,0 +1,104 @@
+{
+ "in_reply_to_status_id": null,
+ "created_at": "Mon Aug 29 03:48:06 +0000 2011",
+ "geo": null,
+ "user": {
+ "profile_background_tile": true,
+ "protected": false,
+ "url": "http://www.beforeitwasround.com",
+ "listed_count": 21,
+ "name": "Steve Agalloco",
+ "profile_link_color": "009999",
+ "following": true,
+ "utc_offset": -18000,
+ "profile_sidebar_border_color": "eeeeee",
+ "description": "ruby, rails, node, nosql, husband, father, golfer. not necessarily in that order.",
+ "time_zone": "Eastern Time (US & Canada)",
+ "created_at": "Wed Aug 23 01:12:20 +0000 2006",
+ "friends_count": 380,
+ "profile_image_url": "http://a3.twimg.com/profile_images/1376908742/social_network_icon_normal.jpg",
+ "default_profile_image": false,
+ "show_all_inline_media": true,
+ "contributors_enabled": false,
+ "geo_enabled": true,
+ "profile_use_background_image": false,
+ "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/140563920/116775_0147_ful.jpg",
+ "profile_background_color": "131516",
+ "screen_name": "anno",
+ "is_translator": false,
+ "profile_background_image_url": "http://a3.twimg.com/profile_background_images/140563920/116775_0147_ful.jpg",
+ "profile_image_url_https": "https://si0.twimg.com/profile_images/1376908742/social_network_icon_normal.jpg",
+ "follow_request_sent": false,
+ "statuses_count": 2013,
+ "favourites_count": 383,
+ "id_str": "4618",
+ "lang": "en",
+ "verified": false,
+ "profile_text_color": "333333",
+ "location": "Charlotte, NC",
+ "id": 4618,
+ "default_profile": false,
+ "notifications": false,
+ "profile_sidebar_fill_color": "efefef",
+ "followers_count": 396
+ },
+ "in_reply_to_user_id": null,
+ "truncated": false,
+ "coordinates": null,
+ "favorited": false,
+ "possibly_sensitive": false,
+ "in_reply_to_status_id_str": null,
+ "in_reply_to_screen_name": null,
+ "source": "Tweetstreamie",
+ "in_reply_to_user_id_str": null,
+ "id_str": "108023089715089408",
+ "entities": {
+ "hashtags": [],
+ "media": [
+ {
+ "type": "photo",
+ "url": "http://t.co/CBYa7Ri",
+ "media_url": "http://p.twimg.com/AX_GbYJCEAAldJ7.jpg",
+ "display_url": "pic.twitter.com/CBYa7Ri",
+ "expanded_url": "http://twitter.com/anno/status/108023089715089408/photo/1",
+ "media_url_https": "https://p.twimg.com/AX_GbYJCEAAldJ7.jpg",
+ "indices": [
+ 24,
+ 43
+ ],
+ "sizes": {
+ "small": {
+ "h": 81,
+ "w": 94,
+ "resize": "fit"
+ },
+ "medium": {
+ "h": 81,
+ "w": 94,
+ "resize": "fit"
+ },
+ "large": {
+ "h": 81,
+ "w": 94,
+ "resize": "fit"
+ },
+ "thumb": {
+ "h": 81,
+ "w": 94,
+ "resize": "crop"
+ }
+ },
+ "id": 108023089719283710,
+ "id_str": "108023089719283712"
+ }
+ ],
+ "urls": [],
+ "user_mentions": []
+ },
+ "id": 108023089715089400,
+ "contributors": null,
+ "place": null,
+ "retweeted": false,
+ "retweet_count": 0,
+ "text": "You always have options http://t.co/CBYa7Ri"
+}
\ No newline at end of file
diff --git a/spec/fixtures/status_with_media.xml b/spec/fixtures/status_with_media.xml
new file mode 100644
index 000000000..746665252
--- /dev/null
+++ b/spec/fixtures/status_with_media.xml
@@ -0,0 +1,97 @@
+
+
+ Mon Aug 29 03:48:06 +0000 2011
+ 108023089715089408
+ You always have options http://t.co/CBYa7Ri
+
+ false
+ false
+
+
+
+ 0
+ false
+
+ 4618
+ Steve Agalloco
+ anno
+ Charlotte, NC
+ ruby, rails, node, nosql, husband, father, golfer. not necessarily in that order.
+ http://a3.twimg.com/profile_images/1376908742/social_network_icon_normal.jpg
+ https://si0.twimg.com/profile_images/1376908742/social_network_icon_normal.jpg
+ http://www.beforeitwasround.com
+ false
+ 396
+ 131516
+ 333333
+ 009999
+ efefef
+ eeeeee
+ 380
+ Wed Aug 23 01:12:20 +0000 2006
+ 383
+ -18000
+ Eastern Time (US & Canada)
+ http://a3.twimg.com/profile_background_images/140563920/116775_0147_ful.jpg
+ https://si0.twimg.com/profile_background_images/140563920/116775_0147_ful.jpg
+ true
+ false
+ false
+ true
+ false
+ true
+ 2013
+ en
+ false
+ false
+ 21
+ true
+ false
+ false
+ false
+
+
+
+
+ false
+
+
+
+
+
+ http://p.twimg.com/AX_GbYJCEAAldJ7.jpg
+ http://t.co/CBYa7Ri
+ photo
+ pic.twitter.com/CBYa7Ri
+ https://p.twimg.com/AX_GbYJCEAAldJ7.jpg
+ http://twitter.com/anno/status/108023089715089408/photo/1
+
+
+ 94
+ 81
+ fit
+
+
+ 94
+ 81
+ fit
+
+
+ 94
+ 81
+ fit
+
+
+ 94
+ 81
+ crop
+
+
+ 108023089719283712
+ 108023089719283712
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spec/helper.rb b/spec/helper.rb
index 32a15ce7f..cba36cf81 100644
--- a/spec/helper.rb
+++ b/spec/helper.rb
@@ -6,36 +6,36 @@
require 'rspec'
require 'webmock/rspec'
-def a_delete(path)
- a_request(:delete, Twitter.endpoint + path)
+def a_delete(path, endpoint=Twitter.endpoint)
+ a_request(:delete, endpoint + path)
end
-def a_get(path)
- a_request(:get, Twitter.endpoint + path)
+def a_get(path, endpoint=Twitter.endpoint)
+ a_request(:get, endpoint + path)
end
-def a_post(path)
- a_request(:post, Twitter.endpoint + path)
+def a_post(path, endpoint=Twitter.endpoint)
+ a_request(:post, endpoint + path)
end
-def a_put(path)
- a_request(:put, Twitter.endpoint + path)
+def a_put(path, endpoint=Twitter.endpoint)
+ a_request(:put, endpoint + path)
end
-def stub_delete(path)
- stub_request(:delete, Twitter.endpoint + path)
+def stub_delete(path, endpoint=Twitter.endpoint)
+ stub_request(:delete, endpoint + path)
end
-def stub_get(path)
- stub_request(:get, Twitter.endpoint + path)
+def stub_get(path, endpoint=Twitter.endpoint)
+ stub_request(:get, endpoint + path)
end
-def stub_post(path)
- stub_request(:post, Twitter.endpoint + path)
+def stub_post(path, endpoint=Twitter.endpoint)
+ stub_request(:post, endpoint + path)
end
-def stub_put(path)
- stub_request(:put, Twitter.endpoint + path)
+def stub_put(path, endpoint=Twitter.endpoint)
+ stub_request(:put, endpoint + path)
end
def fixture_path
diff --git a/spec/twitter/client/tweets_spec.rb b/spec/twitter/client/tweets_spec.rb
index dd0829ce5..a9f51fc45 100644
--- a/spec/twitter/client/tweets_spec.rb
+++ b/spec/twitter/client/tweets_spec.rb
@@ -49,6 +49,31 @@
end
+ describe ".update_with_media" do
+
+ before do
+ stub_post("statuses/update_with_media.#{format}", Twitter.media_endpoint).
+ to_return(:body => fixture("status_with_media.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
+ end
+
+ it "should get the correct resource" do
+ @client.update_with_media("You always have options", fixture("me.jpeg"))
+ a_post("statuses/update_with_media.#{format}", Twitter.media_endpoint).
+ should have_been_made
+ end
+
+ it "should return a single status" do
+ status = @client.update_with_media("You always have options", fixture("me.jpeg"))
+ status.text.should include("You always have options")
+ end
+
+ it 'should return the media as an entity' do
+ status = @client.update_with_media("You always have options", fixture("me.jpeg"))
+ status.entities.media.should be
+ end
+
+ end
+
describe ".status_destroy" do
before do