twitter4r 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,353 +39,10 @@ describe "Twitter::RESTError#to_s" do
39
39
  end
40
40
  end
41
41
 
42
- describe "Twitter::Client" do
43
- before(:each) do
44
- @init_hash = { :login => 'user', :password => 'pass' }
45
- end
46
-
47
- it ".new should accept login and password as initializer hash keys and set the values to instance values" do
48
- client = nil
49
- lambda do
50
- client = Twitter::Client.new(@init_hash)
51
- end.should_not raise_error
52
- client.send(:login).should eql(@init_hash[:login])
53
- client.send(:password).should eql(@init_hash[:password])
54
- end
55
- end
56
-
57
- describe "Twitter::Client.config" do
58
- before(:each) do
59
- @config_hash = { :host => 'test.host',
60
- :port => 443,
61
- :ssl => true,
62
- :proxy_host => 'myproxy.host',
63
- :proxy_port => 8080,
64
- :proxy_user => 'myproxyuser',
65
- :proxy_pass => 'myproxypass',
66
- }
67
- end
68
-
69
- it "should override @@CONF values if supplied" do
70
- Twitter::Client.config @config_hash
71
- host = Twitter::Client.class_eval("@@CONF[:host]")
72
- host.should eql(@config_hash[:host])
73
- port = Twitter::Client.class_eval("@@CONF[:port]")
74
- port.should eql(@config_hash[:port])
75
- ssl = Twitter::Client.class_eval("@@CONF[:ssl]")
76
- ssl.should eql(@config_hash[:ssl])
77
- proxy_host = Twitter::Client.class_eval("@@CONF[:proxy_host]")
78
- proxy_host.should eql(@config_hash[:proxy_host])
79
- proxy_port = Twitter::Client.class_eval("@@CONF[:proxy_port]")
80
- proxy_port.should eql(@config_hash[:proxy_port])
81
- proxy_user = Twitter::Client.class_eval("@@CONF[:proxy_user]")
82
- proxy_user.should eql(@config_hash[:proxy_user])
83
- proxy_pass = Twitter::Client.class_eval("@@CONF[:proxy_pass]")
84
- proxy_pass.should eql(@config_hash[:proxy_pass])
85
-
86
- end
87
-
88
- after(:each) do
89
- Twitter::Client.config :host => 'twitter.com', :port => 80, :use_ssl => false
90
- end
91
- end
92
-
93
- describe "Twitter::Client#timeline(:public)" do
94
- before(:each) do
95
- Twitter::Client.config(:port => 443, :use_ssl => false)
96
- @host = Twitter::Client.class_eval("@@CONF[:host]")
97
- @port = Twitter::Client.class_eval("@@CONF[:port]")
98
- @proxy_host = Twitter::Client.class_eval("@@CONF[:proxy_host]")
99
- @proxy_port = Twitter::Client.class_eval("@@CONF[:proxy_port]")
100
- @proxy_user = Twitter::Client.class_eval("@@CONF[:proxy_user]")
101
- @proxy_pass = Twitter::Client.class_eval("@@CONF[:proxy_pass]")
102
-
103
- @request = mas_net_http_get(:basic_auth => nil)
104
- @response = mas_net_http_response(:success, '[]')
105
-
106
- @http = mas_net_http(@response)
107
- @client = Twitter::Client.from_config 'config/twitter.yml'
108
- @login = @client.instance_eval("@login")
109
- @password = @client.instance_eval("@password")
110
- end
111
-
112
- it "should connect to the Twitter service via HTTP connection" do
113
- Net::HTTP.should_receive(:new).with(@host, @port, @proxy_host, @proxy_port, @proxy_user, @proxy_pass).once.and_return(@http)
114
- @client.timeline(:public)
115
- end
116
-
117
- it " should send HTTP Basic Authentication credentials" do
118
- @request.should_receive(:basic_auth).with(@login, @password).once
119
- @client.timeline(:public)
120
- end
121
- end
122
-
123
- describe "Twitter::Client#unmarshall_statuses" do
124
- before(:each) do
125
- @json_hash = { "text" => "Thinking Zipcar is lame...",
126
- "id" => 46672912,
127
- "user" => {"name" => "Angie",
128
- "description" => "TV junkie...",
129
- "location" => "NoVA",
130
- "profile_image_url" => "http:\/\/assets0.twitter.com\/system\/user\/profile_image\/5483072\/normal\/eye.jpg?1177462492",
131
- "url" => nil,
132
- "id" => 5483072,
133
- "protected" => false,
134
- "screen_name" => "ang_410"},
135
- "created_at" => "Wed May 02 03:04:54 +0000 2007"}
136
- @user = Twitter::User.new @json_hash["user"]
137
- @status = Twitter::Status.new @json_hash
138
- @status.user = @user
139
- @client = Twitter::Client.from_config 'config/twitter.yml'
140
- end
141
-
142
- it "should return expected populated Twitter::Status object values in an Array" do
143
- statuses = @client.send(:unmarshall_statuses, [@json_hash])
144
- statuses.should have(1).entries
145
- statuses.first.should.eql? @status
146
- end
147
- end
148
-
149
- describe "Twitter::Client#unmarshall_user" do
150
- before(:each) do
151
- @json_hash = { "name" => "Lucy Snowe",
152
- "description" => "School Mistress Entrepreneur",
153
- "location" => "Villette",
154
- "url" => "http://villetteschoolforgirls.com",
155
- "id" => 859303,
156
- "protected" => true,
157
- "screen_name" => "LucyDominatrix", }
158
- @user = Twitter::User.new @json_hash
159
- @client = Twitter::Client.from_config 'config/twitter.yml'
160
- end
161
-
162
- it "should return expected populated Twitter::User object value" do
163
- user = @client.send(:unmarshall_user, @json_hash)
164
- user.should.eql? @user
165
- end
166
- end
167
-
168
- describe "Twitter::Client#timeline_request upon 200 HTTP response" do
169
- before(:each) do
170
- @request = mas_net_http_get :basic_auth => nil
171
- @response = mas_net_http_response # defaults to :success
172
-
173
- @http = mas_net_http(@response)
174
- @client = Twitter::Client.from_config 'config/twitter.yml'
175
- @uris = Twitter::Client.class_eval("@@URIS")
176
-
177
- JSON.stub!(:parse).and_return({})
178
- end
179
-
180
- it "should make GET HTTP request to appropriate URL" do
181
- @uris.keys.each do |type|
182
- Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
183
- @client.send(:timeline_request, type, @http)
184
- end
185
- end
186
- end
187
-
188
- describe "Twitter::Client#timeline_request upon 403 HTTP response" do
189
- before(:each) do
190
- @request = mas_net_http_get :basic_auth => nil
191
- @response = mas_net_http_response :not_authorized
192
-
193
- @http = mas_net_http(@response)
194
- @client = Twitter::Client.from_config 'config/twitter.yml'
195
- @uris = Twitter::Client.class_eval("@@URIS")
196
- end
197
-
198
- it "should make GET HTTP request to appropriate URL" do
199
- @uris.keys.each do |type|
200
- lambda do
201
- Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
202
- @client.send(:timeline_request, type, @http)
203
- end.should raise_error(Twitter::RESTError)
204
- end
205
- end
206
- end
207
-
208
- describe "Twitter::Client#timeline_request upon 500 HTTP response" do
209
- before(:each) do
210
- @request = mas_net_http_get(:basic_auth => nil)
211
- @response = mas_net_http_response(:server_error)
212
-
213
- @http = mas_net_http(@response)
214
- @client = Twitter::Client.from_config 'config/twitter.yml'
215
- @uris = Twitter::Client.class_eval("@@URIS")
216
- end
217
-
218
- it "should make GET HTTP request to appropriate URL" do
219
- @uris.keys.each do |type|
220
- lambda do
221
- Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
222
- @client.send(:timeline_request, type, @http)
223
- end.should raise_error(Twitter::RESTError)
224
- end
225
- end
226
- end
227
-
228
- describe "Twitter::Client#timeline_request upon 404 HTTP response" do
229
- before(:each) do
230
- @request = mas_net_http_get(:basic_auth => nil)
231
- @response = mas_net_http_response(:file_not_found)
232
-
233
- @http = mas_net_http(@response)
234
- @client = Twitter::Client.from_config 'config/twitter.yml'
235
- @uris = Twitter::Client.class_eval("@@URIS")
236
- end
237
-
238
- it "should make GET HTTP request to appropriate URL" do
239
- @uris.keys.each do |type|
240
- lambda do
241
- Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
242
- @client.send(:timeline_request, type, @http)
243
- end.should raise_error(Twitter::RESTError)
244
- end
245
- end
246
- end
247
-
248
- describe "Twitter::Client#update(msg) upon 200 HTTP response" do
249
- before(:each) do
250
- @request = mas_net_http_post(:basic_auth => nil)
251
- @response = mas_net_http_response
252
-
253
- @http = mas_net_http(@response)
254
- @client = Twitter::Client.from_config 'config/twitter.yml'
255
- @expected_uri = Twitter::Client.class_eval("@@URIS[:update]")
256
-
257
- @message = "We love Jodhi May!"
258
- end
259
-
260
- it "should make POST HTTP request to appropriate URL" do
261
- Net::HTTP::Post.should_receive(:new).with(@expected_uri).and_return(@request)
262
- @client.update(@message)
263
- end
264
- end
265
-
266
- describe "Twitter::Client#update(msg) upon 500 HTTP response" do
267
- before(:each) do
268
- @request = mas_net_http_post(:basic_auth => nil)
269
- @response = mas_net_http_response(:server_error)
270
-
271
- @http = mas_net_http(@response)
272
- @client = Twitter::Client.from_config 'config/twitter.yml'
273
- @expected_uri = Twitter::Client.class_eval("@@URIS[:update]")
274
-
275
- @message = "We love Jodhi May!"
276
- end
277
-
278
- it "should make POST HTTP request to appropriate URL" do
279
- lambda do
280
- Net::HTTP::Post.should_receive(:new).with(@expected_uri).and_return(@request)
281
- @client.update(@message)
282
- end.should raise_error(Twitter::RESTError)
283
- end
284
- end
285
-
286
- describe "Twitter::Client#public_timeline" do
287
- before(:each) do
288
- @request = mas_net_http_get(:basic_auth => nil)
289
- @response = mas_net_http_response
290
-
291
- @http = mas_net_http(@response)
292
- @client = Twitter::Client.from_config 'config/twitter.yml'
293
- end
294
-
295
- it "should delegate work to Twitter::Client#public(:public)" do
296
- @client.should_receive(:timeline).with(:public).once
297
- @client.public_timeline
298
- end
299
- end
300
-
301
- describe "Twitter::Client#friend_timeline" do
302
- before(:each) do
303
- @request = mas_net_http_get(:basic_auth => nil)
304
- @response = mas_net_http_response
305
-
306
- @http = mas_net_http(@response)
307
- @client = Twitter::Client.from_config 'config/twitter.yml'
308
- end
309
-
310
- it "should delegate work to Twitter::Client#public(:friends)" do
311
- @client.should_receive(:timeline).with(:friends).once
312
- @client.friend_timeline
313
- end
314
- end
315
-
316
- describe "Twitter::Client#friend_statuses" do
317
- before(:each) do
318
- @request = mas_net_http_get(:basic_auth => nil)
319
- @response = mas_net_http_response
320
-
321
- @http = mas_net_http(@response)
322
- @client = Twitter::Client.from_config 'config/twitter.yml'
323
- end
324
-
325
- it "should delegate work to Twitter::Client#public(:friends_statuses)" do
326
- @client.should_receive(:timeline).with(:friends_statuses).once
327
- @client.friend_statuses
328
- end
329
- end
330
-
331
- describe "Twitter::Client#follower_statuses" do
332
- before(:each) do
333
- @request = mas_net_http_get(:basic_auth => nil)
334
- @response = mas_net_http_response
335
-
336
- @http = mas_net_http(@response)
337
- @client = Twitter::Client.from_config 'config/twitter.yml'
338
- end
339
-
340
- it "should delegate work to Twitter::Client#public(:followers)" do
341
- @client.should_receive(:timeline).with(:followers).once
342
- @client.follower_statuses
343
- end
344
- end
345
-
346
- describe "Twitter::Client#send_direct_message" do
347
- before(:each) do
348
- @request = mas_net_http_post(:basic_auth => nil)
349
- @response = mas_net_http_response
350
-
351
- @http = mas_net_http(@response)
352
- @client = Twitter::Client.from_config 'config/twitter.yml'
353
-
354
- @login = @client.instance_eval("@login")
355
- @password = @client.instance_eval("@password")
356
-
357
- @user = mock(Twitter::User)
358
- @user.stub!(:screen_name).and_return("twitter4r")
359
-
360
- @message = "This is a test direct message from twitter4r RSpec specifications"
361
- @expected_uri = '/direct_messages/new.json'
362
- @expected_params = "user=#{@user.screen_name}&text=#{URI.escape(@message)}"
363
- end
364
-
365
- it "should convert given Twitter::User object to screen name" do
366
- @user.should_receive(:screen_name).once
367
- @client.send_direct_message(@user, @message)
368
- end
369
-
370
- it "should POST to expected URI" do
371
- Net::HTTP::Post.should_receive(:new).with(@expected_uri).once.and_return(@request)
372
- @client.send_direct_message(@user, @message)
373
- end
374
-
375
- it "should login via HTTP Basic Authentication using expected credentials" do
376
- @request.should_receive(:basic_auth).with(@login, @password).once
377
- @client.send_direct_message(@user, @message)
378
- end
379
-
380
- it "should make POST request with expected URI escaped parameters" do
381
- @http.should_receive(:request).with(@request, @expected_params).once.and_return(@response)
382
- @client.send_direct_message(@user, @message)
383
- end
384
- end
385
-
386
42
  describe "Twitter::Status#eql?" do
