spec/rubytter_spec.rb in rubytter-0.4.4 vs spec/rubytter_spec.rb in rubytter-0.4.5
- old
+ new
@@ -18,115 +18,133 @@
# more...
end
it 'should get or post' do
# TODO: split specs
- @rubytter.should_receive(:get).with('/statuses/replies', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/statuses/replies', {})
@rubytter.replies
- @rubytter.should_receive(:get).with('/statuses/replies', {:page => 2})
+ @rubytter.should_receive(:get).with('twitter.com', '/statuses/replies', {:page => 2})
@rubytter.replies(:page => 2)
- @rubytter.should_receive(:get).with('/statuses/user_timeline/1', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/statuses/user_timeline/1', {})
@rubytter.user_timeline(1)
- @rubytter.should_receive(:get).with('/users/show/1', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/users/show/1', {})
@rubytter.user(1)
- @rubytter.should_receive(:delete).with('/statuses/destroy/1', {})
+ @rubytter.should_receive(:delete).with('twitter.com', '/statuses/destroy/1', {})
@rubytter.remove_status(1)
end
# direct_messages
it 'should respond to direct_messages' do
- @rubytter.should_receive(:get).with('/direct_messages', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/direct_messages', {})
@rubytter.direct_messages()
end
it 'should respond to sent_direct_messages' do
- @rubytter.should_receive(:get).with('/direct_messages/sent', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/direct_messages/sent', {})
@rubytter.sent_direct_messages()
end
it 'should respond to send_direct_message' do
- @rubytter.should_receive(:post).with('/direct_messages/new', {})
+ @rubytter.should_receive(:post).with('twitter.com', '/direct_messages/new', {})
@rubytter.send_direct_message()
end
it 'should respond to destroy_direct_message' do
- @rubytter.should_receive(:delete).with('/direct_messages/destroy/1', {})
+ @rubytter.should_receive(:delete).with('twitter.com', '/direct_messages/destroy/1', {})
@rubytter.remove_direct_message(1)
end
it 'should respond to direct_message' do
- @rubytter.should_receive(:post).with('/direct_messages/new', {:user => 'test', :text => 'aaaaaaaaaaaaa'})
+ @rubytter.should_receive(:post).with('twitter.com', '/direct_messages/new', {:user => 'test', :text => 'aaaaaaaaaaaaa'})
@rubytter.direct_message('test', 'aaaaaaaaaaaaa')
end
# statuses
it 'should respond to update' do
- @rubytter.should_receive(:post).with('/statuses/update', {:status => 'test'})
+ @rubytter.should_receive(:post).with('twitter.com', '/statuses/update', {:status => 'test'})
@rubytter.update('test')
end
it 'should respond to update_status' do
- @rubytter.should_receive(:post).with('/statuses/update', {:status => 'test'})
+ @rubytter.should_receive(:post).with('twitter.com', '/statuses/update', {:status => 'test'})
@rubytter.update_status(:status => 'test')
end
# friendship
it 'should respond to follow' do
- @rubytter.should_receive(:post).with('/friendships/create/test', {})
+ @rubytter.should_receive(:post).with('twitter.com', '/friendships/create/test', {})
@rubytter.follow('test')
end
it 'should respond to leave' do
- @rubytter.should_receive(:delete).with('/friendships/destroy/test', {})
+ @rubytter.should_receive(:delete).with('twitter.com', '/friendships/destroy/test', {})
@rubytter.leave('test')
end
it 'should respond to friendship_exists' do
- @rubytter.should_receive(:get).with('/friendships/exists', {:user_a => 'a', :user_b => 'b'})
+ @rubytter.should_receive(:get).with('twitter.com', '/friendships/exists', {:user_a => 'a', :user_b => 'b'})
@rubytter.friendship_exists(:user_a => 'a', :user_b => 'b')
end
# Social Graph Methods
it 'should respond to followers_ids' do
- @rubytter.should_receive(:get).with('/friends/ids/test', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/friends/ids/test', {})
@rubytter.friends_ids('test')
end
it 'should respond to followers_ids' do
- @rubytter.should_receive(:get).with('/followers/ids/test', {})
+ @rubytter.should_receive(:get).with('twitter.com', '/followers/ids/test', {})
@rubytter.followers_ids('test')
end
it 'should respond to http_request' do
- @rubytter.should_receive(:http_request) {|req, param_str| param_str.should == 'status=test'}
+ @rubytter.should_receive(:http_request) {|host, req, param_str| param_str.should == 'status=test'}
@rubytter.update_status(:status => 'test')
end
- it 'should respond to search' do
- @rubytter.should_receive(:http_request) do |req, param_str, host|
+ it 'should respond to search (1)' do
+ @rubytter.should_receive(:get).with('search.twitter.com', '/search', {:q => 'test'})
+ @rubytter.search('test')
+ end
+
+ it 'should respond to search (2)' do
+ @rubytter.should_receive(:http_request) do |host, req, param_str|
req.path.should == '/search.json?q=test'
host.should == 'search.twitter.com'
end
@rubytter.search('test')
end
- it 'should respond to search with params' do
- @rubytter.should_receive(:http_request) do |req, param_str, host|
- req.path.should == '/search.json?lang=ja&q=test'
+ it 'should respond to search with params (1)' do
+ @rubytter.should_receive(:get).with('search.twitter.com', "/search", {:q=>"test", :lang=>"ja"})
+ @rubytter.search(:q => 'test', :lang => 'ja')
+ end
+
+ it 'should respond to search with params (2)' do
+ @rubytter.should_receive(:http_request) do |host, req, param_str|
+ req.path.should =~ /\/search.json\?/
+ req.path.should =~ /q=test/
+ req.path.should =~ /lang=ja/
end
@rubytter.search(:q => 'test', :lang => 'ja')
end
it 'should respond to to_param_str' do
@rubytter.to_param_str(:page => 2, :foo => 'bar').should == 'foo=bar&page=2'
+ end
+
+ it 'should raise when call to_param_str with invalid arg' do
+ lambda { @rubytter.to_param_str(nil) }.should raise_error ArgumentError
+ lambda { @rubytter.to_param_str('foo') }.should raise_error ArgumentError
+ lambda { @rubytter.to_param_str(:bar) }.should raise_error ArgumentError
end
it 'should create struct from json' do
hash = {
:a => 'a',