twitter4r 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/twitter/core.rb CHANGED
@@ -40,8 +40,9 @@ module Twitter
40
40
  def eql?(obj)
41
41
  [:id, :name, :description, :location,
42
42
  :screen_name, :url].each do |att|
43
- return false if self.send(att).eql?(obj.send(att))
44
- end or true
43
+ return false unless self.send(att).eql?(obj.send(att))
44
+ end
45
+ true
45
46
  end
46
47
  end # User
47
48
 
@@ -52,8 +53,9 @@ module Twitter
52
53
 
53
54
  def eql?(obj)
54
55
  [:id, :text, :created_at, :user].each do |att|
55
- return false if self.send(att).eql?(obj.send(att))
56
- end or true
56
+ return false unless self.send(att).eql?(obj.send(att))
57
+ end
58
+ true
57
59
  end
58
60
  end # Status
59
61
 
@@ -62,9 +64,11 @@ module Twitter
62
64
  include ClassUtilMixin
63
65
  attr_accessor :login, :password
64
66
 
65
- @@HOST = 'twitter.com'
66
- @@PORT = 80
67
- @@SSL = false
67
+ @@CONF = {
68
+ :host => 'twitter.com',
69
+ :port => 80,
70
+ :ssl => false,
71
+ }
68
72
  @@URIS = {:public => '/statuses/public_timeline.json',
69
73
  :friends => '/statuses/friends_timeline.json',
70
74
  :friends_statues => '/statuses/friends.json',
@@ -73,10 +77,16 @@ module Twitter
73
77
  :send_direct_message => '/direct_messages/new.json', }
74
78
 
75
79
  class << self
80
+ # The following configuration options can be passed in a hash to this method:
81
+ # * <tt>host</tt> - host of the REST server, defaults to twitter.com. Should only be changed for integration testing.
82
+ # * <tt>port</tt> - port of the REST server, defaults to 443.
83
+ # * <tt>ssl</tt> - SSL flag, defaults to false. Do not use :use_ssl anymore.
84
+ # * <tt>proxy_host</tt> - proxy host. No default.
85
+ # * <tt>proxy_port</tt> - proxy port. No default.
86
+ # * <tt>proxy_user</tt> - proxy username. No default.
87
+ # * <tt>proxy_pass</tt> - proxy password. No default.
76
88
  def config(conf)
77
- @@HOST = conf[:host] if conf[:host]
78
- @@PORT = conf[:port] if conf[:port]
79
- @@SSL = conf[:use_ssl] if conf[:use_ssl] # getting ready for SSL support
89
+ @@CONF.merge!(conf)
80
90
  end
81
91
 
82
92
  # Mostly helper method for irb shell prototyping
@@ -88,7 +98,7 @@ module Twitter
88
98
  end # class << self
89
99
 
90
100
  def timeline(type = :public)
91
- http = Net::HTTP.new(@@HOST, @@PORT)
101
+ http = create_http_connection
92
102
  http.start do |http|
93
103
  timeline_request(type, http)
94
104
  end # http.start block
@@ -112,7 +122,7 @@ module Twitter
112
122
 
113
123
  def update(message)
114
124
  uri = @@URIS[:update]
115
- http = Net::HTTP.new(@@HOST, @@PORT)
125
+ http = create_http_connection
116
126
  http.start do |http|
117
127
  request = Net::HTTP::Post.new(uri)
118
128
  request.basic_auth(@login, @password)
@@ -124,7 +134,7 @@ module Twitter
124
134
  def send_direct_message(user, message)
125
135
  login = user.respond_to?(:screen_name) ? user.screen_name : user
126
136
  uri = @@URIS[:send_direct_message]
127
- http = Net::HTTP.new(@@HOST, @@PORT)
137
+ http = create_http_connection
128
138
  http.start do |http|
129
139
  request = Net::HTTP::Post.new(uri)
130
140
  request.basic_auth(@login, @password)
@@ -164,6 +174,15 @@ module Twitter
164
174
  unmarshall_statuses(JSON.parse(response.body))
165
175
  end
166
176
 
177
+ def create_http_connection
178
+ conn = Net::HTTP.new(@@CONF[:host], @@CONF[:port],
179
+ @@CONF[:proxy_host], @@CONF[:proxy_port],
180
+ @@CONF[:proxy_user], @@CONF[:proxy_pass])
181
+ conn.use_ssl = @@CONF[:ssl]
182
+ conn.verify_mode = OpenSSL::SSL::VERIFY_NONE if @@CONF[:ssl]
183
+ conn
184
+ end
185
+
167
186
  def raise_rest_error(response, uri = nil)
