Skip to content

Commit

Permalink
Change trends endpoint to api.twitter.com/1/trends
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 23, 2010
1 parent a608d40 commit 39ff888
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/twitter/trends.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Trends
format :json

def self.api_endpoint
@api_endpoint ||= "search.twitter.com/trends"
@api_endpoint ||= "api.twitter.com/#{API_VERSION}/trends"
end

def self.api_endpoint=(value)
Expand Down
20 changes: 10 additions & 10 deletions test/twitter/trends_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TrendsTest < Test::Unit::TestCase

context "Getting current trends" do
should "work" do
stub_get 'http://search.twitter.com:80/trends/current.json', 'trends_current.json'
stub_get 'http://api.twitter.com/1/trends/current.json', 'trends_current.json'
trends = Trends.current
trends.size.should == 10
trends[0].name.should == '#musicmonday'
Expand All @@ -15,7 +15,7 @@ class TrendsTest < Test::Unit::TestCase
end

should "be able to exclude hashtags" do
stub_get 'http://search.twitter.com:80/trends/current.json?exclude=hashtags', 'trends_current_exclude.json'
stub_get 'http://api.twitter.com/1/trends/current.json?exclude=hashtags', 'trends_current_exclude.json'
trends = Trends.current(:exclude => 'hashtags')
trends.size.should == 10
trends[0].name.should == 'New Divide'
Expand All @@ -27,31 +27,31 @@ class TrendsTest < Test::Unit::TestCase

context "Getting daily trends" do
should "work" do
stub_get 'http://search.twitter.com:80/trends/daily.json?', 'trends_daily.json'
stub_get 'http://api.twitter.com/1/trends/daily.json?', 'trends_daily.json'
trends = Trends.daily
trends.size.should == 480
trends[0].name.should == '#3turnoffwords'
trends[0].query.should == '#3turnoffwords'
end

should "be able to exclude hastags" do
stub_get 'http://search.twitter.com:80/trends/daily.json?exclude=hashtags', 'trends_daily_exclude.json'
stub_get 'http://api.twitter.com/1/trends/daily.json?exclude=hashtags', 'trends_daily_exclude.json'
trends = Trends.daily(:exclude => 'hashtags')
trends.size.should == 480
trends[0].name.should == 'Kobe'
trends[0].query.should == %Q(Kobe)
end

should "be able to get for specific date (with date string)" do
stub_get 'http://search.twitter.com:80/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
stub_get 'http://api.twitter.com/1/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
trends = Trends.daily(:date => '2009-05-01')
trends.size.should == 440
trends[0].name.should == 'Swine Flu'
trends[0].query.should == %Q(\"Swine Flu\" OR Flu)
end

should "be able to get for specific date (with date object)" do
stub_get 'http://search.twitter.com:80/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
stub_get 'http://api.twitter.com/1/trends/daily.json?date=2009-05-01', 'trends_daily_date.json'
trends = Trends.daily(:date => Date.new(2009, 5, 1))
trends.size.should == 440
trends[0].name.should == 'Swine Flu'
Expand All @@ -61,31 +61,31 @@ class TrendsTest < Test::Unit::TestCase

context "Getting weekly trends" do
should "work" do
stub_get 'http://search.twitter.com:80/trends/weekly.json?', 'trends_weekly.json'
stub_get 'http://api.twitter.com/1/trends/weekly.json?', 'trends_weekly.json'
trends = Trends.weekly
trends.size.should == 210
trends[0].name.should == 'Happy Mothers Day'
trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
end

should "be able to exclude hastags" do
stub_get 'http://search.twitter.com:80/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json'
stub_get 'http://api.twitter.com/1/trends/weekly.json?exclude=hashtags', 'trends_weekly_exclude.json'
trends = Trends.weekly(:exclude => 'hashtags')
trends.size.should == 210
trends[0].name.should == 'Happy Mothers Day'
trends[0].query.should == %Q(\"Happy Mothers Day\" OR \"Mothers Day\")
end

should "be able to get for specific date (with date string)" do
stub_get 'http://search.twitter.com:80/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
stub_get 'http://api.twitter.com/1/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
trends = Trends.weekly(:date => '2009-05-01')
trends.size.should == 210
trends[0].name.should == 'TGIF'
trends[0].query.should == 'TGIF'
end

should "be able to get for specific date (with date object)" do
stub_get 'http://search.twitter.com:80/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
stub_get 'http://api.twitter.com/1/trends/weekly.json?date=2009-05-01', 'trends_weekly_date.json'
trends = Trends.weekly(:date => Date.new(2009, 5, 1))
trends.size.should == 210
trends[0].name.should == 'TGIF'
Expand Down

0 comments on commit 39ff888

Please sign in to comment.