tweetwine 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/Rakefile +22 -23
- data/lib/tweetwine/cli.rb +167 -165
- data/lib/tweetwine/config.rb +3 -2
- data/lib/tweetwine/exceptions.rb +1 -0
- data/lib/tweetwine/version.rb +1 -1
- data/project.rb +16 -16
- data/test/fixture/{config_example.yaml → config_integration.yaml} +0 -0
- data/test/fixture/oauth.rb +11 -11
- data/test/{test_helper.rb → helper.rb} +16 -7
- data/test/{example/authorization_example.rb → integration/authorization_test.rb} +17 -17
- data/test/integration/global_options_test.rb +67 -0
- data/test/integration/helper.rb +70 -0
- data/test/integration/invalid_config_file_test.rb +28 -0
- data/test/integration/search_statuses_test.rb +81 -0
- data/test/integration/show_followers_test.rb +24 -0
- data/test/integration/show_friends_test.rb +24 -0
- data/test/integration/show_home_test.rb +47 -0
- data/test/integration/show_mentions_test.rb +24 -0
- data/test/integration/show_user_test.rb +48 -0
- data/test/integration/update_status_test.rb +199 -0
- data/test/integration/use_http_proxy_test.rb +71 -0
- data/test/{example/user_help_example.rb → integration/user_help_test.rb} +36 -36
- data/test/unit/character_encoding_test.rb +19 -15
- data/test/unit/cli_test.rb +9 -10
- data/test/unit/config_test.rb +73 -71
- data/test/unit/helper.rb +108 -0
- data/test/unit/http_test.rb +39 -39
- data/test/unit/oauth_test.rb +15 -16
- data/test/unit/obfuscate_test.rb +4 -4
- data/test/unit/option_parser_test.rb +12 -12
- data/test/unit/promise_test.rb +10 -10
- data/test/unit/support_test.rb +44 -45
- data/test/unit/tweet_helper.rb +1 -1
- data/test/unit/tweet_test.rb +42 -42
- data/test/unit/twitter_test.rb +300 -303
- data/test/unit/ui_test.rb +310 -312
- data/test/unit/uri_test.rb +7 -7
- data/test/unit/url_shortener_test.rb +77 -79
- data/tweetwine.gemspec +6 -15
- metadata +55 -145
- data/test/example/example_helper.rb +0 -58
- data/test/example/global_options_example.rb +0 -64
- data/test/example/search_statuses_example.rb +0 -76
- data/test/example/show_followers_example.rb +0 -24
- data/test/example/show_friends_example.rb +0 -24
- data/test/example/show_home_example.rb +0 -44
- data/test/example/show_mentions_example.rb +0 -24
- data/test/example/show_user_example.rb +0 -44
- data/test/example/update_status_example.rb +0 -183
- data/test/example/use_http_proxy_example.rb +0 -68
- data/test/unit/unit_helper.rb +0 -111
data/test/unit/unit_helper.rb
DELETED
@@ -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
|