387
43
  before(:each) do
388
- @attr_hash = { :text => 'Status', :id => 34329594003,
44
+ @id = 34329594003
45
+ @attr_hash = { :text => 'Status', :id => @id,
389
46
  :user => { :name => 'Tess',
390
47
  :description => "Unfortunate D'Urberville",
391
48
  :location => 'Dorset',
@@ -398,21 +55,17 @@ describe "Twitter::Status#eql?" do
398
55
  end
399
56
 
400
57
  it "should return true when non-transient object attributes are eql?" do
401
- @obj.should.eql? @other
402
- @obj.eql?(@other).should.eql? true # for the sake of getting rcov to recognize this method is covered in the specs
58
+ @obj.should eql(@other)
403
59
  end
404
60
 
405
61
  it "should return false when not all non-transient object attributes are eql?" do
406
62
  @other.created_at = Time.now.to_s
407
63
  @obj.should_not eql(@other)
408
- @obj.eql?(@other).should be(false) # for the sake of getting rcov to recognize this method is covered in the specs
409
64
  end
410
65
 
411
66
  it "should return true when comparing same object to itself" do
412
67
  @obj.should eql(@obj)
413
- @obj.eql?(@obj).should be(true) # for the sake of getting rcov to recognize this method is covered in the specs
414
68
  @other.should eql(@other)
415
- @other.eql?(@other).should be(true) # for the sake of getting rcov to recognize this method is covered in the specs
416
69
  end
417
70
  end
418
71
 
@@ -430,7 +83,6 @@ describe "Twitter::User#eql?" do
430
83
 
431
84
  it "should return true when non-transient object attributes are eql?" do
432
85
  @obj.should eql(@other)
433
- @obj.eql?(@other).should be(true)
434
86
  end
435
87
 
436
88
  it "should return false when not all non-transient object attributes are eql?" do
@@ -441,8 +93,35 @@ describe "Twitter::User#eql?" do
441
93
 
442
94
  it "should return true when comparing same object to itself" do
443
95
  @obj.should eql(@obj)
444
- @obj.eql?(@obj).should be(true)
445
96
  @other.should eql(@other)
446
- @obj.eql?(@obj).should be(true)
97
+ end
98
+ end
99
+
100
+ describe "Twitter::ClassUtilMixin#require_block" do
101
+ before(:each) do
102
+ class TestClass
103
+ include Twitter::ClassUtilMixin
104
+ end
105
+ @test_subject = TestClass.new
106
+ end
107
+
108
+ it "should respond to :require_block" do
109
+ @test_subject.should respond_to(:require_block)
110
+ end
111
+
112
+ it "should raise ArgumentError when block not given" do
113
+ lambda {
114
+ @test_subject.send(:require_block, false)
115
+ }.should raise_error(ArgumentError)
116
+ end
117
+
118
+ it "should not raise ArgumentError when block is given" do
119
+ lambda {
120
+ @test_subject.send(:require_block, true)
121
+ }.should_not raise_error(ArgumentError)
122
+ end
123
+
124
+ after(:each) do
125
+ @test_subject = nil
447
126
  end
448
127
  end
@@ -0,0 +1,177 @@
1
+ #describe "Twitter::Client#public_timeline" do
2
+ # before(:each) do
3
+ # @request = mas_net_http_get(:basic_auth => nil)
4
+ # @response = mas_net_http_response
5
+ #
6
+ # @http = mas_net_http(@response)
7
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
8
+ # end
9
+ #
10
+ # it "should delegate work to Twitter::Client#public(:public)" do
11
+ # @client.should_receive(:timeline).with(:public).once
12
+ # @client.public_timeline
13
+ # end
14
+ #end
15
+
16
+ #describe "Twitter::Client#friend_timeline" do
17
+ # before(:each) do
18
+ # @request = mas_net_http_get(:basic_auth => nil)
19
+ # @response = mas_net_http_response
20
+ #
21
+ # @http = mas_net_http(@response)
22
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
23
+ # end
24
+ #
25
+ # it "should delegate work to Twitter::Client#public(:friends)" do
26
+ # @client.should_receive(:timeline).with(:friends).once
27
+ # @client.friend_timeline
28
+ # end
29
+ #end
30
+
31
+ #describe "Twitter::Client#friend_statuses" do
32
+ # before(:each) do
33
+ # @request = mas_net_http_get(:basic_auth => nil)
34
+ # @response = mas_net_http_response
35
+ #
36
+ # @http = mas_net_http(@response)
37
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
38
+ # end
39
+ #
40
+ # it "should delegate work to Twitter::Client#public(:friends_statuses)" do
41
+ # @client.should_receive(:timeline).with(:friends_statuses).once
42
+ # @client.friend_statuses
43
+ # end
44
+ #end
45
+
46
+ #describe "Twitter::Client#follower_statuses" do
47
+ # before(:each) do
48
+ # @request = mas_net_http_get(:basic_auth => nil)
49
+ # @response = mas_net_http_response
50
+ # @http = mas_net_http(@response)
51
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
52
+ # end
53
+ #
54
+ # it "should delegate work to Twitter::Client#public(:followers)" do
55
+ # @client.should_receive(:timeline).with(:followers).once
56
+ # @client.follower_statuses
57
+ # end
58
+ #end
59
+
60
+ #describe "Twitter::Client#timeline_request upon 200 HTTP response" do
61
+ # before(:each) do
62
+ # @request = mas_net_http_get :basic_auth => nil
63
+ # @response = mas_net_http_response # defaults to :success
64
+ #
65
+ # @http = mas_net_http(@response)
66
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
67
+ # @header = @client.send(:http_header)
68
+ # @uris = Twitter::Client.class_eval("@@URIS")
69
+ #
70
+ # JSON.stub!(:parse).and_return({})
71
+ # end
72
+ #
73
+ # it "should make GET HTTP request to appropriate URL" do
74
+ # @uris.keys.each do |type|
75
+ # Net::HTTP::Get.should_receive(:new).with(@uris[type], @header).and_return(@request)
76
+ # @client.send(:timeline, type)
77
+ # end
78
+ # end
79
+ #end
80
+
81
+ #describe "Twitter::Client#timeline_request upon 403 HTTP response" do
82
+ # before(:each) do
83
+ # @request = mas_net_http_get :basic_auth => nil
84
+ # @response = mas_net_http_response :not_authorized
85
+ #
86
+ # @http = mas_net_http(@response)
87
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
88
+ # @header = @client.send(:http_header)
89
+ # @uris = Twitter::Client.class_eval("@@URIS")
90
+ # end
91
+ #
92
+ # it "should make GET HTTP request to appropriate URL" do
93
+ # @uris.keys.each do |type|
94
+ # lambda {
95
+ # Net::HTTP::Get.should_receive(:new).with(@uris[type], @header).and_return(@request)
96
+ # @client.send(:timeline, type)
97
+ # }.should raise_error(Twitter::RESTError)
98
+ # end
99
+ # end
100
+ #end
101
+
102
+ #describe "Twitter::Client#timeline_request upon 500 HTTP response" do
103
+ # before(:each) do
104
+ # @request = mas_net_http_get(:basic_auth => nil)
105
+ # @response = mas_net_http_response(:server_error)
106
+ #
107
+ # @http = mas_net_http(@response)
108
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
109
+ # @header = @client.send(:http_header)
110
+ # @uris = Twitter::Client.class_eval("@@URIS")
111
+ # end
112
+
113
+ # it "should make GET HTTP request to appropriate URL" do
114
+ # @uris.keys.each do |type|
115
+ # lambda do
116
+ # Net::HTTP::Get.should_receive(:new).with(@uris[type], @header).and_return(@request)
117
+ # @client.send(:timeline, type)
118
+ # end.should raise_error(Twitter::RESTError)
119
+ # end
120
+ # end
121
+ #end
122
+
123
+ #describe "Twitter::Client#timeline_request upon 404 HTTP response" do
124
+ # before(:each) do
125
+ # @request = mas_net_http_get(:basic_auth => nil)
126
+ # @response = mas_net_http_response(:file_not_found)
127
+ # @http = mas_net_http(@response)
128
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
129
+ # @header = @client.send(:http_header)
130
+ # @uris = Twitter::Client.class_eval("@@URIS")
131
+ # end
132
+ #
133
+ # it "should make GET HTTP request to appropriate URL" do
134
+ # @uris.keys.each do |type|
135
+ # lambda {
136
+ # Net::HTTP::Get.should_receive(:new).with(@uris[type], @header).and_return(@request)
137
+ # @client.send(:timeline, type)
138
+ # }.should raise_error(Twitter::RESTError)
139
+ # end
140
+ # end
141
+ #end
142
+
143
+ #describe "Twitter::Client#timeline(:public)" do
144
+ # before(:each) do
145
+ # @host = 'twitter.com'
146
+ # @port = 443
147
+ # @protocol = :http
148
+ # @proxy_host = 'myproxy.host'
149
+ # @proxy_port = 8080
150
+ #
151
+ # Twitter::Client.configure do |conf|
152
+ # conf.host = @host
153
+ # conf.port = @port
154
+ # conf.protocol = @protocol
155
+ # conf.proxy_host = @proxy_host
156
+ # conf.proxy_port = @proxy_port
157
+ # end
158
+ #
159
+ # @request = mas_net_http_get(:basic_auth => nil)
160
+ # @response = mas_net_http_response(:success, '[]')
161
+ #
162
+ # @http = mas_net_http(@response)
163
+ # @client = Twitter::Client.from_config 'config/twitter.yml'
164
+ # @login = @client.instance_eval("@login")
165
+ # @password = @client.instance_eval("@password")
166
+ # end
167
+ #
168
+ # it "should connect to the Twitter service via HTTP connection" do
169
+ # Net::HTTP.should_receive(:new).with(@host, @port, @proxy_host, @proxy_port).once.and_return(@http)
170
+ # @client.timeline(:public)
171
+ # end
172
+ #
173
+ # it " should send HTTP Basic Authentication credentials" do
174
+ # @request.should_receive(:basic_auth).with(@login, @password).once
175
+ # @client.timeline(:public)
176
+ # end
177
+ #end
@@ -0,0 +1,42 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Hash, "#to_http_str" do
4
+ before(:each) do
5
+ @http_params = {:id => 'otherlogin', :since_id => 3953743, :full_name => 'Lucy Cross'}
6
+ @id_regexp = Regexp.new("id=#{URI.encode(@http_params[:id].to_s)}")
7
+ @since_id_regexp = Regexp.new("since_id=#{URI.encode(@http_params[:since_id].to_s)}")
8
+ @full_name_regexp = Regexp.new("full_name=#{URI.encode(@http_params[:full_name].to_s)}")
9
+ end
10
+
11
+ it "should generate expected URL encoded string" do
12
+ http_str = @http_params.to_http_str
13
+ http_str.should match(@id_regexp)
14
+ http_str.should match(@since_id_regexp)
15
+ http_str.should match(@full_name_regexp)
16
+ end
17
+
18
+ after(:each) do
19
+ @http_params = nil
20
+ @id_kv_str, @since_id_kv_str, @full_name_kv_str = nil
21
+ end
22
+ end
23
+
24
+ describe Time, "#to_s" do
25
+ before(:each) do
26
+ @time = Time.now
27
+ @expected_string = @time.rfc2822
28
+ end
29
+
30
+ it "should output RFC2822 compliant string" do
31
+ time_string = @time.to_s
32
+ time_string.should eql(@expected_string)
33
+ end
34
+
35
+ it "should respond to #old_to_s" do
36
+ @time.should respond_to(:old_to_s)
37
+ end
38
+
39
+ after(:each) do
40
+ nilize(@time, @expected_string)
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Twitter::Client, "#featured(:users)" do
4
+ before(:each) do
5
+ @twitter = client_context
6
+ @uris = Twitter::Client.class_eval("@@FEATURED_URIS")
7
+ @request = mas_net_http_get(:basic_auth => nil)
8
+ @response = mas_net_http_response(:success)
9
+ @connection = mas_net_http(@response)
10
+ Net::HTTP.stub!(:new).and_return(@connection)
11
+ @users = [
12
+ Twitter::User.new(:screen_name => 'twitter4r'),
13
+ Twitter::User.new(:screen_name => 'dictionary'),
14
+ ]
15
+ Twitter::User.stub!(:unmarshal).and_return(@users)
16
+ end
17
+
18
+ it "should create expected HTTP GET request" do
19
+ @twitter.should_receive(:create_http_get_request).with(@uris[:users]).and_return(@request)
20
+ @twitter.featured(:users)
21
+ end
22
+
23
+ it "should bless Twitter::User models returned" do
24
+ @twitter.should_receive(:bless_models).with(@users).and_return(@users)
25
+ @twitter.featured(:users)
26
+ end
27
+
28
+ after(:each) do
29
+ nilize(@twitter, @uris, @request, @response, @connection)
30
+ end
31
+ end
32
+
33
+ describe Twitter::User, ".featured" do
34
+ before(:each) do
35
+ @twitter = client_context
36
+ end
37
+
38
+ it "should delegate #featured(:users) message to given client context" do
39
+ @twitter.should_receive(:featured).with(:users).and_return([])
40
+ Twitter::User.featured(@twitter)
41
+ end
42
+
43
+ after(:each) do
44
+ nilize(@twitter)
45
+ end
46
+ end