spec/base_spec.rb in billymeltdown-twitter-0.3.8.1 vs spec/base_spec.rb in billymeltdown-twitter-0.4.2

- old
+ new

@@ -14,11 +14,15 @@ describe "timelines" do it "should bomb if given invalid timeline" do lambda { @base.timeline(:fakeyoutey) }.should raise_error(Twitter::UnknownTimeline) end - it "should default to friends timeline" + it "should default to friends timeline" do + @base.should_receive(:call).with("friends_timeline", {:auth=>true, :args=>{}, :since=>nil}) + @base.should_receive(:statuses) + @base.timeline + end it "should be able to retrieve friends timeline" do data = open(File.dirname(__FILE__) + '/fixtures/friends_timeline.xml').read @base.should_receive(:request).and_return(Hpricot::XML(data)) @base.timeline(:friends).size.should == 3 @@ -48,10 +52,16 @@ data = open(File.dirname(__FILE__) + '/fixtures/friends_lite.xml').read @base.should_receive(:request).and_return(Hpricot::XML(data)) @base.friends(:lite => true).size.should == 15 end + it "should be able to get friend ids" do + data = open(File.dirname(__FILE__) + '/fixtures/friend_ids.xml').read + @base.should_receive(:request).and_return(Hpricot::XML(data)) + @base.friend_ids.size.should == 8 + end + it "should be able to get friends for another user" do data = open(File.dirname(__FILE__) + '/fixtures/friends_for.xml').read @base.should_receive(:request).and_return(Hpricot::XML(data)) timeline = @base.friends_for(20) timeline.size.should == 24 @@ -64,21 +74,29 @@ timeline = @base.followers timeline.size.should == 29 timeline.first.name.should == 'Blaine Cook' end + it "should be able to get follower ids" do + data = open(File.dirname(__FILE__) + '/fixtures/follower_ids.xml').read + @base.should_receive(:request).and_return(Hpricot::XML(data)) + @base.follower_ids.size.should == 8 + end + it "should be able to create a friendship" do data = open(File.dirname(__FILE__) + '/fixtures/friendship_created.xml').read @base.should_receive(:request).and_return(Hpricot::XML(data)) user = @base.create_friendship('jnunemaker') end - it "should bomb if friendship already exists" #do - # data = open(File.dirname(__FILE__) + '/fixtures/friendship_already_exists.xml').read - # @base.should_receive(:request).and_return(Hpricot::XML(data)) - # lambda { @base.create_friendship('billymeltdown') }.should raise_error(Twitter::AlreadyFollowing) - #end + it "should bomb if friendship already exists" do + data = open(File.dirname(__FILE__) + '/fixtures/friendship_already_exists.xml').read + response = Net::HTTPForbidden.new("1.1", '403', '') + response.stub!(:body).and_return(data) + @base.should_receive(:response).and_return(response) + lambda { @base.create_friendship('billymeltdown') }.should raise_error(Twitter::AlreadyFollowing) + end end it "should be able to get single status" do data = open(File.dirname(__FILE__) + '/fixtures/status.xml').read @base.should_receive(:request).and_return(Hpricot::XML(data)) @@ -116,6 +134,6 @@ it "should have remaining hits" do @base.rate_limit_status.remaining_hits.should == 5 end end -end \ No newline at end of file +end