rubytter 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rubytter.rb +8 -3
- data/spec/rubytter_spec.rb +11 -1
- metadata +1 -1
data/lib/rubytter.rb
CHANGED
@@ -10,7 +10,7 @@ class Rubytter
|
|
10
10
|
class APIError < StandardError; end
|
11
11
|
|
12
12
|
APP_NAME = 'Rubytter'
|
13
|
-
VERSION = '0.4.
|
13
|
+
VERSION = '0.4.4'
|
14
14
|
HOMEPAGE = 'http://github.com/jugyo/rubytter'
|
15
15
|
|
16
16
|
def initialize(login, password, options = {})
|
@@ -84,8 +84,13 @@ class Rubytter
|
|
84
84
|
send_direct_message(params.merge({:user => user, :text => text}))
|
85
85
|
end
|
86
86
|
|
87
|
-
def search(
|
88
|
-
params =
|
87
|
+
def search(arg)
|
88
|
+
params = case arg
|
89
|
+
when String
|
90
|
+
{:q => arg}
|
91
|
+
when Hash
|
92
|
+
arg
|
93
|
+
end
|
89
94
|
path = '/search.json?' + to_param_str(params)
|
90
95
|
req = create_request(Net::HTTP::Post.new(path))
|
91
96
|
http_request(req, nil, "search.#{@host}")
|
data/spec/rubytter_spec.rb
CHANGED
@@ -110,10 +110,20 @@ class Rubytter
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'should respond to search' do
|
113
|
-
@rubytter.should_receive(:http_request)
|
113
|
+
@rubytter.should_receive(:http_request) do |req, param_str, host|
|
114
|
+
req.path.should == '/search.json?q=test'
|
115
|
+
host.should == 'search.twitter.com'
|
116
|
+
end
|
114
117
|
@rubytter.search('test')
|
115
118
|
end
|
116
119
|
|
120
|
+
it 'should respond to search with params' do
|
121
|
+
@rubytter.should_receive(:http_request) do |req, param_str, host|
|
122
|
+
req.path.should == '/search.json?lang=ja&q=test'
|
123
|
+
end
|
124
|
+
@rubytter.search(:q => 'test', :lang => 'ja')
|
125
|
+
end
|
126
|
+
|
117
127
|
it 'should respond to to_param_str' do
|
118
128
|
@rubytter.to_param_str(:page => 2, :foo => 'bar').should == 'foo=bar&page=2'
|
119
129
|
end
|