tweetwine 0.4.1 → 0.4.2

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.
Files changed (52) hide show
  1. data/CHANGELOG.rdoc +6 -0
  2. data/Rakefile +22 -23
  3. data/lib/tweetwine/cli.rb +167 -165
  4. data/lib/tweetwine/config.rb +3 -2
  5. data/lib/tweetwine/exceptions.rb +1 -0
  6. data/lib/tweetwine/version.rb +1 -1
  7. data/project.rb +16 -16
  8. data/test/fixture/{config_example.yaml → config_integration.yaml} +0 -0
  9. data/test/fixture/oauth.rb +11 -11
  10. data/test/{test_helper.rb → helper.rb} +16 -7
  11. data/test/{example/authorization_example.rb → integration/authorization_test.rb} +17 -17
  12. data/test/integration/global_options_test.rb +67 -0
  13. data/test/integration/helper.rb +70 -0
  14. data/test/integration/invalid_config_file_test.rb +28 -0
  15. data/test/integration/search_statuses_test.rb +81 -0
  16. data/test/integration/show_followers_test.rb +24 -0
  17. data/test/integration/show_friends_test.rb +24 -0
  18. data/test/integration/show_home_test.rb +47 -0
  19. data/test/integration/show_mentions_test.rb +24 -0
  20. data/test/integration/show_user_test.rb +48 -0
  21. data/test/integration/update_status_test.rb +199 -0
  22. data/test/integration/use_http_proxy_test.rb +71 -0
  23. data/test/{example/user_help_example.rb → integration/user_help_test.rb} +36 -36
  24. data/test/unit/character_encoding_test.rb +19 -15
  25. data/test/unit/cli_test.rb +9 -10
  26. data/test/unit/config_test.rb +73 -71
  27. data/test/unit/helper.rb +108 -0
  28. data/test/unit/http_test.rb +39 -39
  29. data/test/unit/oauth_test.rb +15 -16
  30. data/test/unit/obfuscate_test.rb +4 -4
  31. data/test/unit/option_parser_test.rb +12 -12
  32. data/test/unit/promise_test.rb +10 -10
  33. data/test/unit/support_test.rb +44 -45
  34. data/test/unit/tweet_helper.rb +1 -1
  35. data/test/unit/tweet_test.rb +42 -42
  36. data/test/unit/twitter_test.rb +300 -303
  37. data/test/unit/ui_test.rb +310 -312
  38. data/test/unit/uri_test.rb +7 -7
  39. data/test/unit/url_shortener_test.rb +77 -79
  40. data/tweetwine.gemspec +6 -15
  41. metadata +55 -145
  42. data/test/example/example_helper.rb +0 -58
  43. data/test/example/global_options_example.rb +0 -64
  44. data/test/example/search_statuses_example.rb +0 -76
  45. data/test/example/show_followers_example.rb +0 -24
  46. data/test/example/show_friends_example.rb +0 -24
  47. data/test/example/show_home_example.rb +0 -44
  48. data/test/example/show_mentions_example.rb +0 -24
  49. data/test/example/show_user_example.rb +0 -44
  50. data/test/example/update_status_example.rb +0 -183
  51. data/test/example/use_http_proxy_example.rb +0 -68
  52. data/test/unit/unit_helper.rb +0 -111
data/test/unit/ui_test.rb CHANGED
@@ -1,368 +1,333 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'unit_helper'
4
- require 'tweet_helper'
3
+ require 'unit/helper'
4
+ require 'unit/tweet_helper'
5
5
 
6
- module Tweetwine::Test
6
+ module Tweetwine::Test::Unit
7
7
 
8
- class UITest < UnitTestCase
8
+ class UITest < TestCase
9
9
  include TweetHelper
10
10
 
11
- context "a UI instance" do
12
- setup do
13
- @in = mock
14
- @out = mock
15
- @err = mock
16
- @ui = UI.new({ :in => @in, :out => @out, :err => @err })
17
- end
11
+ before do
12
+ @in = mock
13
+ @out = mock
14
+ @err = mock
15
+ @ui = UI.new({ :in => @in, :out => @out, :err => @err })
16
+ end
18
17
 
