From cf825ea46c86dc50b831365426f96825c5a03701 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sun, 16 Jan 2011 14:16:52 -0800 Subject: [PATCH] Add failing test case for #136 --- spec/fixtures/pengwynn.json | 1 + spec/fixtures/pengwynn.xml | 53 ++++++++++++++++++++ spec/fixtures/sferik.json | 1 + spec/fixtures/{user.xml => sferik.xml} | 39 +++++++------- spec/fixtures/user.json | 1 - spec/twitter/client/account_spec.rb | 12 ++--- spec/twitter/client/block_spec.rb | 6 +-- spec/twitter/client/friendship_spec.rb | 8 +-- spec/twitter/client/list_subscribers_spec.rb | 4 +- spec/twitter/client/notification_spec.rb | 4 +- spec/twitter/client/spam_reporting_spec.rb | 2 +- spec/twitter/client/user_spec.rb | 10 ++-- spec/twitter/client_spec.rb | 11 ++++ 13 files changed, 109 insertions(+), 43 deletions(-) create mode 100644 spec/fixtures/pengwynn.json create mode 100644 spec/fixtures/pengwynn.xml create mode 100644 spec/fixtures/sferik.json rename spec/fixtures/{user.xml => sferik.xml} (61%) delete mode 100644 spec/fixtures/user.json diff --git a/spec/fixtures/pengwynn.json b/spec/fixtures/pengwynn.json new file mode 100644 index 000000000..91087a184 --- /dev/null +++ b/spec/fixtures/pengwynn.json @@ -0,0 +1 @@ +{"profile_background_color":"efefef","listed_count":201,"lang":"en","verified":false,"profile_background_image_url":"http:\/\/a1.twimg.com\/profile_background_images\/61741268\/twitter-small.png","created_at":"Sat Mar 08 16:34:22 +0000 2008","description":"Christian husband and father. Dev Experience @ HP Cloud Services. Co-host of the @changelogshow. Mashup of design & development.","screen_name":"pengwynn","status":{"in_reply_to_user_id_str":null,"text":"Flatstache is to Mustache what Zepto is to jQuery, from @natevw http:\/\/t.co\/gOjxJ1E","coordinates":null,"retweeted":false,"retweet_count":0,"created_at":"Sun Jan 16 21:01:10 +0000 2011","in_reply_to_user_id":null,"place":null,"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"id_str":"26745802235842561","geo":null,"id":26745802235842561,"contributors":null,"in_reply_to_screen_name":null},"url":"http:\/\/wynnnetherland.com","is_translator":false,"show_all_inline_media":false,"geo_enabled":true,"profile_text_color":"666666","followers_count":2902,"contributors_enabled":false,"following":true,"favourites_count":67,"profile_sidebar_fill_color":"dddddd","location":"Dallas, TX","profile_background_tile":false,"time_zone":"Central Time (US & Canada)","profile_link_color":"35abe9","protected":false,"follow_request_sent":false,"statuses_count":4160,"profile_sidebar_border_color":"cccccc","name":"Wynn Netherland","id_str":"14100886","friends_count":1710,"id":14100886,"notifications":false,"profile_use_background_image":true,"utc_offset":-21600,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1180321093\/komikazee_normal.png"} \ No newline at end of file diff --git a/spec/fixtures/pengwynn.xml b/spec/fixtures/pengwynn.xml new file mode 100644 index 000000000..2675e0e34 --- /dev/null +++ b/spec/fixtures/pengwynn.xml @@ -0,0 +1,53 @@ + + + 14100886 + Wynn Netherland + pengwynn + Dallas, TX + Christian husband and father. Dev Experience @ HP Cloud Services. Co-host of the @changelogshow. Mashup of design & development. + http://a0.twimg.com/profile_images/1180321093/komikazee_normal.png + http://wynnnetherland.com + false + 2902 + efefef + 666666 + 35abe9 + dddddd + cccccc + 1710 + Sat Mar 08 16:34:22 +0000 2008 + 67 + -21600 + Central Time (US & Canada) + http://a1.twimg.com/profile_background_images/61741268/twitter-small.png + false + true + false + true + false + true + 4160 + en + false + false + 201 + false + false + + Sun Jan 16 21:01:10 +0000 2011 + 26745802235842561 + Flatstache is to Mustache what Zepto is to jQuery, from @natevw http://t.co/gOjxJ1E + <a href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow">Twitter for Mac</a> + false + false + + + + 1 + false + + + + + + diff --git a/spec/fixtures/sferik.json b/spec/fixtures/sferik.json new file mode 100644 index 000000000..dd670bf21 --- /dev/null +++ b/spec/fixtures/sferik.json @@ -0,0 +1 @@ +{"show_all_inline_media":true,"lang":"en","geo_enabled":true,"profile_background_image_url":"http:\/\/a2.twimg.com\/profile_background_images\/162641967\/we_concept_bg2.png","created_at":"Mon Jul 16 12:59:01 +0000 2007","description":"A mind forever voyaging through strange seas of thought, alone.","screen_name":"sferik","url":"https:\/\/github.com\/sferik","status":{"retweeted_status":{"coordinates":null,"retweeted":false,"retweet_count":8,"created_at":"Sun Jan 16 20:57:21 +0000 2011","in_reply_to_user_id":null,"place":null,"source":"\u003Ca href=\"http:\/\/www.echofon.com\/\" rel=\"nofollow\"\u003EEchofon\u003C\/a\u003E","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"id_str":"26744838716133376","geo":null,"contributors":null,"in_reply_to_screen_name":null,"id":26744838716133376,"in_reply_to_user_id_str":null,"text":"[ANN] sqlite3-ruby => sqlite3"},"coordinates":null,"retweeted":false,"retweet_count":8,"created_at":"Sun Jan 16 21:38:25 +0000 2011","in_reply_to_user_id":null,"place":null,"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E","in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_status_id_str":null,"id_str":"26755176471724032","geo":null,"contributors":null,"in_reply_to_screen_name":null,"id":26755176471724032,"in_reply_to_user_id_str":null,"text":"RT @tenderlove: [ANN] sqlite3-ruby => sqlite3"},"profile_text_color":"333333","followers_count":1048,"listed_count":41,"following":false,"favourites_count":1040,"profile_sidebar_fill_color":"DDEEF6","location":"San Francisco","profile_background_tile":false,"time_zone":"Pacific Time (US & Canada)","contributors_enabled":false,"statuses_count":3479,"profile_link_color":"0084B4","is_translator":false,"profile_sidebar_border_color":"C0DEED","protected":false,"id_str":"7505382","name":"Erik Michaels-Ober","verified":false,"notifications":false,"profile_use_background_image":true,"friends_count":197,"profile_image_url":"http:\/\/a1.twimg.com\/profile_images\/1186912733\/Github_Square_normal.jpg","id":7505382,"follow_request_sent":false,"utc_offset":-28800,"profile_background_color":"000000"} \ No newline at end of file diff --git a/spec/fixtures/user.xml b/spec/fixtures/sferik.xml similarity index 61% rename from spec/fixtures/user.xml rename to spec/fixtures/sferik.xml index a0a37a224..624d82bba 100644 --- a/spec/fixtures/user.xml +++ b/spec/fixtures/sferik.xml @@ -4,57 +4,58 @@ Erik Michaels-Ober sferik San Francisco - Adventures in hunger and foolishness. - http://a0.twimg.com/profile_images/323331048/me_normal.jpg - + A mind forever voyaging through strange seas of thought, alone. + http://a1.twimg.com/profile_images/1186912733/Github_Square_normal.jpg + https://github.com/sferik false - 898 + 1048 000000 333333 0084B4 DDEEF6 C0DEED - 88 + 197 Mon Jul 16 12:59:01 +0000 2007 - 727 + 1040 -28800 Pacific Time (US & Canada) - http://a3.twimg.com/profile_background_images/162641967/we_concept_bg2.png + http://a2.twimg.com/profile_background_images/162641967/we_concept_bg2.png false true false true false false - 2962 + 3479 en false false - 29 + 41 true + false - Fri Oct 22 21:56:04 +0000 2010 - 28443146015 - RT @mojombo: A release three years and three months in the making. I give you...Chronic 0.3.0! http://rubygems.org/gems/chronic - <a href="http://www.echofon.com/" rel="nofollow">Echofon</a> + Sun Jan 16 21:38:25 +0000 2011 + 26755176471724032 + RT @tenderlove: [ANN] sqlite3-ruby =&gt; sqlite3 + <a href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow">Twitter for Mac</a> false false - + 9 false - Fri Oct 22 21:34:32 +0000 2010 - 28441706055 - A release three years and three months in the making. I give you...Chronic 0.3.0! http://rubygems.org/gems/chronic - web + Sun Jan 16 20:57:21 +0000 2011 + 26744838716133376 + [ANN] sqlite3-ruby =&gt; sqlite3 + <a href="http://www.echofon.com/" rel="nofollow">Echofon</a> false false - + 9 false diff --git a/spec/fixtures/user.json b/spec/fixtures/user.json deleted file mode 100644 index 22be767b3..000000000 --- a/spec/fixtures/user.json +++ /dev/null @@ -1 +0,0 @@ -{"geo_enabled":true,"time_zone":"Pacific Time (US & Canada)","description":"Adventures in hunger and foolishness.","profile_sidebar_fill_color":"DDEEF6","followers_count":898,"verified":false,"notifications":false,"follow_request_sent":false,"profile_use_background_image":true,"profile_sidebar_border_color":"C0DEED","url":null,"profile_background_image_url":"http:\/\/a3.twimg.com\/profile_background_images\/162641967\/we_concept_bg2.png","lang":"en","created_at":"Mon Jul 16 12:59:01 +0000 2007","profile_background_color":"000000","location":"San Francisco","listed_count":29,"profile_background_tile":false,"friends_count":88,"protected":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/323331048\/me_normal.jpg","statuses_count":2962,"profile_text_color":"333333","name":"Erik Michaels-Ober","show_all_inline_media":true,"following":true,"favourites_count":727,"screen_name":"sferik","id":7505382,"id_str":"7505382","contributors_enabled":false,"utc_offset":-28800,"profile_link_color":"0084B4"} \ No newline at end of file diff --git a/spec/twitter/client/account_spec.rb b/spec/twitter/client/account_spec.rb index 22fdd2942..8067144c0 100644 --- a/spec/twitter/client/account_spec.rb +++ b/spec/twitter/client/account_spec.rb @@ -11,7 +11,7 @@ before do stub_get("account/verify_credentials.#{format}"). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -72,7 +72,7 @@ before do stub_post("account/update_delivery_device.#{format}"). with(:body => {:device => "sms"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -94,7 +94,7 @@ before do stub_post("account/update_profile_colors.#{format}"). with(:body => {:profile_background_color => "000000"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -115,7 +115,7 @@ before do stub_post("account/update_profile_image.#{format}"). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -135,7 +135,7 @@ before do stub_post("account/update_profile_background_image.#{format}"). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -156,7 +156,7 @@ before do stub_post("account/update_profile.#{format}"). with(:body => {:url => "http://github.com/sferik/"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do diff --git a/spec/twitter/client/block_spec.rb b/spec/twitter/client/block_spec.rb index e58938a08..62f2f0e8a 100644 --- a/spec/twitter/client/block_spec.rb +++ b/spec/twitter/client/block_spec.rb @@ -12,7 +12,7 @@ before do stub_post("blocks/create.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -33,7 +33,7 @@ before do stub_delete("blocks/destroy.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -55,7 +55,7 @@ before do stub_get("blocks/exists.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) stub_get("blocks/exists.#{format}"). with(:query => {:screen_name => "pengwynn"}). to_return(:body => fixture("not_found.#{format}"), :status => 404, :headers => {:content_type => "application/#{format}; charset=utf-8"}) diff --git a/spec/twitter/client/friendship_spec.rb b/spec/twitter/client/friendship_spec.rb index 072a04b75..ae4430485 100644 --- a/spec/twitter/client/friendship_spec.rb +++ b/spec/twitter/client/friendship_spec.rb @@ -14,7 +14,7 @@ before do stub_post("friendships/create.#{format}"). with(:body => {:screen_name => "sferik", :follow => "true"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -36,7 +36,7 @@ before do stub_post("friendships/create.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -58,7 +58,7 @@ before do stub_post("friendships/create.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -82,7 +82,7 @@ before do stub_delete("friendships/destroy.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do diff --git a/spec/twitter/client/list_subscribers_spec.rb b/spec/twitter/client/list_subscribers_spec.rb index e94efb6a1..638caeee8 100644 --- a/spec/twitter/client/list_subscribers_spec.rb +++ b/spec/twitter/client/list_subscribers_spec.rb @@ -138,7 +138,7 @@ before do stub_get("sferik/presidents/subscribers/813286.#{format}"). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) stub_get("sferik/presidents/subscribers/18755393.#{format}"). to_return(:body => fixture("not_found.#{format}"), :status => 404, :headers => {:content_type => "application/#{format}; charset=utf-8"}) end @@ -166,7 +166,7 @@ before do @client.stub!(:get_screen_name).and_return('sferik') stub_get("sferik/presidents/subscribers/813286.#{format}"). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) stub_get("sferik/presidents/subscribers/18755393.#{format}"). to_return(:body => fixture("not_found.#{format}"), :status => 404, :headers => {:content_type => "application/#{format}; charset=utf-8"}) end diff --git a/spec/twitter/client/notification_spec.rb b/spec/twitter/client/notification_spec.rb index bb83717e3..a692d2e95 100644 --- a/spec/twitter/client/notification_spec.rb +++ b/spec/twitter/client/notification_spec.rb @@ -12,7 +12,7 @@ before do stub_post("notifications/follow.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -34,7 +34,7 @@ before do stub_post("notifications/leave.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do diff --git a/spec/twitter/client/spam_reporting_spec.rb b/spec/twitter/client/spam_reporting_spec.rb index 629dae728..35e0b9854 100644 --- a/spec/twitter/client/spam_reporting_spec.rb +++ b/spec/twitter/client/spam_reporting_spec.rb @@ -12,7 +12,7 @@ before do stub_post("report_spam.#{format}"). with(:body => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do diff --git a/spec/twitter/client/user_spec.rb b/spec/twitter/client/user_spec.rb index 764969bc5..eee5f41f6 100644 --- a/spec/twitter/client/user_spec.rb +++ b/spec/twitter/client/user_spec.rb @@ -14,7 +14,7 @@ before do stub_get("users/show.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -36,7 +36,7 @@ before do stub_get("users/show.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -53,7 +53,7 @@ before do stub_get("users/show.#{format}"). with(:query => {:screen_name => "0"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -70,7 +70,7 @@ before do stub_get("users/show.#{format}"). with(:query => {:user_id => "7505382"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do @@ -88,7 +88,7 @@ @client.stub!(:get_screen_name).and_return('sferik') stub_get("users/show.#{format}"). with(:query => {:screen_name => "sferik"}). - to_return(:body => fixture("user.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) + to_return(:body => fixture("sferik.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) end it "should get the correct resource" do diff --git a/spec/twitter/client_spec.rb b/spec/twitter/client_spec.rb index a71bdc28c..7d6e31c3d 100644 --- a/spec/twitter/client_spec.rb +++ b/spec/twitter/client_spec.rb @@ -7,4 +7,15 @@ connection = client.send(:connection).build_url(nil).to_s connection.should == endpoint.to_s end + + it "should not cache the screen name across clients" do + stub_get("account/verify_credentials.json"). + to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"}) + client1 = Twitter::Client.new(:oauth_token => 'ot1', :oauth_token_secret => 'ots1') + client1.send(:get_screen_name).should == "sferik" + stub_get("account/verify_credentials.json"). + to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"}) + client2 = Twitter::Client.new(:oauth_token => 'ot2', :oauth_token_secret => 'ots2') + client2.send(:get_screen_name).should == "pengwynn" + end end