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
@@ -1,13 +1,13 @@
1
1
  # coding: utf-8
2
2
 
3
- require "unit_helper"
3
+ require 'unit/helper'
4
4
 
5
- module Tweetwine::Test
5
+ module Tweetwine::Test::Unit
6
6
 
7
- class ObfuscateTest < UnitTestCase
7
+ class ObfuscateTest < TestCase
8
8
  include Obfuscate
9
9
 
10
- should "obfuscate symmetrically" do
10
+ it "obfuscates symmetrically" do
11
11
  str = 'hey, jack'
12
12
  assert_equal(str, obfuscate(obfuscate(str)))
13
13
  end
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
 
3
- require "unit_helper"
3
+ require 'unit/helper'
4
4
 
5
- module Tweetwine::Test
5
+ module Tweetwine::Test::Unit
6
6
 
7
- class OptionParserTest < UnitTestCase
8
- setup do
7
+ class OptionParserTest < TestCase
8
+ before do
9
9
  @parser = OptionParser.new do |parser, options|
10
10
  parser.on '-c', '--colors', 'Enable colors.' do
11
11
  options[:colors] = true
@@ -16,41 +16,41 @@ class OptionParserTest < UnitTestCase
16
16
  end
17
17
  end
18
18
 
19
- should "return empty options if no options (no default values)" do
19
+ it "returns empty options if no options (no default values)" do
20
20
  options = @parser.parse %w{}
21
21
  assert options.empty?
22
22
  end
23
23
 
24
- should "return only options that occurred (no default values)" do
24
+ it "returns only options that occurred (no default values)" do
25
25
  options = @parser.parse %w{-u jack}
26
26
  assert_equal({:username => 'jack'}, options)
27
27
  end
28
28
 
29
- should "return copy of options after parsing" do
29
+ it "returns copy of options after parsing" do
30
30
  options1 = @parser.parse %w{-u jack}
31
31
  options2 = @parser.parse %w{-c}
32
32
  assert_equal({:username => 'jack'}, options1)
33
33
  assert_equal({:colors => true}, options2)
34
34
  end
35
35
 
36
- should "parse from beginning, removing recognized options" do
36
+ it "parses from beginning, removing recognized options" do
37
37
  args = %w{-u jack foo bar}
38
38
  options = @parser.parse args
39
39
  assert_equal(%w{foo bar}, args)
40
40
  end
41
41
 
42
- should "parse from beginning, leaving option-like arguments after non-option arguments in place" do
42
+ it "parses from beginning, leaving option-like arguments after non-option arguments in place" do
43
43
  args = %w{-c foo -u jack bar}
44
44
  options = @parser.parse args
45
45
  assert_equal(%w{foo -u jack bar}, args)
46
46
  assert_equal({:colors => true}, options)
47
47
  end
48
48
 
49
- should "raise exception upon unrecognized option" do
50
- assert_raise(CommandLineError) { @parser.parse %w{-d} }
49
+ it "raises exception upon unrecognized option" do
50
+ assert_raises(CommandLineError) { @parser.parse %w{-d} }
51
51
  end
52
52
 
53
- should "describe option syntax" do
53
+ it "describes option syntax" do
54
54
  description = @parser.help.split("\n")
55
55
  assert_match(/\A\s+\-c, \-\-colors\s+Enable colors.\z/, description[0])
56
56
  assert_match(/\A\s+\-u, \-\-username <user>\s+Specify user.\z/, description[1])
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
 
3
- require "unit_helper"
3
+ require 'unit/helper'
4
4
 
5
- module Tweetwine::Test
5
+ module Tweetwine::Test::Unit
6
6
 
7
- class PromiseTest < UnitTestCase
8
- setup do
7
+ class PromiseTest < TestCase
8
+ before do
9
9
  @result = nil
10
10
  @action_called = 0
11
11
  @promise = Promise.new do
