t 2.0.1 → 2.0.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.
- data.tar.gz.sig +0 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +12 -12
- data/Rakefile +11 -1
- data/bin/t +11 -11
- data/lib/t.rb +7 -9
- data/lib/t/cli.rb +299 -360
- data/lib/t/collectable.rb +2 -4
- data/lib/t/core_ext/kernel.rb +3 -5
- data/lib/t/core_ext/string.rb +4 -6
- data/lib/t/delete.rb +27 -29
- data/lib/t/editor.rb +1 -3
- data/lib/t/list.rb +44 -45
- data/lib/t/printable.rb +43 -44
- data/lib/t/rcfile.rb +4 -5
- data/lib/t/requestable.rb +1 -3
- data/lib/t/search.rb +42 -55
- data/lib/t/set.rb +11 -12
- data/lib/t/stream.rb +24 -20
- data/lib/t/utils.rb +20 -28
- data/lib/t/version.rb +1 -3
- data/spec/cli_spec.rb +1241 -1242
- data/spec/delete_spec.rb +122 -122
- data/spec/editor_spec.rb +42 -42
- data/spec/fixtures/lists.json +1 -1
- data/spec/fixtures/locations.json +1 -1
- data/spec/helper.rb +17 -13
- data/spec/list_spec.rb +202 -202
- data/spec/rcfile_spec.rb +73 -73
- data/spec/search_spec.rb +398 -398
- data/spec/set_spec.rb +72 -72
- data/spec/stream_spec.rb +56 -56
- data/spec/utils_spec.rb +29 -29
- data/t.gemspec +1 -1
- metadata +56 -32
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
data/spec/fixtures/lists.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[{"uri":"/pengwynn/rubyists","name":"Rubyists","full_name":"@pengwynn/rubyists","description":"","mode":"public","user":{"id":14100886,"profile_background_image_url_https":"https://si0.twimg.com/images/themes/theme1/bg.png","time_zone":"Central Time (US & Canada)","location":"Denton, TX","profile_background_image_url":"http://a0.twimg.com/images/themes/theme1/bg.png","id_str":"14100886","profile_link_color":"0084B4","geo_enabled":true,"default_profile":false,"profile_image_url":"http://a0.twimg.com/profile_images/2221455972/wynn-mic-bw_normal.jpg","utc_offset":-21600,"profile_use_background_image":false,"statuses_count":7384,"name":"Wynn Netherland","follow_request_sent":false,"profile_text_color":"333333","lang":"en","screen_name":"pengwynn","listed_count":397,"protected":false,"is_translator":false,"followers_count":6182,"profile_sidebar_border_color":"FFFFFF","description":"Christian, husband, father, GitHubber, Co-host of @thechangelog, Co-author of Sass, Compass, #CSS book http://wynn.fm/sass-meap","profile_image_url_https":"https://si0.twimg.com/profile_images/2221455972/wynn-mic-bw_normal.jpg","profile_background_tile":false,"following":true,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"url":"http://wynnnetherland.com","profile_banner_url":"https://si0.twimg.com/profile_banners/14100886/1347987369","favourites_count":338,"created_at":"Sat Mar 08 16:34:22 +0000 2008","friends_count":3528,"verified":false,"notifications":false,"profile_background_color":"292929","contributors_enabled":false},"following":true,"created_at":"Fri Oct 30 14:39:25 +0000 2009","member_count":499,"id_str":"1129440","subscriber_count":39,"slug":"rubyists","id":1129440},{"uri":"/twitter/team","name":"Team","full_name":"@twitter/team","description":"","mode":"
|
1
|
+
[{"uri":"/pengwynn/rubyists","name":"Rubyists","full_name":"@pengwynn/rubyists","description":"","mode":"public","user":{"id":14100886,"profile_background_image_url_https":"https://si0.twimg.com/images/themes/theme1/bg.png","time_zone":"Central Time (US & Canada)","location":"Denton, TX","profile_background_image_url":"http://a0.twimg.com/images/themes/theme1/bg.png","id_str":"14100886","profile_link_color":"0084B4","geo_enabled":true,"default_profile":false,"profile_image_url":"http://a0.twimg.com/profile_images/2221455972/wynn-mic-bw_normal.jpg","utc_offset":-21600,"profile_use_background_image":false,"statuses_count":7384,"name":"Wynn Netherland","follow_request_sent":false,"profile_text_color":"333333","lang":"en","screen_name":"pengwynn","listed_count":397,"protected":false,"is_translator":false,"followers_count":6182,"profile_sidebar_border_color":"FFFFFF","description":"Christian, husband, father, GitHubber, Co-host of @thechangelog, Co-author of Sass, Compass, #CSS book http://wynn.fm/sass-meap","profile_image_url_https":"https://si0.twimg.com/profile_images/2221455972/wynn-mic-bw_normal.jpg","profile_background_tile":false,"following":true,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"url":"http://wynnnetherland.com","profile_banner_url":"https://si0.twimg.com/profile_banners/14100886/1347987369","favourites_count":338,"created_at":"Sat Mar 08 16:34:22 +0000 2008","friends_count":3528,"verified":false,"notifications":false,"profile_background_color":"292929","contributors_enabled":false},"following":true,"created_at":"Fri Oct 30 14:39:25 +0000 2009","member_count":499,"id_str":"1129440","subscriber_count":39,"slug":"rubyists","id":1129440},{"uri":"/twitter/team","name":"Team","full_name":"@twitter/team","description":"","mode":"other","user":{"id":783214,"profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/657090062/l1uqey5sy82r9ijhke1i.png","time_zone":"Pacific Time (US & Canada)","location":"San Francisco, CA","profile_background_image_url":"http://a0.twimg.com/profile_background_images/657090062/l1uqey5sy82r9ijhke1i.png","id_str":"783214","profile_link_color":"038543","geo_enabled":true,"default_profile":false,"profile_image_url":"http://a0.twimg.com/profile_images/2284174758/v65oai7fxn47qv9nectx_normal.png","utc_offset":-28800,"profile_use_background_image":true,"statuses_count":1433,"name":"Twitter","follow_request_sent":false,"profile_text_color":"333333","lang":"en","screen_name":"twitter","listed_count":73287,"protected":false,"followers_count":13711595,"profile_sidebar_border_color":"EEEEEE","is_translator":false,"description":"Always wondering what's happening. ","profile_background_tile":true,"following":true,"profile_sidebar_fill_color":"F6F6F6","default_profile_image":false,"url":"http://blog.twitter.com/","profile_banner_url":"https://si0.twimg.com/profile_banners/783214/1347405327","favourites_count":18,"created_at":"Tue Feb 20 14:35:54 +0000 2007","friends_count":1249,"verified":true,"notifications":false,"profile_image_url_https":"https://si0.twimg.com/profile_images/2284174758/v65oai7fxn47qv9nectx_normal.png","profile_background_color":"ACDED6","contributors_enabled":true},"following":true,"created_at":"Wed Sep 23 01:18:01 +0000 2009","member_count":1199,"id_str":"574","subscriber_count":78078,"slug":"team","id":574},{"uri":"/sferik/test","name":"test","full_name":"@sferik/test","description":"","mode":"private","user":{"id":7505382,"profile_background_image_url_https":"https://si0.twimg.com/profile_background_images/665875854/bb0b3653dcf0644e344823e0a2eb3382.png","time_zone":"Pacific Time (US & Canada)","location":"San Francisco","profile_background_image_url":"http://a0.twimg.com/profile_background_images/665875854/bb0b3653dcf0644e344823e0a2eb3382.png","id_str":"7505382","profile_link_color":"0084B4","geo_enabled":true,"default_profile":false,"profile_image_url":"http://a0.twimg.com/profile_images/1759857427/image1326743606_normal.png","utc_offset":-28800,"profile_use_background_image":true,"statuses_count":8576,"name":"Erik Michaels-Ober","follow_request_sent":false,"profile_text_color":"333333","lang":"en","screen_name":"sferik","listed_count":129,"protected":false,"followers_count":2449,"profile_sidebar_border_color":"000000","profile_image_url_https":"https://si0.twimg.com/profile_images/1759857427/image1326743606_normal.png","description":"An ingredient in your recipe.","is_translator":false,"profile_background_tile":false,"following":false,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"url":"https://github.com/sferik","favourites_count":4321,"created_at":"Mon Jul 16 12:59:01 +0000 2007","friends_count":203,"verified":false,"notifications":false,"profile_background_color":"000000","contributors_enabled":false},"following":false,"created_at":"Sun Jul 08 22:19:05 +0000 2012","member_count":2,"id_str":"73546689","subscriber_count":0,"slug":"test","id":73546689}]
|
@@ -1 +1 @@
|
|
1
|
-
[{"placeType":{"code":
|
1
|
+
[{"name":"Worldwide","placeType":{"code":19,"name":"Supername"},"url":"http:\/\/where.yahooapis.com\/v1\/place\/1","parentid":0,"country":"","woeid":1,"countryCode":null},{"name":"San Francisco","placeType":{"code":7,"name":"Town"},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2487956","parentid":23424977,"country":"United States","woeid":2487956,"countryCode":"US"},{"name":"United States","placeType":{"code":12,"name":"Country"},"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424977","parentid":1,"country":"United States","woeid":23424977,"countryCode":"US"},{"name":"Soweto","placeType":{"code":22,"name":"Unknown"},"url":"http:\/\/where.yahooapis.com\/v1\/place\/1587677","parentid":23424942,"country":"South Africa","woeid":1587677,"countryCode":"ZA"}]
|
data/spec/helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ENV['THOR_COLUMNS'] =
|
1
|
+
ENV['THOR_COLUMNS'] = '80'
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
4
|
require 'coveralls'
|
@@ -7,7 +7,11 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
7
7
|
SimpleCov::Formatter::HTMLFormatter,
|
8
8
|
Coveralls::SimpleCov::Formatter
|
9
9
|
]
|
10
|
-
|
10
|
+
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/spec/'
|
13
|
+
minimum_coverage(99.16)
|
14
|
+
end
|
11
15
|
|
12
16
|
require 't'
|
13
17
|
require 'json'
|
@@ -21,48 +25,48 @@ RSpec.configure do |config|
|
|
21
25
|
end
|
22
26
|
|
23
27
|
config.before(:each) do
|
24
|
-
stub_post(
|
28
|
+
stub_post('/oauth2/token').with(:body => 'grant_type=client_credentials').to_return(:body => fixture('bearer_token.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
def a_delete(path, endpoint='https://api.twitter.com')
|
32
|
+
def a_delete(path, endpoint = 'https://api.twitter.com')
|
29
33
|
a_request(:delete, endpoint + path)
|
30
34
|
end
|
31
35
|
|
32
|
-
def a_get(path, endpoint='https://api.twitter.com')
|
36
|
+
def a_get(path, endpoint = 'https://api.twitter.com')
|
33
37
|
a_request(:get, endpoint + path)
|
34
38
|
end
|
35
39
|
|
36
|
-
def a_post(path, endpoint='https://api.twitter.com')
|
40
|
+
def a_post(path, endpoint = 'https://api.twitter.com')
|
37
41
|
a_request(:post, endpoint + path)
|
38
42
|
end
|
39
43
|
|
40
|
-
def a_put(path, endpoint='https://api.twitter.com')
|
44
|
+
def a_put(path, endpoint = 'https://api.twitter.com')
|
41
45
|
a_request(:put, endpoint + path)
|
42
46
|
end
|
43
47
|
|
44
|
-
def stub_delete(path, endpoint='https://api.twitter.com')
|
48
|
+
def stub_delete(path, endpoint = 'https://api.twitter.com')
|
45
49
|
stub_request(:delete, endpoint + path)
|
46
50
|
end
|
47
51
|
|
48
|
-
def stub_get(path, endpoint='https://api.twitter.com')
|
52
|
+
def stub_get(path, endpoint = 'https://api.twitter.com')
|
49
53
|
stub_request(:get, endpoint + path)
|
50
54
|
end
|
51
55
|
|
52
|
-
def stub_post(path, endpoint='https://api.twitter.com')
|
56
|
+
def stub_post(path, endpoint = 'https://api.twitter.com')
|
53
57
|
stub_request(:post, endpoint + path)
|
54
58
|
end
|
55
59
|
|
56
|
-
def stub_put(path, endpoint='https://api.twitter.com')
|
60
|
+
def stub_put(path, endpoint = 'https://api.twitter.com')
|
57
61
|
stub_request(:put, endpoint + path)
|
58
62
|
end
|
59
63
|
|
60
64
|
def project_path
|
61
|
-
File.expand_path(
|
65
|
+
File.expand_path('../..', __FILE__)
|
62
66
|
end
|
63
67
|
|
64
68
|
def fixture_path
|
65
|
-
File.expand_path(
|
69
|
+
File.expand_path('../fixtures', __FILE__)
|
66
70
|
end
|
67
71
|
|
68
72
|
def fixture(file)
|
data/spec/list_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe T::List do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
before :each do
|
17
|
-
T::RCFile.instance.path = fixture_path +
|
17
|
+
T::RCFile.instance.path = fixture_path + '/.trc'
|
18
18
|
@list = T::List.new
|
19
19
|
@old_stderr = $stderr
|
20
20
|
$stderr = StringIO.new
|
@@ -28,69 +28,69 @@ describe T::List do
|
|
28
28
|
$stdout = @old_stdout
|
29
29
|
end
|
30
30
|
|
31
|
-
describe
|
31
|
+
describe '#add' do
|
32
32
|
before do
|
33
|
-
@list.options = @list.options.merge(
|
34
|
-
stub_get(
|
35
|
-
stub_post(
|
33
|
+
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
34
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
35
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:body => fixture('list.json'))
|
36
36
|
end
|
37
|
-
it
|
38
|
-
@list.add(
|
39
|
-
expect(a_get(
|
40
|
-
expect(a_post(
|
37
|
+
it 'requests the correct resource' do
|
38
|
+
@list.add('presidents', 'BarackObama')
|
39
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
40
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made
|
41
41
|
end
|
42
|
-
it
|
43
|
-
@list.add(
|
42
|
+
it 'has the correct output' do
|
43
|
+
@list.add('presidents', 'BarackObama')
|
44
44
|
expect($stdout.string.split("\n").first).to eq "@testcli added 1 member to the list \"presidents\"."
|
45
45
|
end
|
46
|
-
context
|
46
|
+
context '--id' do
|
47
47
|
before do
|
48
|
-
@list.options = @list.options.merge(
|
49
|
-
stub_post(
|
48
|
+
@list.options = @list.options.merge('id' => true)
|
49
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:body => fixture('list.json'))
|
50
50
|
end
|
51
|
-
it
|
52
|
-
@list.add(
|
53
|
-
expect(a_get(
|
54
|
-
expect(a_post(
|
51
|
+
it 'requests the correct resource' do
|
52
|
+
@list.add('presidents', '7505382')
|
53
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
54
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made
|
55
55
|
end
|
56
56
|
end
|
57
|
-
context
|
58
|
-
it
|
59
|
-
stub_post(
|
57
|
+
context 'Twitter is down' do
|
58
|
+
it 'retries 3 times and then raise an error' do
|
59
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:status => 502)
|
60
60
|
expect do
|
61
|
-
@list.add(
|
61
|
+
@list.add('presidents', 'BarackObama')
|
62
62
|
end.to raise_error(Twitter::Error::BadGateway)
|
63
|
-
expect(a_post(
|
63
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made.times(3)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
describe
|
68
|
+
describe '#create' do
|
69
69
|
before do
|
70
|
-
@list.options = @list.options.merge(
|
71
|
-
stub_post(
|
70
|
+
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
71
|
+
stub_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'}).to_return(:body => fixture('list.json'))
|
72
72
|
end
|
73
|
-
it
|
74
|
-
@list.create(
|
75
|
-
expect(a_post(
|
73
|
+
it 'requests the correct resource' do
|
74
|
+
@list.create('presidents')
|
75
|
+
expect(a_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'})).to have_been_made
|
76
76
|
end
|
77
|
-
it
|
78
|
-
@list.create(
|
77
|
+
it 'has the correct output' do
|
78
|
+
@list.create('presidents')
|
79
79
|
expect($stdout.string.chomp).to eq "@testcli created the list \"presidents\"."
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
describe
|
83
|
+
describe '#information' do
|
84
84
|
before do
|
85
|
-
@list.options = @list.options.merge(
|
86
|
-
stub_get(
|
85
|
+
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
86
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
87
87
|
end
|
88
|
-
it
|
89
|
-
@list.information(
|
90
|
-
expect(a_get(
|
88
|
+
it 'requests the correct resource' do
|
89
|
+
@list.information('presidents')
|
90
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
91
91
|
end
|
92
|
-
it
|
93
|
-
@list.information(
|
92
|
+
it 'has the correct output' do
|
93
|
+
@list.information('presidents')
|
94
94
|
expect($stdout.string).to eq <<-eos
|
95
95
|
ID 8863586
|
96
96
|
Description Presidents of the United States of America
|
@@ -104,28 +104,28 @@ Mode public
|
|
104
104
|
URL https://twitter.com/sferik/presidents
|
105
105
|
eos
|
106
106
|
end
|
107
|
-
context
|
108
|
-
it
|
109
|
-
@list.information(
|
110
|
-
expect(a_get(
|
107
|
+
context 'with a user passed' do
|
108
|
+
it 'requests the correct resource' do
|
109
|
+
@list.information('testcli/presidents')
|
110
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
111
111
|
end
|
112
|
-
context
|
112
|
+
context '--id' do
|
113
113
|
before do
|
114
|
-
@list.options = @list.options.merge(
|
115
|
-
stub_get(
|
114
|
+
@list.options = @list.options.merge('id' => true)
|
115
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('list.json'))
|
116
116
|
end
|
117
|
-
it
|
118
|
-
@list.information(
|
119
|
-
expect(a_get(
|
117
|
+
it 'requests the correct resource' do
|
118
|
+
@list.information('7505382/presidents')
|
119
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :slug => 'presidents'})).to have_been_made
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
|
-
context
|
123
|
+
context '--csv' do
|
124
124
|
before do
|
125
|
-
@list.options = @list.options.merge(
|
125
|
+
@list.options = @list.options.merge('csv' => true)
|
126
126
|
end
|
127
|
-
it
|
128
|
-
@list.information(
|
127
|
+
it 'has the correct output' do
|
128
|
+
@list.information('presidents')
|
129
129
|
expect($stdout.string).to eq <<-eos
|
130
130
|
ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,URL
|
131
131
|
8863586,Presidents of the United States of America,presidents,sferik,2010-03-15 12:10:13 +0000,2,1,false,public,https://twitter.com/sferik/presidents
|
@@ -134,24 +134,24 @@ ID,Description,Slug,Screen name,Created at,Members,Subscribers,Following,Mode,UR
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
137
|
+
describe '#members' do
|
138
138
|
before do
|
139
|
-
stub_get(
|
139
|
+
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
|
140
140
|
end
|
141
|
-
it
|
142
|
-
@list.members(
|
143
|
-
expect(a_get(
|
141
|
+
it 'requests the correct resource' do
|
142
|
+
@list.members('presidents')
|
143
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
144
144
|
end
|
145
|
-
it
|
146
|
-
@list.members(
|
147
|
-
expect($stdout.string.chomp).to eq
|
145
|
+
it 'has the correct output' do
|
146
|
+
@list.members('presidents')
|
147
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
148
148
|
end
|
149
|
-
context
|
149
|
+
context '--csv' do
|
150
150
|
before do
|
151
|
-
@list.options = @list.options.merge(
|
151
|
+
@list.options = @list.options.merge('csv' => true)
|
152
152
|
end
|
153
|
-
it
|
154
|
-
@list.members(
|
153
|
+
it 'outputs in CSV format' do
|
154
|
+
@list.members('presidents')
|
155
155
|
expect($stdout.string).to eq <<-eos
|
156
156
|
ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name,Name,Verified,Protected,Bio,Status,Location,URL
|
157
157
|
14100886,2008-03-08 16:34:22 +0000,2012-07-07 20:33:19 +0000,6940,192,358,3427,5457,pengwynn,Wynn Netherland,false,false,"Christian, husband, father, GitHubber, Co-host of @thechangelog, Co-author of Sass, Compass, #CSS book http://wynn.fm/sass-meap",@akosmasoftware Sass book! @hcatlin @nex3 are the brains behind Sass. :-),"Denton, TX",http://wynnnetherland.com
|
@@ -159,12 +159,12 @@ ID,Since,Last tweeted at,Tweets,Favorites,Listed,Following,Followers,Screen name
|
|
159
159
|
eos
|
160
160
|
end
|
161
161
|
end
|
162
|
-
context
|
162
|
+
context '--long' do
|
163
163
|
before do
|
164
|
-
@list.options = @list.options.merge(
|
164
|
+
@list.options = @list.options.merge('long' => true)
|
165
165
|
end
|
166
|
-
it
|
167
|
-
@list.members(
|
166
|
+
it 'outputs in long format' do
|
167
|
+
@list.members('presidents')
|
168
168
|
expect($stdout.string).to eq <<-eos
|
169
169
|
ID Since Last tweeted at Tweets Favorites Listed Following...
|
170
170
|
14100886 Mar 8 2008 Jul 7 12:33 6940 192 358 3427...
|
@@ -172,154 +172,154 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
172
172
|
eos
|
173
173
|
end
|
174
174
|
end
|
175
|
-
context
|
175
|
+
context '--reverse' do
|
176
176
|
before do
|
177
|
-
@list.options = @list.options.merge(
|
177
|
+
@list.options = @list.options.merge('reverse' => true)
|
178
178
|
end
|
179
|
-
it
|
180
|
-
@list.members(
|
181
|
-
expect($stdout.string.chomp).to eq
|
179
|
+
it 'reverses the order of the sort' do
|
180
|
+
@list.members('presidents')
|
181
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
182
182
|
end
|
183
183
|
end
|
184
|
-
context
|
184
|
+
context '--sort=favorites' do
|
185
185
|
before do
|
186
|
-
@list.options = @list.options.merge(
|
186
|
+
@list.options = @list.options.merge('sort' => 'favorites')
|
187
187
|
end
|
188
|
-
it
|
189
|
-
@list.members(
|
190
|
-
expect($stdout.string.chomp).to eq
|
188
|
+
it 'sorts by the number of favorites' do
|
189
|
+
@list.members('presidents')
|
190
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
191
191
|
end
|
192
192
|
end
|
193
|
-
context
|
193
|
+
context '--sort=followers' do
|
194
194
|
before do
|
195
|
-
@list.options = @list.options.merge(
|
195
|
+
@list.options = @list.options.merge('sort' => 'followers')
|
196
196
|
end
|
197
|
-
it
|
198
|
-
@list.members(
|
199
|
-
expect($stdout.string.chomp).to eq
|
197
|
+
it 'sorts by the number of followers' do
|
198
|
+
@list.members('presidents')
|
199
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
200
200
|
end
|
201
201
|
end
|
202
|
-
context
|
202
|
+
context '--sort=friends' do
|
203
203
|
before do
|
204
|
-
@list.options = @list.options.merge(
|
204
|
+
@list.options = @list.options.merge('sort' => 'friends')
|
205
205
|
end
|
206
|
-
it
|
207
|
-
@list.members(
|
208
|
-
expect($stdout.string.chomp).to eq
|
206
|
+
it 'sorts by the number of friends' do
|
207
|
+
@list.members('presidents')
|
208
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
209
209
|
end
|
210
210
|
end
|
211
|
-
context
|
211
|
+
context '--sort=listed' do
|
212
212
|
before do
|
213
|
-
@list.options = @list.options.merge(
|
213
|
+
@list.options = @list.options.merge('sort' => 'listed')
|
214
214
|
end
|
215
|
-
it
|
216
|
-
@list.members(
|
217
|
-
expect($stdout.string.chomp).to eq
|
215
|
+
it 'sorts by the number of list memberships' do
|
216
|
+
@list.members('presidents')
|
217
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
218
218
|
end
|
219
219
|
end
|
220
|
-
context
|
220
|
+
context '--sort=since' do
|
221
221
|
before do
|
222
|
-
@list.options = @list.options.merge(
|
222
|
+
@list.options = @list.options.merge('sort' => 'since')
|
223
223
|
end
|
224
|
-
it
|
225
|
-
@list.members(
|
226
|
-
expect($stdout.string.chomp).to eq
|
224
|
+
it 'sorts by the time when Twitter account was created' do
|
225
|
+
@list.members('presidents')
|
226
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
227
227
|
end
|
228
228
|
end
|
229
|
-
context
|
229
|
+
context '--sort=tweets' do
|
230
230
|
before do
|
231
|
-
@list.options = @list.options.merge(
|
231
|
+
@list.options = @list.options.merge('sort' => 'tweets')
|
232
232
|
end
|
233
|
-
it
|
234
|
-
@list.members(
|
235
|
-
expect($stdout.string.chomp).to eq
|
233
|
+
it 'sorts by the number of Tweets' do
|
234
|
+
@list.members('presidents')
|
235
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
236
236
|
end
|
237
237
|
end
|
238
|
-
context
|
238
|
+
context '--sort=tweeted' do
|
239
239
|
before do
|
240
|
-
@list.options = @list.options.merge(
|
240
|
+
@list.options = @list.options.merge('sort' => 'tweeted')
|
241
241
|
end
|
242
|
-
it
|
243
|
-
@list.members(
|
244
|
-
expect($stdout.string.chomp).to eq
|
242
|
+
it 'sorts by the time of the last Tweet' do
|
243
|
+
@list.members('presidents')
|
244
|
+
expect($stdout.string.chomp).to eq 'pengwynn sferik'
|
245
245
|
end
|
246
246
|
end
|
247
|
-
context
|
247
|
+
context '--unsorted' do
|
248
248
|
before do
|
249
|
-
@list.options = @list.options.merge(
|
249
|
+
@list.options = @list.options.merge('unsorted' => true)
|
250
250
|
end
|
251
|
-
it
|
252
|
-
@list.members(
|
253
|
-
expect($stdout.string.chomp).to eq
|
251
|
+
it 'is not sorted' do
|
252
|
+
@list.members('presidents')
|
253
|
+
expect($stdout.string.chomp).to eq 'sferik pengwynn'
|
254
254
|
end
|
255
255
|
end
|
256
|
-
context
|
257
|
-
it
|
258
|
-
@list.members(
|
259
|
-
expect(a_get(
|
256
|
+
context 'with a user passed' do
|
257
|
+
it 'requests the correct resource' do
|
258
|
+
@list.members('testcli/presidents')
|
259
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_screen_name => 'testcli', :slug => 'presidents'})).to have_been_made
|
260
260
|
end
|
261
|
-
context
|
261
|
+
context '--id' do
|
262
262
|
before do
|
263
|
-
@list.options = @list.options.merge(
|
264
|
-
stub_get(
|
263
|
+
@list.options = @list.options.merge('id' => true)
|
264
|
+
stub_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_id => '7505382', :slug => 'presidents'}).to_return(:body => fixture('users_list.json'))
|
265
265
|
end
|
266
|
-
it
|
267
|
-
@list.members(
|
268
|
-
expect(a_get(
|
266
|
+
it 'requests the correct resource' do
|
267
|
+
@list.members('7505382/presidents')
|
268
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:cursor => '-1', :owner_id => '7505382', :slug => 'presidents'})).to have_been_made
|
269
269
|
end
|
270
270
|
end
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe
|
274
|
+
describe '#remove' do
|
275
275
|
before do
|
276
|
-
@list.options = @list.options.merge(
|
277
|
-
stub_get(
|
278
|
-
end
|
279
|
-
it
|
280
|
-
stub_post(
|
281
|
-
@list.remove(
|
282
|
-
expect(a_get(
|
283
|
-
expect(a_post(
|
284
|
-
end
|
285
|
-
it
|
286
|
-
stub_post(
|
287
|
-
@list.remove(
|
276
|
+
@list.options = @list.options.merge('profile' => fixture_path + '/.trc')
|
277
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'))
|
278
|
+
end
|
279
|
+
it 'requests the correct resource' do
|
280
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:body => fixture('list.json'))
|
281
|
+
@list.remove('presidents', 'BarackObama')
|
282
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
283
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made
|
284
|
+
end
|
285
|
+
it 'has the correct output' do
|
286
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:body => fixture('list.json'))
|
287
|
+
@list.remove('presidents', 'BarackObama')
|
288
288
|
expect($stdout.string.split("\n").first).to eq "@testcli removed 1 member from the list \"presidents\"."
|
289
289
|
end
|
290
|
-
context
|
290
|
+
context '--id' do
|
291
291
|
before do
|
292
|
-
@list.options = @list.options.merge(
|
293
|
-
stub_post(
|
292
|
+
@list.options = @list.options.merge('id' => true)
|
293
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:body => fixture('list.json'))
|
294
294
|
end
|
295
|
-
it
|
296
|
-
@list.remove(
|
297
|
-
expect(a_get(
|
298
|
-
expect(a_post(
|
295
|
+
it 'requests the correct resource' do
|
296
|
+
@list.remove('presidents', '7505382')
|
297
|
+
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
|
298
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:user_id => '7505382', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made
|
299
299
|
end
|
300
300
|
end
|
301
|
-
context
|
302
|
-
it
|
303
|
-
stub_post(
|
301
|
+
context 'Twitter is down' do
|
302
|
+
it 'retries 3 times and then raise an error' do
|
303
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'}).to_return(:status => 502)
|
304
304
|
expect do
|
305
|
-
@list.remove(
|
305
|
+
@list.remove('presidents', 'BarackObama')
|
306
306
|
end.to raise_error(Twitter::Error::BadGateway)
|
307
|
-
expect(a_post(
|
307
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:screen_name => 'BarackObama', :slug => 'presidents', :owner_screen_name => 'sferik'})).to have_been_made.times(3)
|
308
308
|
end
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
describe
|
312
|
+
describe '#timeline' do
|
313
313
|
before do
|
314
|
-
@list.options = @list.options.merge(
|
315
|
-
stub_get(
|
314
|
+
@list.options = @list.options.merge('color' => 'always')
|
315
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'))
|
316
316
|
end
|
317
|
-
it
|
318
|
-
@list.timeline(
|
319
|
-
expect(a_get(
|
317
|
+
it 'requests the correct resource' do
|
318
|
+
@list.timeline('presidents')
|
319
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents'})).to have_been_made
|
320
320
|
end
|
321
|
-
it
|
322
|
-
@list.timeline(
|
321
|
+
it 'has the correct output' do
|
322
|
+
@list.timeline('presidents')
|
323
323
|
expect($stdout.string).to eq <<-eos
|
324
324
|
@mutgoff
|
325
325
|
Happy Birthday @imdane. Watch out for those @rally pranksters!
|
@@ -398,12 +398,12 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
398
398
|
|
399
399
|
eos
|
400
400
|
end
|
401
|
-
context
|
401
|
+
context '--color=never' do
|
402
402
|
before do
|
403
|
-
@list.options = @list.options.merge(
|
403
|
+
@list.options = @list.options.merge('color' => 'never')
|
404
404
|
end
|
405
|
-
it
|
406
|
-
@list.timeline(
|
405
|
+
it 'outputs without color' do
|
406
|
+
@list.timeline('presidents')
|
407
407
|
expect($stdout.string).to eq <<-eos
|
408
408
|
@mutgoff
|
409
409
|
Happy Birthday @imdane. Watch out for those @rally pranksters!
|
@@ -483,12 +483,12 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
483
483
|
eos
|
484
484
|
end
|
485
485
|
end
|
486
|
-
context
|
486
|
+
context '--color=auto' do
|
487
487
|
before do
|
488
|
-
@list.options = @list.options.merge(
|
488
|
+
@list.options = @list.options.merge('color' => 'auto')
|
489
489
|
end
|
490
|
-
it
|
491
|
-
@list.timeline(
|
490
|
+
it 'outputs without color when stdout is not a tty' do
|
491
|
+
@list.timeline('presidents')
|
492
492
|
expect($stdout.string).to eq <<-eos
|
493
493
|
@mutgoff
|
494
494
|
Happy Birthday @imdane. Watch out for those @rally pranksters!
|
@@ -567,9 +567,9 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
567
567
|
|
568
568
|
eos
|
569
569
|
end
|
570
|
-
it
|
570
|
+
it 'outputs with color when stdout is a tty' do
|
571
571
|
allow($stdout).to receive(:"tty?").and_return(true)
|
572
|
-
@list.timeline(
|
572
|
+
@list.timeline('presidents')
|
573
573
|
expect($stdout.string).to eq <<-eos
|
574
574
|
\e[1m\e[33m @mutgoff\e[0m
|
575
575
|
Happy Birthday @imdane. Watch out for those @rally pranksters!
|
@@ -650,12 +650,12 @@ ID Since Last tweeted at Tweets Favorites Listed Following...
|
|
650
650
|
end
|
651
651
|
end
|
652
652
|
|
653
|
-
context
|
653
|
+
context '--csv' do
|
654
654
|
before do
|
655
|
-
@list.options = @list.options.merge(
|
655
|
+
@list.options = @list.options.merge('csv' => true)
|
656
656
|
end
|
657
|
-
it
|
658
|
-
@list.timeline(
|
657
|
+
it 'outputs in long format' do
|
658
|
+
@list.timeline('presidents')
|
659
659
|
expect($stdout.string).to eq <<-eos
|
660
660
|
ID,Posted at,Screen name,Text
|
661
661
|
4611686018427387904,2012-09-07 16:35:24 +0000,mutgoff,Happy Birthday @imdane. Watch out for those @rally pranksters!
|
@@ -681,12 +681,12 @@ ID,Posted at,Screen name,Text
|
|
681
681
|
eos
|
682
682
|
end
|
683
683
|
end
|
684
|
-
context
|
684
|
+
context '--long' do
|
685
685
|
before do
|
686
|
-
@list.options = @list.options.merge(
|
686
|
+
@list.options = @list.options.merge('long' => true)
|
687
687
|
end
|
688
|
-
it
|
689
|
-
@list.timeline(
|
688
|
+
it 'outputs in long format' do
|
689
|
+
@list.timeline('presidents')
|
690
690
|
expect($stdout.string).to eq <<-eos
|
691
691
|
ID Posted at Screen name Text
|
692
692
|
4611686018427387904 Sep 7 08:35 @mutgoff Happy Birthday @imdane. ...
|
@@ -711,12 +711,12 @@ ID Posted at Screen name Text
|
|
711
711
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
712
712
|
eos
|
713
713
|
end
|
714
|
-
context
|
714
|
+
context '--reverse' do
|
715
715
|
before do
|
716
|
-
@list.options = @list.options.merge(
|
716
|
+
@list.options = @list.options.merge('reverse' => true)
|
717
717
|
end
|
718
|
-
it
|
719
|
-
@list.timeline(
|
718
|
+
it 'reverses the order of the sort' do
|
719
|
+
@list.timeline('presidents')
|
720
720
|
expect($stdout.string).to eq <<-eos
|
721
721
|
ID Posted at Screen name Text
|
722
722
|
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
|
@@ -743,37 +743,37 @@ ID Posted at Screen name Text
|
|
743
743
|
end
|
744
744
|
end
|
745
745
|
end
|
746
|
-
context
|
746
|
+
context '--number' do
|
747
747
|
before do
|
748
|
-
stub_get(
|
749
|
-
stub_get(
|
750
|
-
stub_get(
|
748
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'))
|
749
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '200', :slug => 'presidents'}).to_return(:body => fixture('200_statuses.json'))
|
750
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :max_id => '265500541700956160', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'))
|
751
751
|
end
|
752
|
-
it
|
753
|
-
@list.options = @list.options.merge(
|
754
|
-
@list.timeline(
|
755
|
-
expect(a_get(
|
752
|
+
it 'limits the number of results to 1' do
|
753
|
+
@list.options = @list.options.merge('number' => 1)
|
754
|
+
@list.timeline('presidents')
|
755
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :slug => 'presidents'})).to have_been_made
|
756
756
|
end
|
757
|
-
it
|
758
|
-
@list.options = @list.options.merge(
|
759
|
-
@list.timeline(
|
760
|
-
expect(a_get(
|
761
|
-
expect(a_get(
|
757
|
+
it 'limits the number of results to 201' do
|
758
|
+
@list.options = @list.options.merge('number' => 201)
|
759
|
+
@list.timeline('presidents')
|
760
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '200', :slug => 'presidents'})).to have_been_made
|
761
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '1', :max_id => '265500541700956160', :slug => 'presidents'})).to have_been_made
|
762
762
|
end
|
763
763
|
end
|
764
|
-
context
|
765
|
-
it
|
766
|
-
@list.timeline(
|
767
|
-
expect(a_get(
|
764
|
+
context 'with a user passed' do
|
765
|
+
it 'requests the correct resource' do
|
766
|
+
@list.timeline('testcli/presidents')
|
767
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'testcli', :count => '20', :slug => 'presidents'})).to have_been_made
|
768
768
|
end
|
769
|
-
context
|
769
|
+
context '--id' do
|
770
770
|
before do
|
771
|
-
@list.options = @list.options.merge(
|
772
|
-
stub_get(
|
771
|
+
@list.options = @list.options.merge('id' => true)
|
772
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :count => '20', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'))
|
773
773
|
end
|
774
|
-
it
|
775
|
-
@list.timeline(
|
776
|
-
expect(a_get(
|
774
|
+
it 'requests the correct resource' do
|
775
|
+
@list.timeline('7505382/presidents')
|
776
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_id => '7505382', :count => '20', :slug => 'presidents'})).to have_been_made
|
777
777
|
end
|
778
778
|
end
|
779
779
|
end
|