168
187
  raise RESTError.new(:code => response.code,
169
188
  :message => response.message,
data/lib/twitter/meta.rb CHANGED
@@ -3,7 +3,7 @@ require('erb')
3
3
 
4
4
  class Twitter::Meta #:nodoc:
5
5
  attr_accessor :root_dir
6
- attr_reader :pkg_info, :gem_spec, :project_files, :spec_files
6
+ attr_reader :gem_spec, :project_files, :spec_files
7
7
 
8
8
  def initialize(root_dir)
9
9
  @root_dir = root_dir
@@ -39,4 +39,3 @@ class Twitter::Meta #:nodoc:
39
39
  @gem_spec
40
40
  end
41
41
  end
42
-
@@ -1,7 +1,7 @@
1
1
  module Twitter::Version #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- REVISION = 0
4
+ REVISION = 1
5
5
  class << self
6
6
  def to_version
7
7
  "#{MAJOR}.#{MINOR}.#{REVISION}"
data/spec/spec_helper.rb CHANGED
@@ -16,6 +16,8 @@ def stubbed_net_http(response, obj_stubs = {}, host = 'twitter.com', port = 80)
16
16
  http = Net::HTTP.new(host, port)
17
17
  Net::HTTP.stub!(:new).and_return(http)
18
18
  http.stub!(:request).and_return(response)
19
+ http.stub!(:use_ssl=)
20
+ http.stub!(:verify_mode=)
19
21
  http
20
22
  end
21
23
 
@@ -27,6 +29,8 @@ def mas_net_http(response)
27
29
  Net::HTTP.stub!(:new).and_return(http)
28
30
  http.stub!(:request).and_return(response)
29
31
  http.stub!(:start).and_yield(http)
32
+ http.stub!(:use_ssl=)
33
+ http.stub!(:verify_mode=)
30
34
  http
31
35
  end
32
36
 
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
2
 
3
- context "Twitter::ClassUtilMixin mixed-in class" do
4
- setup do
3
+ describe "Twitter::ClassUtilMixin mixed-in class" do
4
+ before(:each) do
5
5
  class TestClass
6
6
  include Twitter::ClassUtilMixin
7
7
  attr_accessor :var1, :var2, :var3
@@ -9,78 +9,96 @@ context "Twitter::ClassUtilMixin mixed-in class" do
9
9
  @init_hash = { :var1 => 'val1', :var2 => 'val2', :var3 => 'val3' }
10
10
  end
11
11
 
12
- specify "should have Twitter::ClassUtilMixin as an included module" do
13
- TestClass.included_modules.member?(Twitter::ClassUtilMixin).should.eql true
12
+ it "should have Twitter::ClassUtilMixin as an included module" do
13
+ TestClass.included_modules.member?(Twitter::ClassUtilMixin).should be(true)
14
14
  end
15
15
 
16
- specify "should set attributes passed in the hash to TestClass.new" do
16
+ it "should set attributes passed in the hash to TestClass.new" do
17
17
  test = TestClass.new(@init_hash)
18
18
  @init_hash.each do |key, val|
19
- test.send(key).should.eql val
19
+ test.send(key).should eql(val)
20
20
  end
21
21
  end
22
22
 
23
- specify "should not set attributes passed in the hash that are not attributes in TestClass.new" do
23
+ it "should not set attributes passed in the hash that are not attributes in TestClass.new" do
24
24
  test = nil
25
- lambda { test = TestClass.new(@init_hash.merge(:var4 => 'val4')) }.should_not_raise
26
- test.respond_to?(:var4).should.eql false
25
+ lambda { test = TestClass.new(@init_hash.merge(:var4 => 'val4')) }.should_not raise_error
26
+ test.respond_to?(:var4).should be(false)
27
27
  end
28
28
  end
29
29
 
30
- context "Twitter::RESTError#to_s" do
31
- setup do
30
+ describe "Twitter::RESTError#to_s" do
31
+ before(:each) do
32
32
  @hash = { :code => 200, :message => 'OK', :uri => 'http://test.host/bla' }
33
33
  @error = Twitter::RESTError.new(@hash)
34
34
  @expected_message = "HTTP #{@hash[:code]}: #{@hash[:message]} at #{@hash[:uri]}"
35
35
  end
36
36
 
37
- specify "should return @expected_message" do
38
- @error.to_s.should.eql @expected_message
37
+ it "should return @expected_message" do
38
+ @error.to_s.should eql(@expected_message)
39
39
  end
40
40
  end
41
41
 
42
- context "Twitter::Client" do
43
- setup do
42
+ describe "Twitter::Client" do
43
+ before(:each) do
44
44
  @init_hash = { :login => 'user', :password => 'pass' }
45
45
  end
46
46
 
47
- specify ".new should accept login and password as initializer hash keys and set the values to instance values" do
47
+ it ".new should accept login and password as initializer hash keys and set the values to instance values" do
48
48
  client = nil
49
49
  lambda do
50
50
  client = Twitter::Client.new(@init_hash)
51
- end.should_not_raise
52
- client.send(:login).should.eql @init_hash[:login]
53
- client.send(:password).should.eql @init_hash[:password]
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
54
  end
55
55
  end
56
56
 
57
- context "Twitter::Client.config" do
58
- setup do
57
+ describe "Twitter::Client.config" do
58
+ before(:each) do
59
59
  @config_hash = { :host => 'test.host',
60
60
  :port => 443,
61
- :use_ssl => true, }
61
+ :ssl => true,
62
+ :proxy_host => 'myproxy.host',
63
+ :proxy_port => 8080,
64
+ :proxy_user => 'myproxyuser',
65
+ :proxy_pass => 'myproxypass',
66
+ }
62
67
  end