19
- should "output prompt and return input as trimmed" do
20
- @out.expects(:print).with("The answer: ")
21
- @in.expects(:gets).returns(" 42 ")
22
- assert_equal "42", @ui.prompt("The answer")
23
- end
18
+ it "outputs prompt and return input as trimmed" do
19
+ @out.expects(:print).with("The answer: ")
20
+ @in.expects(:gets).returns(" 42 ")
21
+ assert_equal "42", @ui.prompt("The answer")
22
+ end
24
23
 
25
- should "output info message" do
26
- @out.expects(:puts).with("foo")
27
- @ui.info("foo")
28
- end
24
+ it "outputs info message" do
25
+ @out.expects(:puts).with("foo")
26
+ @ui.info("foo")
27
+ end
29
28
 
30
- should "output info message in process style when given a block" do
31
- inform = sequence('inform')
32
- @out.expects(:print).with("processing...").in_sequence(inform)
33
- @out.expects(:puts).with(" done.").in_sequence(inform)
34
- @ui.info("processing...") { true }
35
- end
29
+ it "outputs info message in process style when given a block" do
30
+ inform = sequence('inform')
31
+ @out.expects(:print).with("processing...").in_sequence(inform)
32
+ @out.expects(:puts).with(" done.").in_sequence(inform)
33
+ @ui.info("processing...") { true }
34
+ end
36
35
 
37
- should "output empty line as info message" do
38
- @out.expects(:puts).with("\n")
39
- @ui.info
40
- end
36
+ it "outputs empty line as info message" do
37
+ @out.expects(:puts).with("\n")
38
+ @ui.info
39
+ end
41
40
 
42
- should "output warning message" do
43
- @out.expects(:puts).with("Warning: monkey patching ahead")
44
- @ui.warn("monkey patching ahead")
45
- end
41
+ it "outputs warning message" do
42
+ @out.expects(:puts).with("Warning: monkey patching ahead")
43
+ @ui.warn("monkey patching ahead")
44
+ end
46
45
 
47
- should "output error message" do
48
- @err.expects(:puts).with("ERROR: Invalid monkey patch")
49
- @ui.error("Invalid monkey patch")
50
- end
46
+ it "outputs error message" do
47
+ @err.expects(:puts).with("ERROR: Invalid monkey patch")
48
+ @ui.error("Invalid monkey patch")
49
+ end
51
50
 
52
- should "confirm action, with positive answer" do
53
- @out.expects(:print).with("Fire nukes? [yN] ")
54
- @in.expects(:gets).returns("y")
55
- assert_equal true, @ui.confirm("Fire nukes?")
56
- end
51
+ it "confirms action, with positive answer" do
52
+ @out.expects(:print).with("Fire nukes? [yN] ")
53
+ @in.expects(:gets).returns("y")
54
+ assert_equal true, @ui.confirm("Fire nukes?")
55
+ end
57
56
 
58
- should "confirm action, with negative answer" do
59
- @out.expects(:print).with("Fire nukes? [yN] ")
60
- @in.expects(:gets).returns("n")
61
- assert_equal false, @ui.confirm("Fire nukes?")
62
- end
57
+ it "confirms action, with negative answer" do
58
+ @out.expects(:print).with("Fire nukes? [yN] ")
59
+ @in.expects(:gets).returns("n")
60
+ assert_equal false, @ui.confirm("Fire nukes?")
61
+ end
63
62
 
64
- should "confirm action, with default answer" do
65
- @out.expects(:print).with("Fire nukes? [yN] ")
66
- @in.expects(:gets).returns("")
67
- assert_equal false, @ui.confirm("Fire nukes?")
68
- end
63
+ it "confirms action, with default answer" do
64
+ @out.expects(:print).with("Fire nukes? [yN] ")
65
+ @in.expects(:gets).returns("")
66
+ assert_equal false, @ui.confirm("Fire nukes?")
67
+ end
69
68
 