@@ -14,13 +14,13 @@ class PromiseTest < UnitTestCase
14
14
  end
15
15
  end
16
16
 
17
- should "evaluate action when calling a method" do
17
+ it "evaluates action when calling a method" do
18
18
  result = @promise.to_i
19
19
  assert_same(@result, result)
20
20
  assert_equal(1, @action_called)
21
21
  end
22
22
 
23
- should "memoize already evaluated action" do
23
+ it "memoizes already evaluated action" do
24
24
  result = @promise.to_i
25
25
  assert_same(@result, result)
26
26
  result = @promise.to_i
@@ -28,22 +28,22 @@ class PromiseTest < UnitTestCase
28
28
  assert_equal(1, @action_called)
29
29
  end
30
30
 
31
- should "inspect the proxy object if action is not evaluated" do
31
+ it "inspects the proxy object if action is not evaluated" do
32
32
  assert_match(/^#<Tweetwine::Promise/, @promise.inspect)
33
33
  assert_equal(0, @action_called)
34
34
  end
35
35
 
36
- should "inspect the evaluated object if action is evaluated" do
36
+ it "inspects the evaluated object if action is evaluated" do
37
37
  eval_action
38
38
  assert_match(/^\d$/, @promise.inspect)
39
39
  end
40
40
 
41
- should "pass #object_id call to the evaluation result" do
41
+ it "passes #object_id call to the evaluation result" do
42
42
  eval_action # in order to have @result set
43
43
  assert_equal(@result.object_id, @promise.object_id)
44
44
  end
45
45
 
46
- should "pass #to_s call to the evaluation result" do
46
+ it "passes #to_s call to the evaluation result" do
47
47
  eval_action # in order to have @result set
48
48
  assert_equal(@result.to_s, @promise.to_s)
49
49
  end
@@ -1,15 +1,14 @@
1
1
  # coding: utf-8
2
2
 
3
- require "unit_helper"
3
+ require 'unit/helper'
4
+ require 'time'
4
5
 
5
- require "time"
6
+ module Tweetwine::Test::Unit
6
7
 
7
- module Tweetwine::Test
8
-
9
- class SupportTest < UnitTestCase
8
+ class SupportTest < TestCase
10
9
  include Support
11
10
 
12
- context "for determining emptiness" do
11
+ describe "for determining emptiness" do
13
12
  [
14
13
  [nil, true, "nil"],
15
14
  ["", true, "empty string"],
@@ -17,27 +16,27 @@ class SupportTest < UnitTestCase
17
16
  [[], true, "empty array"],
18
17
  [%w{a b}, false, "nonempty array"]
19
18
  ].each do |(subject, emptiness, desc)|
20
- should "return #{emptiness} for blank? with #{desc}" do
19
+ it "returns #{emptiness} for blank? with #{desc}" do
21
20
  assert_equal emptiness, blank?(subject)
22
21
  end
23
22
 
24
- should "return #{!emptiness} for present? with #{desc}" do
23
+ it "returns #{!emptiness} for present? with #{desc}" do
25
24
  assert_equal !emptiness, present?(subject)
26
25
  end
27
26
 
28
- should "return non-empty subject for presence, when subject is #{desc}" do
27
+ it "returns non-empty subject for presence, when subject is #{desc}" do
29
28
  actual = presence(subject)
30
29
  expected = present?(subject) ? subject : nil
31
30
  assert_same expected, actual
32
31
  end
33
32
 
34
- should "return value of block for presence, when subject is #{desc}" do
33
+ it "returns value of block for presence, when subject is #{desc}" do
35
34
  actual = presence(subject) { |s| s.size }
36
35
  expected = present?(subject) ? subject.size : nil
37
36
  assert_same expected, actual
38
37
  end
39
38
 
40
- should "allow presence to be used with || operator, when subject is #{desc}" do
39
+ it "allows presence to be used with || operator, when subject is #{desc}" do
41
40
  alternative = "hey"
42
41
  actual = presence(subject) || alternative
43
42
  expected = present?(subject) ? subject : alternative
@@ -46,8 +45,8 @@ class SupportTest < UnitTestCase
46
45
  end
47
46
  end
48
47
 
49
- context "for humanizing time differences" do
50
- should "accept string and time arguments" do
48
+ describe "for humanizing time differences" do
49
+ it "accepts string and time arguments" do
51
50
  start = '2009-01-01 01:01:00'
52
51
  stop = Time.parse '2009-01-01 01:03:00'
53
52
  assert_commutative([2, 'min'], [start, stop]) do |a, b|
@@ -55,7 +54,7 @@ class SupportTest < UnitTestCase
55
54
  end
56
55
  end
57
56
 
58
- should "use second granularity for time differences smaller than a minute" do
57
+ it "uses second granularity for time differences smaller than a minute" do
59
58
  [
60
59
  [0, '2009-01-01 01:00:00', '2009-01-01 01:00:00'],
61
60
  [1, '2009-01-01 00:00:59', '2009-01-01 00:01:00'],
@@ -68,7 +67,7 @@ class SupportTest < UnitTestCase
68
67
  end
69
68
  end
70
69
 
71
- should "use minute granularity for time differences greater than a minute but smaller than an hour" do
70
+ it "uses minute granularity for time differences greater than a minute but smaller than an hour" do
72
71
  [
73
72
  [1, '2009-01-01 01:00:00', '2009-01-01 01:01:00'],
74
73
  [2, '2009-01-01 01:01:00', '2009-01-01 01:03:29'],
@@ -83,7 +82,7 @@ class SupportTest < UnitTestCase
83
82
  end
84
83
  end
85
84
 
86
- should "use hour granularity for time differences greater than an hour but smaller than a day" do
85
+ it "uses hour granularity for time differences greater than an hour but smaller than a day" do
87
86
  [
88
87
  [1, 'hour', '2009-01-01 01:00', '2009-01-01 02:00'],
89
88
  [2, 'hours', '2009-01-01 01:00', '2009-01-01 03:00'],
@@ -96,7 +95,7 @@ class SupportTest < UnitTestCase
96
95
  end
97
96
  end
98
97
 
99
- should "use day granularity for time differences greater than a day" do
98
+ it "uses day granularity for time differences greater than a day" do
100
99
  [
101
100
  [1, 'day', '2009-01-01 01:00', '2009-01-02 01:00'],
102
101
  [2, 'days', '2009-01-01 01:00', '2009-01-03 01:00'],
@@ -110,7 +109,7 @@ class SupportTest < UnitTestCase
110
109
  end
111
110
  end
112
111
 
113
- context "for recursively copying a hash" do
112
+ describe "for recursively copying a hash" do
114
113
  ALL_KEYS_STRINGS = {
115
114
  'alpha' => 'A',
116
115
  'beta' => 'B',
@@ -130,7 +129,7 @@ class SupportTest < UnitTestCase
130
129
  }
131
130
  }
132
131
 
133
- should "stringify hash keys" do
132
+ it "stringifies hash keys" do
134
133
  given = {
135
134
  :alpha => 'A',
136
135
  'beta' => 'B',
@@ -143,7 +142,7 @@ class SupportTest < UnitTestCase
143
142
  assert_equal ALL_KEYS_STRINGS, stringify_hash_keys(given)
144
143
  end
145
144
 
146
- should "symbolize hash keys" do
145
+ it "symbolizes hash keys" do
147
146
  given = {
148
147
  'alpha' => 'A',
149
148
  :beta => 'B',
@@ -156,30 +155,30 @@ class SupportTest < UnitTestCase
156
155
  assert_equal ALL_KEYS_SYMBOLS, symbolize_hash_keys(given)
157
156
  end
158
157
 
159
- should "have symmetric property for stringify and symbolize" do
158
+ it "has symmetric property for stringify and symbolize" do
160
159
  assert_equal ALL_KEYS_STRINGS, stringify_hash_keys(symbolize_hash_keys(ALL_KEYS_STRINGS))
161
160
  assert_equal ALL_KEYS_SYMBOLS, symbolize_hash_keys(stringify_hash_keys(ALL_KEYS_SYMBOLS))
162
161
  end
163
162
  end
164
163
 
165
- context "for parsing integers from strings, with minimum and default values, and naming parameter" do
166
- should "return an integer from its string presentation" do
164
+ describe "for parsing integers from strings, with minimum and default values, and naming parameter" do
165
+ it "returns an integer from its string presentation" do
167
166
  assert_equal 6, parse_int_gt("6", 8, 4, "ethical working hours per day")
168
167
  end
169
168
 
170
- should "return default value if the string parameter is falsy" do
169
+ it "returns default value if the string parameter is falsy" do
171
170
  assert_equal 8, parse_int_gt(nil, 8, 4, "ethical working hours per day")
172
171
  assert_equal 8, parse_int_gt(false, 8, 4, "ethical working hours per day")
173
172
  end
174
173
 
175
- should "raise an error if the parsed value is less than the minimum parameter" do
176
- assert_raise(ArgumentError) { parse_int_gt(3, 8, 4, "ethical working hours per day") }
177
- assert_raise(ArgumentError) { parse_int_gt("3", 8, 4, "ethical working hours per day") }
174
+ it "raises an error if the parsed value is less than the minimum parameter" do
175
+ assert_raises(ArgumentError) { parse_int_gt(3, 8, 4, "ethical working hours per day") }
176
+ assert_raises(ArgumentError) { parse_int_gt("3", 8, 4, "ethical working hours per day") }
178
177
  end
179
178
  end
180
179
 
181
- context "for replacing the contents of a string with a regexp that uses group syntax" do
182
- should "replace the contents of the string by using a single matching group of the regexp" do
180
+ describe "for replacing the contents of a string with a regexp that uses group syntax" do
181
+ it "replaces the contents of the string by using a single matching group of the regexp" do
183
182
  assert_equal "hEllo", str_gsub_by_group("hello", /.+(e)/) { |s| s.upcase }
184
183
  assert_equal "hEllO", str_gsub_by_group("hello", /([aeio])/) { |s| s.upcase }
185
184
  assert_equal "h<b>e</b>ll<b>o</b>", str_gsub_by_group("hello", /([aeio])/) { |s| "<b>#{s}</b>" }
@@ -187,7 +186,7 @@ class SupportTest < UnitTestCase
187
186
  assert_equal "hell", str_gsub_by_group("hello", /.+([io])/) { |s| "" }
188
187
  end
189
188
 
190
- should "replace the contents of the string by using multiple matching groups of the regexp" do
189
+ it "replaces the contents of the string by using multiple matching groups of the regexp" do
191
190
  assert_equal "hEllO", str_gsub_by_group("hello", /([ae]).+([io])/) { |s| s.upcase }
192
191
  assert_equal "h<b>e</b>ll<b>o</b>", str_gsub_by_group("hello", /([ae]).+([io])/) { |s| "<b>#{s}</b>" }
193
192
  assert_equal "hll", str_gsub_by_group("hello", /.+([ae]).+([io])/) { |s| "" }
@@ -195,32 +194,32 @@ class SupportTest < UnitTestCase
195
194
  assert_equal "hEllo", str_gsub_by_group("hello", /^(a)|.+(e)/) { |s| s.upcase }
196
195
  end
197
196
 
198
- should "replace the contents of the string by using the whole regexp if there are no groups in the regexp an the regexp matches" do
197
+ it "replaces the contents of the string by using the whole regexp if there are no groups in the regexp an the regexp matches" do
199
198
  assert_equal "", str_gsub_by_group("", /el/) { |s| s.upcase }
200
199
  assert_equal "hELlo", str_gsub_by_group("hello", /el/) { |s| s.upcase }
201
200
  assert_equal "h<b>e</b>ll<b>o</b>", str_gsub_by_group("hello", /e|o/) { |s| "<b>#{s}</b>" }
202
201
  end
203
202
 
204
- should "not change the contents of the string if the regexp does not match" do
203
+ it "does not change the contents of the string if the regexp does not match" do
205
204
  assert_equal "", str_gsub_by_group("", /.+([ai])/) { |s| s.upcase }
206
205
  assert_equal "hello", str_gsub_by_group("hello", /.+([ai])/) { |s| s.upcase }
207
206
  assert_equal "hello", str_gsub_by_group("hello", /he(f)/) { |s| s.upcase }
208
207
  end
209
208
 
210
- should "return a new string as the result, leaving the original string unmodified" do
209
+ it "returns a new string as the result, leaving the original string unmodified" do
211
210
  org_str = "hello"
212
211
  new_str = str_gsub_by_group(org_str, /e/) { |s| s.upcase }
213
- assert_not_same new_str, org_str
212
+ refute_same new_str, org_str
214
213
  assert_equal "hello", org_str
215
214
  assert_equal "hEllo", new_str
216
215
  end
217
216
 
218
- should "work with UTF-8 input" do
217
+ it "works with UTF-8 input" do
219
218
  assert_equal "Ali<b>en</b>³,<b>Pre</b>dator", str_gsub_by_group("Alien³,Predator", /(en).+(Pre)/) { |s| "<b>#{s}</b>" }
220
219
  end
221
220
  end
222
221
 
223
- context "for unescaping HTML" do
222
+ describe "for unescaping HTML" do
224
223
  [
225
224
  %w{a a},
226
225
  %w{B B},
@@ -230,7 +229,7 @@ class SupportTest < UnitTestCase
230
229
  %w{_ underscore},
231
230
  %w{+ plus}
232
231
  ].each do |(char, desc)|
233
- should "not affect already unescaped characters, case #{desc}" do
232
+ it "does not affect already unescaped characters, case #{desc}" do
234
233
  assert_equal char, unescape_html(char)
235
234
  end
236
235
  end
@@ -242,14 +241,14 @@ class SupportTest < UnitTestCase
242
241
  %w{&quot; "},
243
242
  %W{&nbsp; \ }
244
243
  ].each do |(input, expected)|
245
- should "unescape HTML-escaped characters, case '#{input}'" do
244
+ it "unescapes HTML-escaped characters, case '#{input}'" do
246
245
  assert_equal expected, unescape_html(input)
247
246
  end
248
247
  end
249
248
  end
250
249
 
251
- context "for traversing a hash with a path expression for finding a value" do
252
- setup do
250
+ describe "for traversing a hash with a path expression for finding a value" do
251
+ before do
253
252
  @inner_hash = {
254
253
  :salmon => "slick"
255
254
  }
@@ -262,22 +261,22 @@ class SupportTest < UnitTestCase
262
261
  @outer_hash.default = "no such element in outer hash"
263
262
  end
264
263
 
265
- should "support both a non-array and a single element array path for finding the value" do
264
+ it "supports both a non-array and a single element array path for finding the value" do
266
265
  assert_equal @outer_hash[:simple], find_hash_path(@outer_hash, :simple)
267
266
  assert_equal @outer_hash[:simple], find_hash_path(@outer_hash, [:simple])
268
267
  end
269
268
 
270
- should "find a nested value with an array path" do
269
+ it "finds a nested value with an array path" do
271
270
  assert_equal @inner_hash[:salmon], find_hash_path(@outer_hash, [:inner, :salmon])
272
271
  end
273
272
 
274
- should "return the default value of the hash if the value cannot be found" do
273
+ it "returns the default value of the hash if the value cannot be found" do
275
274
  assert_equal @outer_hash.default, find_hash_path(@outer_hash, :difficult)
276
275
  assert_equal @inner_hash.default, find_hash_path(@outer_hash, [:inner, :cucumber])
277
276
  assert_equal @outer_hash.default, find_hash_path(@outer_hash, [:fishy, :no_such])
278
277
  end
279
278
 
280
- should "return the default value of the hash if invalid path value" do
279
+ it "returns the default value of the hash if invalid path value" do
281
280
  [
282
281
  nil,
283
282
  [:no_such, nil],
@@ -289,7 +288,7 @@ class SupportTest < UnitTestCase
289
288
  end
290
289
  end
291
290
 
292
- should "return nil if nil hash value" do
291
+ it "returns nil if nil hash value" do
293
292
  assert_equal nil, find_hash_path(nil, [:salmon])
294
293
  end
295
294
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'timecop'
4
4
 
5
- module Tweetwine::Test
5
+ module Tweetwine::Test::Unit
6
6
  module TweetHelper
7
7
  FIELD_PATHS = {
8
8
  :from_user => %w{screen_name},
@@ -1,150 +1,150 @@
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 TweetTest < UnitTestCase
8
+ class TweetTest < TestCase
9
9
  include TweetHelper
10
10
 
11
- context "for initialization" do
12
- should "raise exception if from user field is not found" do
13
- assert_raise(ArgumentError) { create_tweet(:from_user => nil) }
11
+ describe "for initialization" do
12
+ it "raises exception if from user field is not found" do
13
+ assert_raises(ArgumentError) { create_tweet(:from_user => nil) }
14
14
  end
15
15
  end
16
16
 
17
- context "for equality" do
18
- should "equal to another tweet with same content" do
17
+ describe "for equality" do
18
+ it "equals to another tweet with same content" do
19
19
  status = 'foo'
20
20
  first = create_tweet(:status => status)
21
21
  second = create_tweet(:status => status)
22
22
  assert_equal first, second
23
23
  end
24
24
 
25
- should "not equal to another tweet with different content" do
25
+ it "does not equal to another tweet with different content" do
26
26
  first = create_tweet(:status => 'ahem')
27
27
  second = create_tweet(:status => 'hmph')
28
- assert_not_equal first, second
28
+ refute_equal first, second
29
29
  end
30
30
  end
31
31
 
32
- context "for handling regular tweet" do
33
- setup do
32
+ describe "for handling regular tweet" do
33
+ before do
34
34
  @status = 'lurking'
35
35
  @tweet = create_tweet(:status => @status)
36
36
  end
37
37
 
38
- should "detect tweet as not retweet" do
38
+ it "detects tweet as not retweet" do
39
39
  assert_equal false, @tweet.retweet?
40
40
  end
41
41
 
42
- should "not have retweeting user" do
42
+ it "does not have retweeting user" do
43
43
  assert_nil @tweet.rt_user
44
44
  end
45
45
 
46
- should "have originating user field" do
46
+ it "has originating user field" do
47
47
  assert_equal(DEFAULT_FIELD_VALUES[:from_user], @tweet.from_user)
48
48
  end
49
49
 
50
- should "detect tweet as not being a reply" do
50
+ it "detects tweet as not being a reply" do
51
51
  assert_equal false, @tweet.reply?
52
52
  end
53
53
 
54
- should "have no destination user" do
54
+ it "has no destination user" do
55
55
  assert_nil @tweet.to_user
56
56
  end
57
57
 
58
- should "detect having creation timestamp" do
58
+ it "detects having creation timestamp" do
59
59
  assert_equal true, @tweet.timestamped?
60
60
  end
61
61
 
62
- should "have creation timestamp" do
62
+ it "has creation timestamp" do
63
63
  assert_equal Time.parse(DEFAULT_FIELD_VALUES[:created_at]), @tweet.created_at
64
64
  end
65
65
 
66
- should "detect having status" do
66
+ it "detects having status" do
67
67
  assert_equal true, @tweet.status?
68
68
  end
69
69
 
70
- should "have status" do
70
+ it "has status" do
71
71
  assert_equal @status, @tweet.status
72
72
  end
73
73
  end
74
74
 
75
- context "for handling replying tweet" do
76
- setup do
75
+ describe "for handling replying tweet" do
76
+ before do
77
77
  @to_user = 'jacko'
78
78
  @tweet = create_tweet(:to_user => @to_user)
79
79
  end
80
80
 
81
- should "detect tweet as being a reply" do
81
+ it "detects tweet as being a reply" do
82
82
  assert_equal true, @tweet.reply?
83
83
  end
84
84
 
85
- should "have destination user" do
85
+ it "has destination user" do
86
86
  assert_equal @to_user, @tweet.to_user
87
87
  end
88
88
  end
89
89
 
90
- context "for handling retweet" do
91
- setup do
90
+ describe "for handling retweet" do
91
+ before do
92
92
  @rt_user = 'jonathan'
93
93
  @status = 'tweet worth retweeting'
94
94
  @tweet = create_tweet(:rt_user => @rt_user, :status => @status)
95
95
  end
96
96
 
97
- should "detect tweet as retweet" do
97
+ it "detects tweet as retweet" do
98
98
  assert_equal true, @tweet.retweet?
99
99
  end
100
100
 
101
- should "have retweeting user" do
101
+ it "has retweeting user" do
102
102
  assert_equal @rt_user, @tweet.rt_user
103
103
  end
104
104
 
105
- should "have originating user" do
105
+ it "has originating user" do
106
106
  assert_equal DEFAULT_FIELD_VALUES[:from_user], @tweet.from_user
107
107
  end
108
108
 
109
- should "detect having creation timestamp of the original tweet" do
109
+ it "detects having creation timestamp of the original tweet" do
110
110
  assert_equal true, @tweet.timestamped?
111
111
  end
112
112
 
113
- should "have creation timestamp of the original tweet" do
113
+ it "has creation timestamp of the original tweet" do
114
114
  assert_equal Time.parse(DEFAULT_FIELD_VALUES[:created_at]), @tweet.created_at
115
115
  end
116
116
 
117
- should "detect having status of the original tweet" do
117
+ it "detects having status of the original tweet" do
118
118
  assert_equal true, @tweet.status?
119
119
  end
120
120
 
121
- should "have status of the original tweet" do
121
+ it "has status of the original tweet" do
122
122
  assert_equal @status, @tweet.status
123
123
  end
124
124
  end
125
125
 
126
- context "for handling tweet with just user info" do
127
- setup do
126
+ describe "for handling tweet with just user info" do
127
+ before do
128
128
  @tweet = create_tweet(:to_user => nil, :status => nil, :created_at => nil)
129
129
  end
130
130
 
131
- should "detect tweet as not retweet" do
131
+ it "detects tweet as not retweet" do
132
132
  assert_equal false, @tweet.retweet?
133
133
  end
134
134
 
135
- should "have originating user field" do
135
+ it "has originating user field" do
136
136
  assert_equal(DEFAULT_FIELD_VALUES[:from_user], @tweet.from_user)
137
137
  end
138
138
 
139
- should "detect tweet as not being a reply" do
139
+ it "detects tweet as not being a reply" do
140
140
  assert_equal false, @tweet.reply?
141
141
  end
142
142
 
143
- should "detect having no creation timestamp" do
143
+ it "detects having no creation timestamp" do
144
144
  assert_equal false, @tweet.timestamped?
145
145
  end
146
146
 
147
- should "detect having no status" do
147
+ it "detects having no status" do
148
148
  assert_equal false, @tweet.status?
149
149
  end
150
150
  end