Skip to content

Commit

Permalink
Add Suggestion spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 17, 2011
1 parent 4f47075 commit 7674681
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 13 deletions.
54 changes: 41 additions & 13 deletions spec/twitter/client/friends_and_followers_spec.rb
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions spec/twitter/suggestion_spec.rb
@@ -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.