Browse files

add query={} argument to trends_statuses

  • Loading branch information...
1 parent dce81c5 commit 017b0f59bffd13787726a643af6dd61bb2b66f67 @yachi yachi committed Aug 15, 2011
Showing with 34 additions and 2 deletions.
  1. +4 −2 lib/weibo/base.rb
  2. +13 −0 spec/spec_helper.rb
  3. +17 −0 spec/weibo/base_spec.rb
View
6 lib/weibo/base.rb
@@ -294,8 +294,10 @@ def trends_weekly(query={})
end
# Trends/statuses
- def trends_statuses(trend_name)
- perform_post("/trends/statuses.json", :body => {:trend_name => trend_name})
+ def trends_statuses(trend_name, query={})
+ body = {:trend_name => trend_name}
+ body.merge!(query)
+ perform_post("/trends/statuses.json", :body => body)
end
#Trends/follow
View
13 spec/spec_helper.rb
@@ -1,2 +1,15 @@
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
require 'weibo'
+
+
+def create_weibo_client
+ Weibo::Config.api_key = 'dev_key'
+ Weibo::Config.api_secret = 'dev_secret'
+
+ user_key = 'user_key'
+ user_secret = 'user_secret'
+
+ weibo_oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
+ weibo_oauth_access = weibo_oauth.authorize_from_access(user_key, user_secret)
+ Weibo::Base.new(weibo_oauth_access)
+end
View
17 spec/weibo/base_spec.rb
@@ -1 +1,18 @@
require 'spec_helper'
+
+describe Weibo::Base do
+
+ before(:each) do
+ @client = create_weibo_client
+ end
+
+ describe "#trends_statuses" do
+ it "pass query argument" do
+ @client = create_weibo_client
+ @client.stub(:perform_post)
+ @client.should_receive(:perform_post).with("/trends/statuses.json", {:body => {:count=>1999, :trend_name => "cat", :page =>5 }})
+ @client.trends_statuses('cat', {:page => 5, :count => 1999})
+ end
+
+ end
+end

0 comments on commit 017b0f5

Please sign in to comment.