Permalink
Browse files

Add Suggestion spec

  • Loading branch information...
1 parent 4f47075 commit 7674681763a4a6197491996591ef2f42335c541b @sferik committed Oct 17, 2011
Showing with 61 additions and 13 deletions.
  1. +41 −13 spec/twitter/client/friends_and_followers_spec.rb
  2. +20 −0 spec/twitter/suggestion_spec.rb
@@ -154,21 +154,49 @@
end
describe ".friendship" do
- before do
- stub_get("/1/friendships/show.json").
- with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).
- to_return(:body => fixture("relationship.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ context "with screen names passed" do
+ before do
+ stub_get("/1/friendships/show.json").
+ with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).
+ to_return(:body => fixture("relationship.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "should get the correct resource" do
+ @client.friendship("sferik", "pengwynn")
+ a_get("/1/friendships/show.json").
+ with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).
+ should have_been_made
+ end
+ it "should return detailed information about the relationship between two users" do
+ relationship = @client.friendship("sferik", "pengwynn")
+ relationship.should be_a Twitter::Relationship
+ relationship.source.screen_name.should == "sferik"
+ end
end
- it "should get the correct resource" do
- @client.friendship("sferik", "pengwynn")
- a_get("/1/friendships/show.json").
- with(:query => {:source_screen_name => "sferik", :target_screen_name => "pengwynn"}).
- should have_been_made
+ context "with numeric screen names passed" do
+ before do
+ stub_get("/1/friendships/show.json").
+ with(:query => {:source_screen_name => "0", :target_screen_name => "311"}).
+ to_return(:body => fixture("relationship.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "should get the correct resource" do
+ @client.friendship("0", "311")
+ a_get("/1/friendships/show.json").
+ with(:query => {:source_screen_name => "0", :target_screen_name => "311"}).
+ should have_been_made
+ end
end
- it "should return detailed information about the relationship between two users" do
- relationship = @client.friendship("sferik", "pengwynn")
- relationship.should be_a Twitter::Relationship
- relationship.source.screen_name.should == "sferik"
+ context "with user IDs passed" do
+ before do
+ stub_get("/1/friendships/show.json").
+ with(:query => {:source_id => "7505382", :target_id => "14100886"}).
+ to_return(:body => fixture("relationship.json"), :headers => {:content_type => "application/json; charset=utf-8"})
+ end
+ it "should get the correct resource" do
+ @client.friendship(7505382, 14100886)
+ a_get("/1/friendships/show.json").
+ with(:query => {:source_id => "7505382", :target_id => "14100886"}).
+ should have_been_made
+ end
end
end
@@ -0,0 +1,20 @@
+require 'helper'
+
+describe Twitter::Suggestion do
+
+ before do
+ @suggestion = Twitter::Suggestion.new('slug' => 'art-design')
+ end
+
+ describe "#==" do
+ it "should return true when slugs are equal" do
+ other = Twitter::Suggestion.new('slug' => 'art-design')
+ (@suggestion == other).should be_true
+ end
+ it "should return false when coordinates are not equal" do
+ other = Twitter::Suggestion.new('slug' => 'design-art')
+ (@suggestion == other).should be_false
+ end
+ end
+
+end

0 comments on commit 7674681

Please sign in to comment.