70
- context "with colorization disabled" do
71
- setup do
72
- @ui = UI.new({:in => @in, :out => @out, :colors => false })
73
- end
69
+ describe "when colors are disabled" do
70
+ before do
71
+ @ui = UI.new({:in => @in, :out => @out, :colors => false })
72
+ end
74
73
 
75
- should "output tweet with just user info" do
76
- from_user = "fooman"
77
- tweet = create_tweet(:from_user => from_user)
78
- @out.expects(:puts).with(<<-END
74
+ it "outputs tweet with just user info" do
75
+ from_user = "fooman"
76
+ tweet = create_tweet(:from_user => from_user)
77
+ @out.expects(:puts).with(<<-END
79
78
  #{from_user}
80
79
 
81
- END
82
- )
83
- @ui.show_tweet(tweet)
84
- end
80
+ END
81
+ )
82
+ @ui.show_tweet(tweet)
83
+ end
85
84
 
86
- should "output regular tweet" do
87
- from_user = "fooman"
88
- status = "Hi, @barman! Lulz woo! #hellos"
89
- time = 2
90
- tweet = create_tweet(
91
- :from_user => from_user,
92
- :status => status,
93
- :created_at => create_timestamp(time)
94
- )
95
- @out.expects(:puts).with(<<-END
85
+ it "outputs regular tweet" do
86
+ from_user = "fooman"
87
+ status = "Hi, @barman! Lulz woo! #hellos"
88
+ time = 2
89
+ tweet = create_tweet(
90
+ :from_user => from_user,
91
+ :status => status,
92
+ :created_at => create_timestamp(time)
93
+ )
94
+ @out.expects(:puts).with(<<-END
96
95
  #{from_user}, #{time} sec ago:
97
96
  #{status}
98
97
 
99
- END
100
- )
101
- show_tweet_at_default_time(tweet)
102
- end
98
+ END
99
+ )
100
+ show_tweet_at_default_time(tweet)
101
+ end
103
102
 
104
- should "output replying tweet" do
105
- from_user = "barman"
106
- to_user = "fooman"
107
- status = "Hi, @#{to_user}! How are you doing?"
108
- tweet = create_tweet(
109
- :from_user => from_user,
110
- :status => status,
111
- :to_user => to_user
112
- )
113
- @out.expects(:puts).with(<<-END
103
+ it "outputs replying tweet" do
104
+ from_user = "barman"
105
+ to_user = "fooman"
106
+ status = "Hi, @#{to_user}! How are you doing?"
107
+ tweet = create_tweet(
108
+ :from_user => from_user,
109
+ :status => status,
110
+ :to_user => to_user
111
+ )
112
+ @out.expects(:puts).with(<<-END
114
113
  #{from_user}, in reply to #{to_user}, 0 sec ago:
115
114
  #{status}
116
115
 
117
- END
118
- )
119
- show_tweet_at_default_time(tweet)
120
- end
116
+ END
117
+ )
118
+ show_tweet_at_default_time(tweet)
119
+ end
121
120
 
122
- should "output regular retweet" do
123
- from_user = "barman"
124
- rt_user = "fooman"
125
- status = "status worth retweeting"
126
- tweet = create_tweet(
127
- :from_user => from_user,
128
- :status => status,
129
- :rt_user => rt_user
130
- )
131
- @out.expects(:puts).with(<<-END
121
+ it "outputs regular retweet" do
122
+ from_user = "barman"
123
+ rt_user = "fooman"
124
+ status = "status worth retweeting"
125
+ tweet = create_tweet(
126
+ :from_user => from_user,
127
+ :status => status,
128
+ :rt_user => rt_user
129
+ )
130
+ @out.expects(:puts).with(<<-END
132
131
  #{rt_user} RT #{from_user}, 0 sec ago:
133
132
  #{status}
134
133
 
135
- END
136
- )
137
- show_tweet_at_default_time(tweet)
138
- end
134
+ END
135
+ )
136
+ show_tweet_at_default_time(tweet)
137
+ end
139
138
 