63
68
 
64
- specify "should override @@HOST and @@PORT if supplied" do
69
+ it "should override @@CONF values if supplied" do
65
70
  Twitter::Client.config @config_hash
66
- host = Twitter::Client.class_eval("@@HOST")
67
- host.should.eql @config_hash[:host]
68
- port = Twitter::Client.class_eval("@@PORT")
69
- port.should.eql @config_hash[:port]
70
- ssl = Twitter::Client.class_eval("@@SSL")
71
- ssl.should.eql @config_hash[:use_ssl]
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
+
72
86
  end
73
87
 
74
- teardown do
88
+ after(:each) do
75
89
  Twitter::Client.config :host => 'twitter.com', :port => 80, :use_ssl => false
76
90
  end
77
91
  end
78
92
 
79
- context "Twitter::Client#timeline(:public)" do
80
- setup do
93
+ describe "Twitter::Client#timeline(:public)" do
94
+ before(:each) do
81
95
  Twitter::Client.config(:port => 443, :use_ssl => false)
82
- @host = Twitter::Client.class_eval("@@HOST")
83
- @port = Twitter::Client.class_eval("@@PORT")
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]")
84
102
 
85
103
  @request = mas_net_http_get(:basic_auth => nil)
86
104
  @response = mas_net_http_response(:success, '[]')
@@ -91,19 +109,19 @@ context "Twitter::Client#timeline(:public)" do
91
109
  @password = @client.instance_eval("@password")
92
110
  end
93
111
 
94
- specify "should connect to the Twitter service via HTTP connection" do
95
- Net::HTTP.should_receive(:new).with(@host, @port).once.and_return(@http)
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)
96
114
  @client.timeline(:public)
97
115
  end
98
116
 
99
- specify " should send HTTP Basic Authentication credentials" do
117
+ it " should send HTTP Basic Authentication credentials" do
100
118
  @request.should_receive(:basic_auth).with(@login, @password).once
101
119
  @client.timeline(:public)
102
120
  end
103
121
  end
104
122
 
