tweetwine 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
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,111 +0,0 @@
1
- # coding: utf-8
2
-
3
- require "test_helper"
4
-
5
- require "contest"
6
- require "mocha"
7
-
8
- Mocha::Configuration.prevent(:stubbing_non_existent_method)
9
-
10
- module Tweetwine::Test
11
- module Assertions
12
- # Asserts whether an Enumeration-like object contains all the elements.
13
- # Fails unless +actual+ contains the same elements as +expected+, ignoring
14
- # the order of the elements.
15
- def assert_contains_exactly(expected, actual, msg_diff_size = nil, msg_diff_elems = nil)
16
- assert_equal(expected.size, actual.size, message(msg_diff_size) {
17
- 'Expected %s to be of same size as %s' % [actual.inspect, expected.inspect]
18
- })
19
- assert(enumerable_minus_each_element(actual, expected).empty?, message(msg_diff_elems) {
20
- 'Expected %s to contain all the elements of %s' % [actual.inspect, expected.inspect]
21
- })
22
- end
23
-
24
- # Fails unless +str+ is a full match to +regex+.
25
- def assert_full_match(regex, str, msg = nil)
26
- match_data = regex.match(str)
27
- assert(str == match_data.to_s, message(msg) {
28
- 'Expected %s to be a full match to %s' % [str, regex.inspect]
29
- })
30
- end
31
-
32
- # Fails if +str+ is a full match to +regex+.
33
- def assert_no_full_match(regex, str, msg = nil)
34
- match_data = regex.match(str)
35
- assert(str != match_data.to_s, message(msg) {
36
- 'Expected %s not to be a full match to %s' % [str, regex.inspect]
37
- })
38
- end
39
-
40
- # Fails unless +fun.call(*args)+ is equal to +expected+ and
41
- # +fun.call(*args)+ is equal to +fun.call(*args.reverse)+.
42
- def assert_commutative(expected, args, msg_not_expected = nil, msg_not_commutative = nil, &fun)
43
- left_args = args
44
- left_actual = fun.call(left_args)
45
- assert_equal(expected, left_actual, message(msg_not_expected) {
46
- 'Expected %s, not %s' % [expected.inspect, left_actual.inspect]
47
- })
48
- right_args = args.reverse
49
- right_actual = fun.call(*right_args)
50
- assert_equal(left_actual, right_actual, message(msg_not_commutative) {
51
- 'Expected fun%s => %s to be commutative with fun%s => %s' %
52
- [left_args.inspect, left_actual.inspect, right_args.inspect, right_actual.inspect]
53
- })
54
- end
55
-
56
- private
57
-
58
- def message(given, &default)
59
- given.nil? ? default.call : given
60
- end
61
-
62
- def enumerable_minus_each_element(enumerable, elements)
63
- remaining = enumerable.dup.to_a
64
- elements.each do |e|
65
- index = remaining.index(e)
66
- remaining.delete_at(index) if index
67
- end
68
- remaining
69
- end
70
- end
71
-
72
- module Doubles
73
- def mock_config
74
- @config = mock('Config')
75
- Tweetwine::CLI.stubs(:config).returns(@config)
76
- end
77
-
78
- def mock_http
79
- @http = mock('Http')
80
- Tweetwine::CLI.stubs(:http).returns(@http)
81
- end
82
-
83
- def mock_oauth
84
- @oauth = mock('OAuth')
85
- Tweetwine::CLI.stubs(:oauth).returns(@oauth)
86
- end
87
-
88
- def mock_ui
89
- @ui = mock('UI')
90
- Tweetwine::CLI.stubs(:ui).returns(@ui)
91
- end
92
-
93
- def mock_url_shortener
94
- @url_shortener = mock('UrlShortener')
95
- Tweetwine::CLI.stubs(:url_shortener).returns(@url_shortener)
96
- end
97
-
98
- def stub_config(options = {})
99
- @config = options
100
- Tweetwine::CLI.stubs(:config).returns(@config)
101
- end
102
- end
103
-
104
- class UnitTestCase < ::Test::Unit::TestCase
105
- include WebMock::API
106
- include Tweetwine
107
- include Helper
108
- include Assertions
109
- include Doubles
110
- end
111
- end