140
- should "output replying retweet" do
141
- from_user = "barman"
142
- to_user = "jackman"
143
- rt_user = "fooman"
144
- status = "@#{to_user}, reply worth retweeting"
145
- tweet = create_tweet(
146
- :from_user => from_user,
147
- :to_user => to_user,
148
- :status => status,
149
- :rt_user => rt_user
150
- )
151
- @out.expects(:puts).with(<<-END
139
+ it "outputs replying retweet" do
140
+ from_user = "barman"
141
+ to_user = "jackman"
142
+ rt_user = "fooman"
143
+ status = "@#{to_user}, reply worth retweeting"
144
+ tweet = create_tweet(
145
+ :from_user => from_user,
146
+ :to_user => to_user,
147
+ :status => status,
148
+ :rt_user => rt_user
149
+ )
150
+ @out.expects(:puts).with(<<-END
152
151
  #{rt_user} RT #{from_user}, in reply to #{to_user}, 0 sec ago:
153
152
  #{status}
154
153
 
155
- END
156
- )
157
- show_tweet_at_default_time(tweet)
158
- end
154
+ END
155
+ )
156
+ show_tweet_at_default_time(tweet)
157
+ end
159
158
 
160
- should "unescape HTML in a status" do
161
- from_user = "fooman"
162
- escaped_status = "apple &gt; orange &amp; grapefruit &lt; banana"
163
- unescaped_status = "apple > orange & grapefruit < banana"
164
- tweet = create_tweet(
165
- :from_user => from_user,
166
- :status => escaped_status
167
- )
168
- @out.expects(:puts).with(<<-END
159
+ it "unescapes HTML in a status" do
160
+ from_user = "fooman"
161
+ escaped_status = "apple &gt; orange &amp; grapefruit &lt; banana"
162
+ unescaped_status = "apple > orange & grapefruit < banana"
163
+ tweet = create_tweet(
164
+ :from_user => from_user,
165
+ :status => escaped_status
166
+ )
167
+ @out.expects(:puts).with(<<-END
169
168
  #{from_user}, 0 sec ago:
170
169
  #{unescaped_status}
171
170
 
172
- END
173
- )
174
- show_tweet_at_default_time(tweet)
175
- end
171
+ END
172
+ )
173
+ show_tweet_at_default_time(tweet)
174
+ end
176
175
 
177
- should "output a preview of a status" do
178
- status = "@nick, check http://bit.ly/18rU_Vx"
179
- @out.expects(:puts).with(<<-END
176
+ it "outputs a preview of a status" do
177
+ status = "@nick, check http://bit.ly/18rU_Vx"
178
+ @out.expects(:puts).with(<<-END
180
179
 
181
180
  #{status}
182
181
 
183
- END
184
- )
185
- @ui.show_status_preview(status)
186
- end
182
+ END
183
+ )
184
+ @ui.show_status_preview(status)
187
185
  end
186
+ end
188
187
 
189
- context "with colorization enabled" do
190
- setup do
191
- @ui = UI.new({:in => @in, :out => @out, :colors => true})
192
- end
188
+ describe "when colors are enabled" do
189
+ before do
190
+ @ui = UI.new({:in => @in, :out => @out, :colors => true})
191
+ end
193
192
 