105
- context "Twitter::Client#unmarshall_statuses" do
106
- setup do
123
+ describe "Twitter::Client#unmarshall_statuses" do
124
+ before(:each) do
107
125
  @json_hash = { "text" => "Thinking Zipcar is lame...",
108
126
  "id" => 46672912,
109
127
  "user" => {"name" => "Angie",
@@ -121,15 +139,15 @@ context "Twitter::Client#unmarshall_statuses" do
121
139
  @client = Twitter::Client.from_config 'config/twitter.yml'
122
140
  end
123
141
 
124
- specify "should return expected populated Twitter::Status object values in an Array" do
142
+ it "should return expected populated Twitter::Status object values in an Array" do
125
143
  statuses = @client.send(:unmarshall_statuses, [@json_hash])
126
- statuses.should.have(1)
144
+ statuses.should have(1).entries
127
145
  statuses.first.should.eql? @status
128
146
  end
129
147
  end
130
148
 
131
- context "Twitter::Client#unmarshall_user" do
132
- setup do
149
+ describe "Twitter::Client#unmarshall_user" do
150
+ before(:each) do
133
151
  @json_hash = { "name" => "Lucy Snowe",
134
152
  "description" => "School Mistress Entrepreneur",
135
153
  "location" => "Villette",
@@ -141,14 +159,14 @@ context "Twitter::Client#unmarshall_user" do
141
159
  @client = Twitter::Client.from_config 'config/twitter.yml'
142
160
  end
143
161
 
144
- specify "should return expected populated Twitter::User object value" do
162
+ it "should return expected populated Twitter::User object value" do
145
163
  user = @client.send(:unmarshall_user, @json_hash)
146
164
  user.should.eql? @user
147
165
  end
148
166
  end
149
167
 
150
- context "Twitter::Client#timeline_request upon 200 HTTP response" do
151
- setup do
168
+ describe "Twitter::Client#timeline_request upon 200 HTTP response" do
169
+ before(:each) do
152
170
  @request = mas_net_http_get :basic_auth => nil
153
171
  @response = mas_net_http_response # defaults to :success
154
172
 
@@ -159,7 +177,7 @@ context "Twitter::Client#timeline_request upon 200 HTTP response" do
159
177
  JSON.stub!(:parse).and_return({})
160
178
  end
161
179
 
162
- specify "should make GET HTTP request to appropriate URL" do
180
+ it "should make GET HTTP request to appropriate URL" do
163
181
  @uris.keys.each do |type|
164
182
  Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
165
183
  @client.send(:timeline_request, type, @http)
@@ -167,8 +185,8 @@ context "Twitter::Client#timeline_request upon 200 HTTP response" do
167
185
  end
168
186
  end
169
187
 
170
- context "Twitter::Client#timeline_request upon 403 HTTP response" do
171
- setup do
188
+ describe "Twitter::Client#timeline_request upon 403 HTTP response" do
189
+ before(:each) do
172
190
  @request = mas_net_http_get :basic_auth => nil
173
191
  @response = mas_net_http_response :not_authorized
174
192
 
@@ -177,18 +195,18 @@ context "Twitter::Client#timeline_request upon 403 HTTP response" do
177
195
  @uris = Twitter::Client.class_eval("@@URIS")
178
196
  end
179
197
 
180
- specify "should make GET HTTP request to appropriate URL" do
198
+ it "should make GET HTTP request to appropriate URL" do
181
199
  @uris.keys.each do |type|
182
200
  lambda do
183
201
  Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
184
202
  @client.send(:timeline_request, type, @http)
185
- end.should_raise(Twitter::RESTError)
203
+ end.should raise_error(Twitter::RESTError)
186
204
  end
187
205
  end
188
206
  end
189
207
 
190
- context "Twitter::Client#timeline_request upon 500 HTTP response" do
191
- setup do
208
+ describe "Twitter::Client#timeline_request upon 500 HTTP response" do
209
+ before(:each) do
192
210
  @request = mas_net_http_get(:basic_auth => nil)
193
211
  @response = mas_net_http_response(:server_error)
194
212
 
@@ -197,18 +215,18 @@ context "Twitter::Client#timeline_request upon 500 HTTP response" do
197
215
  @uris = Twitter::Client.class_eval("@@URIS")
198
216
  end
199
217
 
200
- specify "should make GET HTTP request to appropriate URL" do
218
+ it "should make GET HTTP request to appropriate URL" do
201
219
  @uris.keys.each do |type|
202
220
  lambda do
203
221
  Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
204
222
  @client.send(:timeline_request, type, @http)
205
- end.should_raise(Twitter::RESTError)
223
+ end.should raise_error(Twitter::RESTError)
206
224
  end
207
225
  end
208
226
  end
209
227
 
210
- context "Twitter::Client#timeline_request upon 404 HTTP response" do
211
- setup do
228
+ describe "Twitter::Client#timeline_request upon 404 HTTP response" do
229
+ before(:each) do
212
230
  @request = mas_net_http_get(:basic_auth => nil)
213
231
  @response = mas_net_http_response(:file_not_found)
214
232
 
@@ -217,18 +235,18 @@ context "Twitter::Client#timeline_request upon 404 HTTP response" do
217
235
  @uris = Twitter::Client.class_eval("@@URIS")
218
236
  end
219
237
 
220
- specify "should make GET HTTP request to appropriate URL" do
238
+ it "should make GET HTTP request to appropriate URL" do
221
239
  @uris.keys.each do |type|
222
240
  lambda do
223
241
  Net::HTTP::Get.should_receive(:new).with(@uris[type]).and_return(@request)
224
242
  @client.send(:timeline_request, type, @http)
225
- end.should_raise(Twitter::RESTError)
243
+ end.should raise_error(Twitter::RESTError)
226
244
  end
227
245
  end
228
246
  end
229
247
 
230
- context "Twitter::Client#update(msg) upon 200 HTTP response" do
231
- setup do
248
+ describe "Twitter::Client#update(msg) upon 200 HTTP response" do
249
+ before(:each) do
232
250
  @request = mas_net_http_post(:basic_auth => nil)
233
251
  @response = mas_net_http_response
234
252
 
@@ -239,14 +257,14 @@ context "Twitter::Client#update(msg) upon 200 HTTP response" do
239
257
  @message = "We love Jodhi May!"
240
258
  end
241
259
 
242
- specify "should make POST HTTP request to appropriate URL" do
260
+ it "should make POST HTTP request to appropriate URL" do
243
261
  Net::HTTP::Post.should_receive(:new).with(@expected_uri).and_return(@request)
244
262
  @client.update(@message)
245
263
  end
246
264
  end
247
265
 
248
- context "Twitter::Client#update(msg) upon 500 HTTP response" do
249
- setup do
266
+ describe "Twitter::Client#update(msg) upon 500 HTTP response" do
267
+ before(:each) do
250
268
  @request = mas_net_http_post(:basic_auth => nil)
251
269
  @response = mas_net_http_response(:server_error)
252
270
 
@@ -257,16 +275,16 @@ context "Twitter::Client#update(msg) upon 500 HTTP response" do
257
275
  @message = "We love Jodhi May!"
258
276
  end
259
277
 
260
- specify "should make POST HTTP request to appropriate URL" do
278
+ it "should make POST HTTP request to appropriate URL" do
261
279
  lambda do
262
280
  Net::HTTP::Post.should_receive(:new).with(@expected_uri).and_return(@request)
263
281
  @client.update(@message)
264
- end.should_raise(Twitter::RESTError)
282
+ end.should raise_error(Twitter::RESTError)
265
283
  end
266
284
  end
267
285
 
268
- context "Twitter::Client#public_timeline" do
269
- setup do
286
+ describe "Twitter::Client#public_timeline" do
287
+ before(:each) do
270
288
  @request = mas_net_http_get(:basic_auth => nil)
271
289
  @response = mas_net_http_response
272
290
 
@@ -274,14 +292,14 @@ context "Twitter::Client#public_timeline" do
274
292
  @client = Twitter::Client.from_config 'config/twitter.yml'
275
293
  end
276
294
 
277
- specify "should delegate work to Twitter::Client#public(:public)" do
295
+ it "should delegate work to Twitter::Client#public(:public)" do
278
296
  @client.should_receive(:timeline).with(:public).once
279
297
  @client.public_timeline
280
298
  end
281
299
  end
282
300
 
283
- context "Twitter::Client#friend_timeline" do
284
- setup do
301
+ describe "Twitter::Client#friend_timeline" do
302
+ before(:each) do
285
303
  @request = mas_net_http_get(:basic_auth => nil)
286
304
  @response = mas_net_http_response
287
305
 
@@ -289,14 +307,14 @@ context "Twitter::Client#friend_timeline" do
289
307
  @client = Twitter::Client.from_config 'config/twitter.yml'
290
308
  end
291
309
 
292
- specify "should delegate work to Twitter::Client#public(:friends)" do
310
+ it "should delegate work to Twitter::Client#public(:friends)" do
293
311
  @client.should_receive(:timeline).with(:friends).once
294
312
  @client.friend_timeline
295
313
  end
296
314
  end
297
315
 
298
- context "Twitter::Client#friend_statuses" do
299
- setup do
316
+ describe "Twitter::Client#friend_statuses" do
317
+ before(:each) do
300
318
  @request = mas_net_http_get(:basic_auth => nil)
301
319
  @response = mas_net_http_response
302
320
 
@@ -304,14 +322,14 @@ context "Twitter::Client#friend_statuses" do
304
322
  @client = Twitter::Client.from_config 'config/twitter.yml'
305
323
  end
306
324
 
307
- specify "should delegate work to Twitter::Client#public(:friends_statuses)" do
325
+ it "should delegate work to Twitter::Client#public(:friends_statuses)" do
308
326
  @client.should_receive(:timeline).with(:friends_statuses).once
309
327
  @client.friend_statuses
310
328
  end
311
329
  end
312
330
 
313
- context "Twitter::Client#follower_statuses" do
314
- setup do
331
+ describe "Twitter::Client#follower_statuses" do
332
+ before(:each) do
315
333
  @request = mas_net_http_get(:basic_auth => nil)
316
334
  @response = mas_net_http_response
317
335
 
@@ -319,14 +337,14 @@ context "Twitter::Client#follower_statuses" do
319
337
  @client = Twitter::Client.from_config 'config/twitter.yml'
320
338
  end
321
339
 
322
- specify "should delegate work to Twitter::Client#public(:followers)" do
340
+ it "should delegate work to Twitter::Client#public(:followers)" do
323
341
  @client.should_receive(:timeline).with(:followers).once
324
342
  @client.follower_statuses
325
343
  end
326
344
  end
327
345
 
328
- context "Twitter::Client#send_direct_message" do
329
- setup do
346
+ describe "Twitter::Client#send_direct_message" do
347
+ before(:each) do
330
348
  @request = mas_net_http_post(:basic_auth => nil)
331
349
  @response = mas_net_http_response
332
350
 
@@ -344,29 +362,29 @@ context "Twitter::Client#send_direct_message" do
344
362
  @expected_params = "user=#{@user.screen_name}&text=#{URI.escape(@message)}"
345
363
  end
346
364
 
347
- specify "should convert given Twitter::User object to screen name" do
365
+ it "should convert given Twitter::User object to screen name" do
348
366
  @user.should_receive(:screen_name).once
349
367
  @client.send_direct_message(@user, @message)
350
368
  end
351
369
 
352
- specify "should POST to expected URI" do
370
+ it "should POST to expected URI" do
353
371
  Net::HTTP::Post.should_receive(:new).with(@expected_uri).once.and_return(@request)
354
372
  @client.send_direct_message(@user, @message)
355
373
  end
356
374
 
357
- specify "should login via HTTP Basic Authentication using expected credentials" do
375
+ it "should login via HTTP Basic Authentication using expected credentials" do
358
376
  @request.should_receive(:basic_auth).with(@login, @password).once
359
377
  @client.send_direct_message(@user, @message)
360
378
  end
361
379
 
362
- specify "should make POST request with expected URI escaped parameters" do
380
+ it "should make POST request with expected URI escaped parameters" do
363
381
  @http.should_receive(:request).with(@request, @expected_params).once.and_return(@response)
364
382
  @client.send_direct_message(@user, @message)
365
383
  end
366
384
  end
367
385
 
368
- context "Twitter::Status#eql?" do
369
- setup do
386
+ describe "Twitter::Status#eql?" do
387
+ before(:each) do
370
388
  @attr_hash = { :text => 'Status', :id => 34329594003,
371
389
  :user => { :name => 'Tess',
372
390
  :description => "Unfortunate D'Urberville",
@@ -379,27 +397,27 @@ context "Twitter::Status#eql?" do
379
397
  @other = Twitter::Status.new @attr_hash
380
398
  end
381
399
 
382
- specify "should return true when non-transient object attributes are eql?" do
400
+ it "should return true when non-transient object attributes are eql?" do
383
401
  @obj.should.eql? @other
384
402
  @obj.eql?(@other).should.eql? true # for the sake of getting rcov to recognize this method is covered in the specs
385
403
  end
386
404
 
387
- specify "should return false when not all non-transient object attributes are eql?" do
405
+ it "should return false when not all non-transient object attributes are eql?" do
388
406
  @other.created_at = Time.now.to_s
389
- @obj.should.not.eql? @other
390
- @obj.eql?(@other).should.eql? false # for the sake of getting rcov to recognize this method is covered in the specs
407
+ @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
391
409
  end
392
410
 
393
- specify "should return true when comparing same object to itself" do
394
- @obj.should.eql? @obj
395
- @obj.eql?(@obj).should.eql? true # for the sake of getting rcov to recognize this method is covered in the specs
396
- @other.should.eql? @other
397
- @other.eql?(@other).should.eql? true # for the sake of getting rcov to recognize this method is covered in the specs
411
+ it "should return true when comparing same object to itself" do
412
+ @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
+ @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
398
416
  end
399
417
  end
400
418
 
401
- context "Twitter::User#eql?" do
402
- setup do
419
+ describe "Twitter::User#eql?" do
420
+ before(:each) do
403
421
  @attr_hash = { :name => 'Elizabeth Jane Newson-Henshard',
404
422
  :description => "Wronged 'Daughter'",
405
423
  :location => 'Casterbridge',
@@ -410,21 +428,21 @@ context "Twitter::User#eql?" do
410
428
  @other = Twitter::User.new @attr_hash
411
429
  end
412
430
 
413
- specify "should return true when non-transient object attributes are eql?" do
414
- @obj.should.eql? @other
415
- @obj.eql?(@other).should.eql? true
431
+ it "should return true when non-transient object attributes are eql?" do
432
+ @obj.should eql(@other)
433
+ @obj.eql?(@other).should be(true)
416
434
  end
417
435
 
418
- specify "should return false when not all non-transient object attributes are eql?" do
436
+ it "should return false when not all non-transient object attributes are eql?" do
419
437
  @other.id = 1
420
- @obj.should.not.eql? @other
421
- @obj.eql?(@other).should.eql? false
438
+ @obj.should_not eql(@other)
439
+ @obj.eql?(@other).should be(false)
422
440
  end
423
441
 
424
- specify "should return true when comparing same object to itself" do
425
- @obj.should.eql? @obj
426
- @obj.eql?(@obj).should.eql? true
427
- @other.should.eql? @other
428
- @obj.eql?(@obj).should.eql? true
442
+ it "should return true when comparing same object to itself" do
443
+ @obj.should eql(@obj)
444
+ @obj.eql?(@obj).should be(true)
445
+ @other.should eql(@other)
446
+ @obj.eql?(@obj).should be(true)
429
447
  end
430
448
  end
@@ -21,9 +21,10 @@ module ERBMetaMixin
21
21
  end
22
22
  end
23
23
 
24
- context "Twitter::Meta cache policy" do
24
+ describe "Twitter::Meta cache policy" do
25
25
  include ERBMetaMixin
26
- setup do
26
+ include ERBMetaMixin
27
+ before(:each) do
27
28
  @root_dir = project_root_dir
28
29
  @meta = Twitter::Meta.new(@root_dir)
29
30
  @expected_pkg_info = load_erb_yaml(File.join(@root_dir, 'pkg-info.yml'), binding)
@@ -31,34 +32,26 @@ context "Twitter::Meta cache policy" do
31
32
  @expected_spec_files = spec_files
32
33
  end
33
34
 
34
- specify "should store value returned from pkg_info in @pkg_info after first YAML load" do
35
- @meta.instance_eval("@pkg_info").should.eql?(nil)
36
- @meta.pkg_info
37
- @meta.instance_eval("@pkg_info").should_eql?(@expected_pkg_info)
38
- @meta.pkg_info
39
- @meta.instance_eval("@pkg_info").should_eql?(@expected_pkg_info)
40
- end
41
-
42
- specify "should store value returned from project_files in @project_files after first glob" do
43
- @meta.instance_eval("@project_files").should.eql?(nil)
35
+ it "should store value returned from project_files in @project_files after first glob" do
36
+ @meta.instance_eval("@project_files").should be(nil)
44
37
  @meta.project_files
45
- @meta.instance_eval("@project_files").should.eql?(@expected_project_files)
38
+ @meta.instance_eval("@project_files").should eql(@expected_project_files)
46
39
  @meta.project_files
47
- @meta.instance_eval("@project_files").should.eql?(@expected_project_files)
40
+ @meta.instance_eval("@project_files").should eql(@expected_project_files)
48
41
  end
49
42
 
50
- specify "should store value returned from spec_files in @spec_files after first glob" do
51
- @meta.instance_eval("@spec_files").should.eql?(nil)
43
+ it "should store value returned from spec_files in @spec_files after first glob" do
44
+ @meta.instance_eval("@spec_files").should be(nil)
52
45
  @meta.spec_files
53
- @meta.instance_eval("@spec_files").should.eql?(@expected_spec_files)
46
+ @meta.instance_eval("@spec_files").should eql(@expected_spec_files)
54
47
  @meta.spec_files
55
- @meta.instance_eval("@spec_files").should.eql?(@expected_spec_files)
48
+ @meta.instance_eval("@spec_files").should eql(@expected_spec_files)
56
49
  end
57
50
  end
58
51
 
59
- context "Twitter::Meta" do
52
+ describe "Twitter::Meta" do
60
53
  include ERBMetaMixin
61
- setup do
54
+ before(:each) do
62
55
  @root_dir = project_root_dir
63
56
  @meta = Twitter::Meta.new(@root_dir)
64
57
  @expected_yaml_hash = load_erb_yaml(File.join(@root_dir, 'pkg-info.yml'), binding)
@@ -66,27 +59,27 @@ context "Twitter::Meta" do
66
59
  @expected_spec_files = spec_files
67
60
  end
68
61
 
69
- specify "should load and return YAML file into Hash object upon #pkg_info call" do
62
+ it "should load and return YAML file into Hash object upon #pkg_info call" do
70
63
  yaml_hash = @meta.pkg_info
71
64
  yaml_hash.should.eql? @expected_yaml_hash
72
65
  end
73
66
 
74
- specify "should return the embedded hash responding to key 'spec' of #pkg_info call upon #spec_info call" do
67
+ it "should return the embedded hash responding to key 'spec' of #pkg_info call upon #spec_info call" do
75
68
  yaml_hash = @meta.spec_info
76
69
  yaml_hash.should.eql? @expected_yaml_hash['spec']
77
70
  end
78
71
 
79
- specify "should return list of files matching ROOT_DIR/lib/**/*.rb upon #project_files call" do
72
+ it "should return list of files matching ROOT_DIR/lib/**/*.rb upon #project_files call" do
80
73
  project_files = @meta.project_files
81
74
  project_files.should.eql? @expected_project_files
82
75
  end
83
76
 
84
- specify "should return list of files matching ROOT_DIR/spec/**/*.rb upon #spec_files call" do
77
+ it "should return list of files matching ROOT_DIR/spec/**/*.rb upon #spec_files call" do
85
78
  spec_files = @meta.spec_files
86
79
  spec_files.should.eql? @expected_spec_files
87
80
  end
88
81
 
89
- specify "should return Gem specification based on YAML file contents and #project_files and #spec_files return values" do
82
+ it "should return Gem specification based on YAML file contents and #project_files and #spec_files return values" do
90
83
  spec = @meta.gem_spec
91
84
  expected_spec_hash = @expected_yaml_hash['spec']
92
85
  expected_spec_hash.each do |key, val|
@@ -5,15 +5,15 @@ VERSION_LIST = [Twitter::Version::MAJOR, Twitter::Version::MINOR, Twitter::Versi
5
5
  EXPECTED_VERSION = VERSION_LIST.join('.')
6
6
  EXPECTED_NAME = VERSION_LIST.join('_')
7
7
 
8
- context "Twitter::Version.to_version" do
9
- specify "should return #{EXPECTED_VERSION}" do
10
- Twitter::Version.to_version.should.eql EXPECTED_VERSION
8
+ describe "Twitter::Version.to_version" do
9
+ it "should return #{EXPECTED_VERSION}" do
10
+ Twitter::Version.to_version.should eql(EXPECTED_VERSION)
11
11
  end
12
12
  end
13
13
 
14
- context "Twitter::Version.to_name" do
15
- specify "should return #{EXPECTED_NAME}" do
16
- Twitter::Version.to_name.should.eql EXPECTED_NAME
14
+ describe "Twitter::Version.to_name" do
15
+ it "should return #{EXPECTED_NAME}" do
16
+ Twitter::Version.to_name.should eql(EXPECTED_NAME)
17
17
  end
18
18
  end
19
19
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: twitter4r
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-05-06 00:00:00 -05:00
6
+ version: 0.1.1
7
+ date: 2007-06-25 00:00:00 -05:00
8
8
  summary: A clean Twitter client API in pure Ruby (not command-line client). Will include Twitter add-ons also in Ruby.
9
9
  require_paths:
10
10
  - lib