194
- should "output tweet with just user info" do
195
- from_user = "fooman"
196
- tweet = create_tweet(:from_user => from_user)
197
- @out.expects(:puts).with(<<-END
193
+ it "outputs tweet with just user info" do
194
+ from_user = "fooman"
195
+ tweet = create_tweet(:from_user => from_user)
196
+ @out.expects(:puts).with(<<-END
198
197
  \e[32m#{from_user}\e[0m
199
198
 
200
- END
201
- )
202
- @ui.show_tweet(tweet)
203
- end
199
+ END
200
+ )
201
+ @ui.show_tweet(tweet)
202
+ end
204
203
 
205
- should "output regular tweet" do
206
- from_user = "fooman"
207
- status = "Wondering about the meaning of life."
208
- tweet = create_tweet(
209
- :from_user => from_user,
210
- :status => status
211
- )
212
- @out.expects(:puts).with(<<-END
204
+ it "outputs regular tweet" do
205
+ from_user = "fooman"
206
+ status = "Wondering about the meaning of life."
207
+ tweet = create_tweet(
208
+ :from_user => from_user,
209
+ :status => status
210
+ )
211
+ @out.expects(:puts).with(<<-END
213
212
  \e[32m#{from_user}\e[0m, 0 sec ago:
214
213
  #{status}
215
214
 
216
- END
217
- )
218
- show_tweet_at_default_time(tweet)
219
- end
215
+ END
216
+ )
217
+ show_tweet_at_default_time(tweet)
218
+ end
220
219
 
221
- should "output replying tweet" do
222
- from_user = "barman"
223
- to_user = "fooman"
224
- tweet = create_tweet(
225
- :from_user => from_user,
226
- :status => "@#{to_user}! How are you doing?",
227
- :to_user => to_user
228
- )
229
- @out.expects(:puts).with(<<-END
220
+ it "outputs replying tweet" do
221
+ from_user = "barman"
222
+ to_user = "fooman"
223
+ tweet = create_tweet(
224
+ :from_user => from_user,
225
+ :status => "@#{to_user}! How are you doing?",
226
+ :to_user => to_user
227
+ )
228
+ @out.expects(:puts).with(<<-END
230
229
  \e[32m#{from_user}\e[0m, in reply to \e[32m#{to_user}\e[0m, 0 sec ago:
231
230
  \e[33m@#{to_user}\e[0m! How are you doing?
232
231
 
233
- END
234
- )
235
- show_tweet_at_default_time(tweet)
236
- end
232
+ END
233
+ )
234
+ show_tweet_at_default_time(tweet)
235
+ end
237
236
 
238
- should "output regular retweet" do
239
- from_user = "barman"
240
- rt_user = "fooman"
241
- status = "status worth retweeting"
242
- tweet = create_tweet(
243
- :from_user => from_user,
244
- :status => status,
245
- :rt_user => rt_user
246
- )
247
- @out.expects(:puts).with(<<-END
237
+ it "outputs regular retweet" do
238
+ from_user = "barman"
239
+ rt_user = "fooman"
240
+ status = "status worth retweeting"
241
+ tweet = create_tweet(
242
+ :from_user => from_user,
243
+ :status => status,
244
+ :rt_user => rt_user
245
+ )
246
+ @out.expects(:puts).with(<<-END
248
247
  \e[32m#{rt_user}\e[0m RT \e[32m#{from_user}\e[0m, 0 sec ago:
249
248
  #{status}
250
249
 
251
- END
252
- )
253
- show_tweet_at_default_time(tweet)
254
- end
250
+ END
251
+ )
252
+ show_tweet_at_default_time(tweet)
253
+ end
255
254
 
256
- should "output replying retweet" do
257
- from_user = "barman"
258
- to_user = "jackman"
259
- rt_user = "fooman"
260
- tweet = create_tweet(
261
- :from_user => from_user,
262
- :to_user => to_user,
263
- :status => "@#{to_user}, reply worth retweeting",
264
- :rt_user => rt_user
265
- )
266
- @out.expects(:puts).with(<<-END
255
+ it "outputs replying retweet" do
256
+ from_user = "barman"
257
+ to_user = "jackman"
258
+ rt_user = "fooman"
259
+ tweet = create_tweet(
260
+ :from_user => from_user,
261
+ :to_user => to_user,
262
+ :status => "@#{to_user}, reply worth retweeting",
263
+ :rt_user => rt_user
264
+ )
265
+ @out.expects(:puts).with(<<-END
267
266
  \e[32m#{rt_user}\e[0m RT \e[32m#{from_user}\e[0m, in reply to \e[32m#{to_user}\e[0m, 0 sec ago:
268
267
  \e[33m@#{to_user}\e[0m, reply worth retweeting
269
268
 
270
- END
271
- )
272
- show_tweet_at_default_time(tweet)
273
- end
269
+ END
270
+ )
271
+ show_tweet_at_default_time(tweet)
272
+ end
274
273
 
275
- should "output a preview of a status" do
276
- status = "@nick, check http://bit.ly/18rU_Vx"
277
- @out.expects(:puts).with(<<-END
274
+ it "outputs a preview of a status" do
275
+ status = "@nick, check http://bit.ly/18rU_Vx"
276
+ @out.expects(:puts).with(<<-END
278
277
 
279
278
  \e[33m@nick\e[0m, check \e[36mhttp://bit.ly/18rU_Vx\e[0m
280
279
 
281
- END
282
- )
283
- @ui.show_status_preview(status)
284
- end
280
+ END
281
+ )
282
+ @ui.show_status_preview(status)
283
+ end
285
284
 
286
- should "highlight hashtags in a status" do
287
- from_user = "barman"
288
- hashtags = %w{#slang #beignHappy}
289
- tweet = create_tweet(
290
- :from_user => from_user,
291
- :status => "Lulz, so happy! #{hashtags[0]} #{hashtags[1]}"
292
- )
293
- @out.expects(:puts).with(<<-END
285
+ it "highlights hashtags in a status" do
286
+ from_user = "barman"
287
+ hashtags = %w{#slang #beignHappy}
288
+ tweet = create_tweet(
289
+ :from_user => from_user,
290
+ :status => "Lulz, so happy! #{hashtags[0]} #{hashtags[1]}"
291
+ )
292
+ @out.expects(:puts).with(<<-END
294
293
  \e[32m#{from_user}\e[0m, 0 sec ago:
295
294
  Lulz, so happy! \e[35m#{hashtags[0]}\e[0m \e[35m#{hashtags[1]}\e[0m
296
295
 
297
- END
298
- )
299
- show_tweet_at_default_time(tweet)
300
- end
301
-
302
- %w{http://is.gd/1qLk3 http://is.gd/1qLk3?id=foo}.each do |url|
303
- should "highlight HTTP and HTTPS URLs in a status, given #{url}" do
304
- from_user = "barman"
305
- tweet = create_tweet(
306
- :from_user => from_user,
307
- :status => "New Rails³ - #{url}"
308
- )
309
- @out.expects(:puts).with(<<-END
310
- \e[32m#{from_user}\e[0m, 0 sec ago:
311
- New Rails³ - \e[36m#{url}\e[0m
312
-
313
- END
314
- )
315
- show_tweet_at_default_time(tweet)
316
- end
317
- end
318
-
319
- [
320
- %w{http://is.gd/1qLk3 http://is.gd/1qLk3},
321
- %w{http://is.gd/1qLk3 http://is.gd/1q}
322
- ].each do |(first_url, second_url)|
323
- should "highlight HTTP and HTTPS URLs in a status, given #{first_url} and #{second_url}" do
324
- from_user = "barman"
325
- tweet = create_tweet(
326
- :from_user => from_user,
327
- :status => "Links: #{first_url} and #{second_url} np"
328
- )
329
- @out.expects(:puts).with(<<-END
330
- \e[32m#{from_user}\e[0m, 0 sec ago:
331
- Links: \e[36m#{first_url}\e[0m and \e[36m#{second_url}\e[0m np
332
-
333
- END
334
- )
335
- show_tweet_at_default_time(tweet)
336
- end
337
- end
296
+ END
297
+ )
298
+ show_tweet_at_default_time(tweet)
299
+ end
338
300
 
339
- should "highlight usernames in a status" do
301
+ %w{http://is.gd/1qLk3 http://is.gd/1qLk3?id=foo}.each do |url|
302
+ it "highlights HTTP and HTTPS URLs in a status, given #{url}" do
340
303
  from_user = "barman"
341
- users = %w{@fooman @barbaz @spoonman}
342
304
  tweet = create_tweet(
343
305
  :from_user => from_user,
344
- :status => "I salute you #{users[0]}, #{users[1]}, and #{users[2]}!"
306
+ :status => "New Rails³ - #{url}"
345
307
  )
346
308
  @out.expects(:puts).with(<<-END
347
309
  \e[32m#{from_user}\e[0m, 0 sec ago:
348
- I salute you \e[33m#{users[0]}\e[0m, \e[33m#{users[1]}\e[0m, and \e[33m#{users[2]}\e[0m!
310
+ New Rails³ - \e[36m#{url}\e[0m
349
311
 
350
312
  END
351
313
  )
352
314
  show_tweet_at_default_time(tweet)
353
315
  end
316
+ end
354
317
 
355
- should "not highlight email addresses as usernames in a status" do
318
+ [
319
+ %w{http://is.gd/1qLk3 http://is.gd/1qLk3},
320
+ %w{http://is.gd/1qLk3 http://is.gd/1q}
321
+ ].each do |(first_url, second_url)|
322
+ it "highlights HTTP and HTTPS URLs in a status, given #{first_url} and #{second_url}" do
356
323
  from_user = "barman"
357
- users = %w{@fooman @barbaz}
358
- email = "barbaz@foo.net"
359
324
  tweet = create_tweet(
360
325
  :from_user => from_user,
361
- :status => "Hi, #{users[0]}! You should notify #{users[1]}, #{email}"
326
+ :status => "Links: #{first_url} and #{second_url} np"
362
327
  )
363
328
  @out.expects(:puts).with(<<-END
364
329
  \e[32m#{from_user}\e[0m, 0 sec ago:
365
- Hi, \e[33m#{users[0]}\e[0m! You should notify \e[33m#{users[1]}\e[0m, #{email}
330
+ Links: \e[36m#{first_url}\e[0m and \e[36m#{second_url}\e[0m np
366
331
 
367
332
  END
368
333
  )
@@ -370,55 +335,88 @@ Hi, \e[33m#{users[0]}\e[0m! You should notify \e[33m#{users[1]}\e[0m, #{email}
370
335
  end
371
336
  end
372
337
 
373
- context "for outputting a collection of tweets" do
374
- setup do
375
- users_and_times = [
376
- ['first', 11],
377
- ['second', 12],
378
- ['third', 13]
379
- ]
380
- statuses = users_and_times.map { |(user, _)| "Hi, I'm #{user}." }
381
- users_and_statuses = users_and_times.zip(statuses)
382
- @outputs = Hash[users_and_statuses.map { |(user, time), status|
383
- output = <<-END
338
+ it "highlights usernames in a status" do
339
+ from_user = "barman"
340
+ users = %w{@fooman @barbaz @spoonman}
341
+ tweet = create_tweet(
342
+ :from_user => from_user,
343
+ :status => "I salute you #{users[0]}, #{users[1]}, and #{users[2]}!"
344
+ )
345
+ @out.expects(:puts).with(<<-END
346
+ \e[32m#{from_user}\e[0m, 0 sec ago:
347
+ I salute you \e[33m#{users[0]}\e[0m, \e[33m#{users[1]}\e[0m, and \e[33m#{users[2]}\e[0m!
348
+
349
+ END
350
+ )
351
+ show_tweet_at_default_time(tweet)
352
+ end
353
+
354
+ it "does not highlight email addresses as usernames in a status" do
355
+ from_user = "barman"
356
+ users = %w{@fooman @barbaz}
357
+ email = "barbaz@foo.net"
358
+ tweet = create_tweet(
359
+ :from_user => from_user,
360
+ :status => "Hi, #{users[0]}! You should notify #{users[1]}, #{email}"
361
+ )
362
+ @out.expects(:puts).with(<<-END
363
+ \e[32m#{from_user}\e[0m, 0 sec ago:
364
+ Hi, \e[33m#{users[0]}\e[0m! You should notify \e[33m#{users[1]}\e[0m, #{email}
365
+
366
+ END
367
+ )
368
+ show_tweet_at_default_time(tweet)
369
+ end
370
+ end
371
+
372
+ describe "when outputting a collection of tweets" do
373
+ before do
374
+ users_and_times = [
375
+ ['first', 11],
376
+ ['second', 12],
377
+ ['third', 13]
378
+ ]
379
+ statuses = users_and_times.map { |(user, _)| "Hi, I'm #{user}." }
380
+ users_and_statuses = users_and_times.zip(statuses)
381
+ @outputs = Hash[users_and_statuses.map { |(user, time), status|
382
+ output = <<-END
384
383
  #{user}, #{time} sec ago:
385
384
  #{status}
386
385
 
387
- END
388
- [user.to_sym, output]
389
- }]
390
- @tweets = users_and_statuses.map { |(user, time), status| create_tweet(
391
- :from_user => user,
392
- :status => status,
393
- :created_at => create_timestamp(time)
394
- )}
395
- end
386
+ END
387
+ [user.to_sym, output]
388
+ }]
389
+ @tweets = users_and_statuses.map { |(user, time), status| create_tweet(
390
+ :from_user => user,
391
+ :status => status,
392
+ :created_at => create_timestamp(time)
393
+ )}
394
+ end
396
395
 
397
- should "output tweets in normal order" do
398
- @ui = UI.new({ :out => @out, :show_reverse => false })
399
- [:first, :second, :third].each do |user|
400
- @out.expects(:puts).with(@outputs[user])
401
- end
402
- show_tweets_at_default_time(@tweets)
396
+ it "outputs tweets in normal order" do
397
+ @ui = UI.new({ :out => @out, :show_reverse => false })
398
+ [:first, :second, :third].each do |user|
399
+ @out.expects(:puts).with(@outputs[user])
403
400
  end
401
+ show_tweets_at_default_time(@tweets)
402
+ end
404
403
 
405
- should "output tweets in reverse order" do
406
- @ui = UI.new({ :out => @out, :show_reverse => true })
407
- [:third, :second, :first].each do |user|
408
- @out.expects(:puts).with(@outputs[user])
409
- end
410
- show_tweets_at_default_time(@tweets)
404
+ it "outputs tweets in reverse order" do
405
+ @ui = UI.new({ :out => @out, :show_reverse => true })
406
+ [:third, :second, :first].each do |user|
407
+ @out.expects(:puts).with(@outputs[user])
411
408
  end
409
+ show_tweets_at_default_time(@tweets)
412
410
  end
413
411
  end
414
412
 
415
- context "username regex" do
413
+ describe "username regex" do
416
414
  [
417
415
  ['@nick', 'normal'],
418
416
  ['@nick_man', 'underscore separated'],
419
417
  [' @nick', 'beginning with space']
420
418
  ].each do |(nick, desc)|
421
- should "match proper username reference, case #{desc}" do
419
+ it "matches proper username reference, case #{desc}" do
422
420
  assert_full_match UI::USERNAME_REGEX, nick
423
421
  end
424
422
  end
@@ -433,19 +431,19 @@ Hi, \e[33m#{users[0]}\e[0m! You should notify \e[33m#{users[1]}\e[0m, #{email}
433
431
  ['man @nick', 'space separated'],
434
432
  ['man@nick', 'prefix in between']
435
433
  ].each do |(no_nick, desc)|
436
- should "not match an inproper username reference, case #{desc}" do
434
+ it "does not match an inproper username reference, case #{desc}" do
437
435
  assert_no_full_match UI::USERNAME_REGEX, no_nick
438
436
  end
439
437
  end
440
438
  end
441
439
 
442
- context "hashtag regex" do
440
+ describe "hashtag regex" do
443
441
  [
444
442
  ['#mayhem', 'normal'],
445
443
  ['#friday_mayhem', 'underscore separated'],
446
444
  ['#friday-mayhem', 'dash separated']
447
445
  ].each do |(hashtag, desc)|
448
- should "match a proper hashtag reference, case #{desc}" do
446
+ it "matches a proper hashtag reference, case #{desc}" do
449
447
  assert_full_match UI::HASHTAG_REGEX, hashtag
450
448
  end
451
449
  end
@@ -457,7 +455,7 @@ Hi, \e[33m#{users[0]}\e[0m! You should notify \e[33m#{users[1]}\e[0m, #{email}
457
455
  ['#mayhem ', 'ending with space'],
458
456
  [' #mayhem ', 'surrounded with space']
459
457
  ].each do |(no_hashtag, desc)|
460
- should "not match an inproper hashtag reference, case #{desc}" do
458
+ it "does not match an inproper hashtag reference, case #{desc}" do
461
459
  assert_no_full_match UI::HASHTAG_REGEX, no_hashtag
462
460
  end
463
461
  end