twitter 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +30 -20
- data/Rakefile +26 -5
- data/lib/twitter/arguments.rb +0 -1
- data/lib/twitter/base.rb +13 -16
- data/lib/twitter/basic_user.rb +3 -3
- data/lib/twitter/client.rb +7 -8
- data/lib/twitter/configuration.rb +5 -5
- data/lib/twitter/core_ext/enumerable.rb +0 -2
- data/lib/twitter/core_ext/kernel.rb +0 -2
- data/lib/twitter/creatable.rb +0 -1
- data/lib/twitter/cursor.rb +7 -10
- data/lib/twitter/direct_message.rb +1 -1
- data/lib/twitter/entity/uri.rb +2 -2
- data/lib/twitter/enumerable.rb +1 -2
- data/lib/twitter/error.rb +4 -6
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +1 -1
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/factory.rb +2 -6
- data/lib/twitter/geo.rb +1 -1
- data/lib/twitter/geo/point.rb +3 -5
- data/lib/twitter/geo_factory.rb +1 -5
- data/lib/twitter/geo_results.rb +5 -8
- data/lib/twitter/identity.rb +1 -2
- data/lib/twitter/list.rb +4 -5
- data/lib/twitter/media/photo.rb +1 -2
- data/lib/twitter/media_factory.rb +1 -5
- data/lib/twitter/null_object.rb +4 -6
- data/lib/twitter/oembed.rb +1 -1
- data/lib/twitter/place.rb +4 -5
- data/lib/twitter/profile_banner.rb +1 -3
- data/lib/twitter/rate_limit.rb +1 -3
- data/lib/twitter/relationship.rb +1 -2
- data/lib/twitter/rest/api/direct_messages.rb +13 -14
- data/lib/twitter/rest/api/favorites.rb +10 -11
- data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
- data/lib/twitter/rest/api/help.rb +8 -9
- data/lib/twitter/rest/api/lists.rb +62 -63
- data/lib/twitter/rest/api/oauth.rb +3 -4
- data/lib/twitter/rest/api/places_and_geo.rb +9 -10
- data/lib/twitter/rest/api/saved_searches.rb +5 -6
- data/lib/twitter/rest/api/search.rb +2 -3
- data/lib/twitter/rest/api/spam_reporting.rb +1 -2
- data/lib/twitter/rest/api/suggested_users.rb +4 -5
- data/lib/twitter/rest/api/timelines.rb +17 -18
- data/lib/twitter/rest/api/trends.rb +10 -11
- data/lib/twitter/rest/api/tweets.rb +15 -16
- data/lib/twitter/rest/api/undocumented.rb +6 -7
- data/lib/twitter/rest/api/users.rb +51 -52
- data/lib/twitter/rest/api/utils.rb +23 -30
- data/lib/twitter/rest/client.rb +8 -9
- data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
- data/lib/twitter/rest/response/parse_error_json.rb +0 -2
- data/lib/twitter/rest/response/parse_json.rb +0 -2
- data/lib/twitter/rest/response/raise_error.rb +1 -3
- data/lib/twitter/search_results.rb +12 -15
- data/lib/twitter/settings.rb +2 -2
- data/lib/twitter/size.rb +2 -2
- data/lib/twitter/source_user.rb +1 -1
- data/lib/twitter/streaming/client.rb +71 -18
- data/lib/twitter/streaming/connection.rb +1 -3
- data/lib/twitter/streaming/deleted_tweet.rb +8 -0
- data/lib/twitter/streaming/event.rb +8 -8
- data/lib/twitter/streaming/friend_list.rb +2 -9
- data/lib/twitter/streaming/message_parser.rb +13 -7
- data/lib/twitter/streaming/response.rb +0 -2
- data/lib/twitter/streaming/stall_warning.rb +7 -0
- data/lib/twitter/suggestion.rb +0 -1
- data/lib/twitter/token.rb +2 -3
- data/lib/twitter/trend_results.rb +5 -8
- data/lib/twitter/tweet.rb +16 -24
- data/lib/twitter/user.rb +30 -32
- data/lib/twitter/version.rb +2 -5
- data/spec/fixtures/track_streaming_user.json +2 -1
- data/spec/helper.rb +6 -2
- data/spec/twitter/base_spec.rb +9 -9
- data/spec/twitter/basic_user_spec.rb +6 -6
- data/spec/twitter/configuration_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +27 -27
- data/spec/twitter/direct_message_spec.rb +36 -36
- data/spec/twitter/entity/uri_spec.rb +27 -27
- data/spec/twitter/error_spec.rb +21 -21
- data/spec/twitter/geo/point_spec.rb +9 -9
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +7 -7
- data/spec/twitter/geo_results_spec.rb +11 -11
- data/spec/twitter/geo_spec.rb +5 -5
- data/spec/twitter/identifiable_spec.rb +9 -9
- data/spec/twitter/list_spec.rb +38 -38
- data/spec/twitter/media/photo_spec.rb +54 -54
- data/spec/twitter/media_factory_spec.rb +5 -5
- data/spec/twitter/null_object_spec.rb +6 -6
- data/spec/twitter/oembed_spec.rb +65 -65
- data/spec/twitter/place_spec.rb +89 -60
- data/spec/twitter/profile_banner_spec.rb +3 -3
- data/spec/twitter/rate_limit_spec.rb +18 -18
- data/spec/twitter/relationship_spec.rb +16 -16
- data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
- data/spec/twitter/rest/api/favorites_spec.rb +93 -93
- data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
- data/spec/twitter/rest/api/geo_spec.rb +33 -33
- data/spec/twitter/rest/api/help_spec.rb +24 -24
- data/spec/twitter/rest/api/lists_spec.rb +487 -487
- data/spec/twitter/rest/api/oauth_spec.rb +30 -30
- data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
- data/spec/twitter/rest/api/search_spec.rb +16 -16
- data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
- data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
- data/spec/twitter/rest/api/timelines_spec.rb +58 -58
- data/spec/twitter/rest/api/trends_spec.rb +26 -26
- data/spec/twitter/rest/api/tweets_spec.rb +284 -284
- data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
- data/spec/twitter/rest/api/users_spec.rb +360 -360
- data/spec/twitter/rest/client_spec.rb +99 -103
- data/spec/twitter/saved_search_spec.rb +16 -16
- data/spec/twitter/search_results_spec.rb +44 -44
- data/spec/twitter/settings_spec.rb +8 -8
- data/spec/twitter/size_spec.rb +5 -5
- data/spec/twitter/source_user_spec.rb +6 -6
- data/spec/twitter/streaming/client_spec.rb +53 -49
- data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
- data/spec/twitter/streaming/event_spec.rb +20 -22
- data/spec/twitter/streaming/friend_list_spec.rb +11 -0
- data/spec/twitter/streaming/message_parser_spec.rb +54 -0
- data/spec/twitter/suggestion_spec.rb +11 -11
- data/spec/twitter/target_user_spec.rb +6 -6
- data/spec/twitter/token_spec.rb +4 -4
- data/spec/twitter/trend_results_spec.rb +30 -30
- data/spec/twitter/trend_spec.rb +20 -20
- data/spec/twitter/tweet_spec.rb +170 -173
- data/spec/twitter/user_spec.rb +179 -179
- data/twitter.gemspec +2 -2
- metadata +21 -4
- metadata.gz.sig +2 -1
@@ -3,65 +3,65 @@ require 'helper'
|
|
3
3
|
describe Twitter::REST::API::PlacesAndGeo do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
6
|
+
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#place' do
|
10
10
|
before do
|
11
|
-
stub_get(
|
11
|
+
stub_get('/1.1/geo/id/247f43d441defc03.json').to_return(:body => fixture('place.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
12
12
|
end
|
13
|
-
it
|
14
|
-
@client.place(
|
15
|
-
expect(a_get(
|
13
|
+
it 'requests the correct resource' do
|
14
|
+
@client.place('247f43d441defc03')
|
15
|
+
expect(a_get('/1.1/geo/id/247f43d441defc03.json')).to have_been_made
|
16
16
|
end
|
17
|
-
it
|
18
|
-
place = @client.place(
|
19
|
-
expect(place.name).to eq(
|
17
|
+
it 'returns a place' do
|
18
|
+
place = @client.place('247f43d441defc03')
|
19
|
+
expect(place.name).to eq('Twitter HQ')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
23
|
+
describe '#reverse_geocode' do
|
24
24
|
before do
|
25
|
-
stub_get(
|
25
|
+
stub_get('/1.1/geo/reverse_geocode.json').with(:query => {:lat => '37.7821120598956', :long => '-122.400612831116'}).to_return(:body => fixture('places.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
26
26
|
end
|
27
|
-
it
|
28
|
-
@client.reverse_geocode(:lat =>
|
29
|
-
expect(a_get(
|
27
|
+
it 'requests the correct resource' do
|
28
|
+
@client.reverse_geocode(:lat => '37.7821120598956', :long => '-122.400612831116')
|
29
|
+
expect(a_get('/1.1/geo/reverse_geocode.json').with(:query => {:lat => '37.7821120598956', :long => '-122.400612831116'})).to have_been_made
|
30
30
|
end
|
31
|
-
it
|
32
|
-
places = @client.reverse_geocode(:lat =>
|
31
|
+
it 'returns places' do
|
32
|
+
places = @client.reverse_geocode(:lat => '37.7821120598956', :long => '-122.400612831116')
|
33
33
|
expect(places).to be_a Twitter::GeoResults
|
34
|
-
expect(places.first.name).to eq(
|
34
|
+
expect(places.first.name).to eq('Bernal Heights')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe '#geo_search' do
|
39
39
|
before do
|
40
|
-
stub_get(
|
40
|
+
stub_get('/1.1/geo/search.json').with(:query => {:ip => '74.125.19.104'}).to_return(:body => fixture('places.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
41
41
|
end
|
42
|
-
it
|
43
|
-
@client.geo_search(:ip =>
|
44
|
-
expect(a_get(
|
42
|
+
it 'requests the correct resource' do
|
43
|
+
@client.geo_search(:ip => '74.125.19.104')
|
44
|
+
expect(a_get('/1.1/geo/search.json').with(:query => {:ip => '74.125.19.104'})).to have_been_made
|
45
45
|
end
|
46
|
-
it
|
47
|
-
places = @client.geo_search(:ip =>
|
46
|
+
it 'returns nearby places' do
|
47
|
+
places = @client.geo_search(:ip => '74.125.19.104')
|
48
48
|
expect(places).to be_a Twitter::GeoResults
|
49
|
-
expect(places.first.name).to eq(
|
49
|
+
expect(places.first.name).to eq('Bernal Heights')
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
describe
|
53
|
+
describe '#similar_places' do
|
54
54
|
before do
|
55
|
-
stub_get(
|
55
|
+
stub_get('/1.1/geo/similar_places.json').with(:query => {:lat => '37.7821120598956', :long => '-122.400612831116', :name => 'Twitter HQ'}).to_return(:body => fixture('places.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
56
56
|
end
|
57
|
-
it
|
58
|
-
@client.similar_places(:lat =>
|
59
|
-
expect(a_get(
|
57
|
+
it 'requests the correct resource' do
|
58
|
+
@client.similar_places(:lat => '37.7821120598956', :long => '-122.400612831116', :name => 'Twitter HQ')
|
59
|
+
expect(a_get('/1.1/geo/similar_places.json').with(:query => {:lat => '37.7821120598956', :long => '-122.400612831116', :name => 'Twitter HQ'})).to have_been_made
|
60
60
|
end
|
61
|
-
it
|
62
|
-
places = @client.similar_places(:lat =>
|
61
|
+
it 'returns similar places' do
|
62
|
+
places = @client.similar_places(:lat => '37.7821120598956', :long => '-122.400612831116', :name => 'Twitter HQ')
|
63
63
|
expect(places).to be_a Twitter::GeoResults
|
64
|
-
expect(places.first.name).to eq(
|
64
|
+
expect(places.first.name).to eq('Bernal Heights')
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -3,65 +3,65 @@ require 'helper'
|
|
3
3
|
describe Twitter::REST::API::Help do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
6
|
+
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#configuration' do
|
10
10
|
before do
|
11
|
-
stub_get(
|
11
|
+
stub_get('/1.1/help/configuration.json').to_return(:body => fixture('configuration.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
12
12
|
end
|
13
|
-
it
|
13
|
+
it 'requests the correct resource' do
|
14
14
|
@client.configuration
|
15
|
-
expect(a_get(
|
15
|
+
expect(a_get('/1.1/help/configuration.json')).to have_been_made
|
16
16
|
end
|
17
|
-
it
|
17
|
+
it 'returns the Twitter configuration' do
|
18
18
|
configuration = @client.configuration
|
19
19
|
expect(configuration).to be_a Twitter::Configuration
|
20
20
|
expect(configuration.characters_reserved_per_media).to eq(20)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe '#languages' do
|
25
25
|
before do
|
26
|
-
stub_get(
|
26
|
+
stub_get('/1.1/help/languages.json').to_return(:body => fixture('languages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
27
27
|
end
|
28
|
-
it
|
28
|
+
it 'requests the correct resource' do
|
29
29
|
@client.languages
|
30
|
-
expect(a_get(
|
30
|
+
expect(a_get('/1.1/help/languages.json')).to have_been_made
|
31
31
|
end
|
32
|
-
it
|
32
|
+
it 'returns the list of languages supported by Twitter' do
|
33
33
|
languages = @client.languages
|
34
34
|
expect(languages).to be_an Array
|
35
35
|
expect(languages.first).to be_a Twitter::Language
|
36
|
-
expect(languages.first.name).to eq(
|
36
|
+
expect(languages.first.name).to eq('Portuguese')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
40
|
+
describe '#privacy' do
|
41
41
|
before do
|
42
|
-
stub_get(
|
42
|
+
stub_get('/1.1/help/privacy.json').to_return(:body => fixture('privacy.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
43
43
|
end
|
44
|
-
it
|
44
|
+
it 'requests the correct resource' do
|
45
45
|
@client.privacy
|
46
|
-
expect(a_get(
|
46
|
+
expect(a_get('/1.1/help/privacy.json')).to have_been_made
|
47
47
|
end
|
48
|
-
it
|
48
|
+
it 'returns the Twitter Privacy Policy' do
|
49
49
|
privacy = @client.privacy
|
50
|
-
expect(privacy.split.first).to eq(
|
50
|
+
expect(privacy.split.first).to eq('Twitter')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe '#tos' do
|
55
55
|
before do
|
56
|
-
stub_get(
|
56
|
+
stub_get('/1.1/help/tos.json').to_return(:body => fixture('tos.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
57
57
|
end
|
58
|
-
it
|
58
|
+
it 'requests the correct resource' do
|
59
59
|
@client.tos
|
60
|
-
expect(a_get(
|
60
|
+
expect(a_get('/1.1/help/tos.json')).to have_been_made
|
61
61
|
end
|
62
|
-
it
|
62
|
+
it 'returns the Twitter Terms of Service' do
|
63
63
|
tos = @client.tos
|
64
|
-
expect(tos.split.first).to eq(
|
64
|
+
expect(tos.split.first).to eq('Terms')
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -3,885 +3,885 @@ require 'helper'
|
|
3
3
|
describe Twitter::REST::API::Lists do
|
4
4
|
|
5
5
|
before do
|
6
|
-
@client = Twitter::REST::Client.new(:consumer_key =>
|
6
|
+
@client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe '#lists' do
|
10
10
|
before do
|
11
|
-
stub_get(
|
11
|
+
stub_get('/1.1/lists/list.json').to_return(:body => fixture('lists.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
12
12
|
end
|
13
|
-
it
|
13
|
+
it 'requests the correct resource' do
|
14
14
|
@client.lists
|
15
|
-
expect(a_get(
|
15
|
+
expect(a_get('/1.1/lists/list.json')).to have_been_made
|
16
16
|
end
|
17
|
-
it
|
17
|
+
it 'returns the requested list' do
|
18
18
|
lists = @client.lists
|
19
19
|
expect(lists).to be_an Array
|
20
20
|
expect(lists.first).to be_a Twitter::List
|
21
|
-
expect(lists.first.name).to eq(
|
21
|
+
expect(lists.first.name).to eq('Rubyists')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
context
|
25
|
+
describe '#list_timeline' do
|
26
|
+
context 'with a screen name passed' do
|
27
27
|
before do
|
28
|
-
stub_get(
|
28
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
29
29
|
end
|
30
|
-
it
|
31
|
-
@client.list_timeline(
|
32
|
-
expect(a_get(
|
30
|
+
it 'requests the correct resource' do
|
31
|
+
@client.list_timeline('sferik', 'presidents')
|
32
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
33
33
|
end
|
34
|
-
it
|
35
|
-
tweets = @client.list_timeline(
|
34
|
+
it 'returns the timeline for members of the specified list' do
|
35
|
+
tweets = @client.list_timeline('sferik', 'presidents')
|
36
36
|
expect(tweets).to be_an Array
|
37
37
|
expect(tweets.first).to be_a Twitter::Tweet
|
38
|
-
expect(tweets.first.text).to eq(
|
38
|
+
expect(tweets.first.text).to eq('Happy Birthday @imdane. Watch out for those @rally pranksters!')
|
39
39
|
end
|
40
|
-
context
|
41
|
-
it
|
42
|
-
list = URI.parse(
|
40
|
+
context 'with a URI object passed' do
|
41
|
+
it 'requests the correct resource' do
|
42
|
+
list = URI.parse('https://twitter.com/sferik/presidents')
|
43
43
|
@client.list_timeline(list)
|
44
|
-
expect(a_get(
|
44
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
45
45
|
end
|
46
46
|
end
|
47
|
-
context
|
48
|
-
it
|
49
|
-
@client.list_timeline(
|
50
|
-
expect(a_get(
|
47
|
+
context 'with a URI string passed' do
|
48
|
+
it 'requests the correct resource' do
|
49
|
+
@client.list_timeline('https://twitter.com/sferik/presidents')
|
50
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
51
51
|
end
|
52
52
|
end
|
53
|
-
context
|
54
|
-
it
|
55
|
-
user = URI.parse(
|
56
|
-
list = URI.parse(
|
53
|
+
context 'with URI objects passed' do
|
54
|
+
it 'requests the correct resource' do
|
55
|
+
user = URI.parse('https://twitter.com/sferik')
|
56
|
+
list = URI.parse('https://twitter.com/sferik/presidents')
|
57
57
|
@client.list_timeline(user, list)
|
58
|
-
expect(a_get(
|
58
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
59
59
|
end
|
60
60
|
end
|
61
|
-
context
|
62
|
-
it
|
63
|
-
@client.list_timeline(
|
64
|
-
expect(a_get(
|
61
|
+
context 'with URI strings passed' do
|
62
|
+
it 'requests the correct resource' do
|
63
|
+
@client.list_timeline('https://twitter.com/sferik', 'https://twitter.com/sferik/presidents')
|
64
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
-
context
|
68
|
+
context 'without a screen name passed' do
|
69
69
|
before do
|
70
|
-
stub_get(
|
71
|
-
stub_get(
|
70
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
71
|
+
stub_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('statuses.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
72
72
|
end
|
73
|
-
it
|
74
|
-
@client.list_timeline(
|
75
|
-
expect(a_get(
|
73
|
+
it 'requests the correct resource' do
|
74
|
+
@client.list_timeline('presidents')
|
75
|
+
expect(a_get('/1.1/lists/statuses.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe
|
81
|
-
context
|
80
|
+
describe '#remove_list_member' do
|
81
|
+
context 'with a screen name passed' do
|
82
82
|
before do
|
83
|
-
stub_post(
|
83
|
+
stub_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
84
84
|
end
|
85
|
-
it
|
86
|
-
@client.remove_list_member(
|
87
|
-
expect(a_post(
|
85
|
+
it 'requests the correct resource' do
|
86
|
+
@client.remove_list_member('sferik', 'presidents', 813_286)
|
87
|
+
expect(a_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
88
88
|
end
|
89
|
-
it
|
90
|
-
list = @client.remove_list_member(
|
89
|
+
it 'returns the list' do
|
90
|
+
list = @client.remove_list_member('sferik', 'presidents', 813_286)
|
91
91
|
expect(list).to be_a Twitter::List
|
92
|
-
expect(list.name).to eq(
|
92
|
+
expect(list.name).to eq('presidents')
|
93
93
|
end
|
94
94
|
end
|
95
|
-
context
|
95
|
+
context 'without a screen name passed' do
|
96
96
|
before do
|
97
|
-
stub_get(
|
98
|
-
stub_post(
|
97
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
98
|
+
stub_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
99
99
|
end
|
100
|
-
it
|
101
|
-
@client.remove_list_member(
|
102
|
-
expect(a_post(
|
100
|
+
it 'requests the correct resource' do
|
101
|
+
@client.remove_list_member('presidents', 813_286)
|
102
|
+
expect(a_post('/1.1/lists/members/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
describe
|
108
|
-
context
|
107
|
+
describe '#memberships' do
|
108
|
+
context 'with a screen name passed' do
|
109
109
|
before do
|
110
|
-
stub_get(
|
110
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
111
111
|
end
|
112
|
-
it
|
113
|
-
@client.memberships(
|
114
|
-
expect(a_get(
|
112
|
+
it 'requests the correct resource' do
|
113
|
+
@client.memberships('sferik')
|
114
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
115
115
|
end
|
116
|
-
it
|
117
|
-
memberships = @client.memberships(
|
116
|
+
it 'returns the lists the specified user has been added to' do
|
117
|
+
memberships = @client.memberships('sferik')
|
118
118
|
expect(memberships).to be_a Twitter::Cursor
|
119
119
|
expect(memberships.first).to be_a Twitter::List
|
120
|
-
expect(memberships.first.name).to eq(
|
120
|
+
expect(memberships.first.name).to eq('developer')
|
121
121
|
end
|
122
|
-
context
|
122
|
+
context 'with each' do
|
123
123
|
before do
|
124
|
-
stub_get(
|
124
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
125
125
|
end
|
126
|
-
it
|
127
|
-
@client.memberships(
|
128
|
-
expect(a_get(
|
129
|
-
expect(a_get(
|
126
|
+
it 'requests the correct resource' do
|
127
|
+
@client.memberships('sferik').each {}
|
128
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
129
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
|
-
context
|
133
|
+
context 'with a user ID passed' do
|
134
134
|
before do
|
135
|
-
stub_get(
|
135
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
136
136
|
end
|
137
|
-
it
|
138
|
-
@client.memberships(
|
139
|
-
expect(a_get(
|
137
|
+
it 'requests the correct resource' do
|
138
|
+
@client.memberships(7_505_382)
|
139
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
140
140
|
end
|
141
|
-
context
|
141
|
+
context 'with each' do
|
142
142
|
before do
|
143
|
-
stub_get(
|
143
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
144
144
|
end
|
145
|
-
it
|
146
|
-
@client.memberships(
|
147
|
-
expect(a_get(
|
148
|
-
expect(a_get(
|
145
|
+
it 'requests the correct resource' do
|
146
|
+
@client.memberships(7_505_382).each {}
|
147
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
148
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
152
|
-
context
|
152
|
+
context 'without a screen name passed' do
|
153
153
|
before do
|
154
|
-
stub_get(
|
155
|
-
stub_get(
|
154
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
155
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('memberships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
156
156
|
end
|
157
|
-
it
|
157
|
+
it 'requests the correct resource' do
|
158
158
|
@client.memberships
|
159
|
-
expect(a_get(
|
159
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
160
160
|
end
|
161
|
-
context
|
161
|
+
context 'with each' do
|
162
162
|
before do
|
163
|
-
stub_get(
|
163
|
+
stub_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('memberships2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
164
164
|
end
|
165
|
-
it
|
166
|
-
@client.memberships.each{}
|
167
|
-
expect(a_get(
|
168
|
-
expect(a_get(
|
165
|
+
it 'requests the correct resource' do
|
166
|
+
@client.memberships.each {}
|
167
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
168
|
+
expect(a_get('/1.1/lists/memberships.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
describe
|
175
|
-
context
|
174
|
+
describe '#list_subscribers' do
|
175
|
+
context 'with a screen name passed' do
|
176
176
|
before do
|
177
|
-
stub_get(
|
177
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
178
178
|
end
|
179
|
-
it
|
180
|
-
@client.list_subscribers(
|
181
|
-
expect(a_get(
|
179
|
+
it 'requests the correct resource' do
|
180
|
+
@client.list_subscribers('sferik', 'presidents')
|
181
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
182
182
|
end
|
183
|
-
it
|
184
|
-
list_subscribers = @client.list_subscribers(
|
183
|
+
it 'returns the subscribers of the specified list' do
|
184
|
+
list_subscribers = @client.list_subscribers('sferik', 'presidents')
|
185
185
|
expect(list_subscribers).to be_a Twitter::Cursor
|
186
186
|
expect(list_subscribers.first).to be_a Twitter::User
|
187
|
-
expect(list_subscribers.first.id).to eq(
|
187
|
+
expect(list_subscribers.first.id).to eq(7_505_382)
|
188
188
|
end
|
189
|
-
context
|
189
|
+
context 'with each' do
|
190
190
|
before do
|
191
|
-
stub_get(
|
191
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
192
192
|
end
|
193
|
-
it
|
194
|
-
@client.list_subscribers(
|
195
|
-
expect(a_get(
|
196
|
-
expect(a_get(
|
193
|
+
it 'requests the correct resource' do
|
194
|
+
@client.list_subscribers('sferik', 'presidents').each {}
|
195
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
196
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
200
|
-
context
|
200
|
+
context 'with a user ID passed' do
|
201
201
|
before do
|
202
|
-
stub_get(
|
202
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
203
203
|
end
|
204
|
-
it
|
205
|
-
@client.list_subscribers(
|
206
|
-
expect(a_get(
|
204
|
+
it 'requests the correct resource' do
|
205
|
+
@client.list_subscribers(7_505_382, 'presidents')
|
206
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
207
207
|
end
|
208
|
-
context
|
208
|
+
context 'with each' do
|
209
209
|
before do
|
210
|
-
stub_get(
|
210
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
211
211
|
end
|
212
|
-
it
|
213
|
-
@client.list_subscribers(
|
214
|
-
expect(a_get(
|
215
|
-
expect(a_get(
|
212
|
+
it 'requests the correct resource' do
|
213
|
+
@client.list_subscribers(7_505_382, 'presidents').each {}
|
214
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
215
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
219
|
-
context
|
219
|
+
context 'without a screen name passed' do
|
220
220
|
before do
|
221
|
-
stub_get(
|
222
|
-
stub_get(
|
221
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
222
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
223
223
|
end
|
224
|
-
it
|
225
|
-
@client.list_subscribers(
|
226
|
-
expect(a_get(
|
224
|
+
it 'requests the correct resource' do
|
225
|
+
@client.list_subscribers('presidents')
|
226
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
227
227
|
end
|
228
|
-
context
|
228
|
+
context 'with each' do
|
229
229
|
before do
|
230
|
-
stub_get(
|
230
|
+
stub_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
231
231
|
end
|
232
|
-
it
|
233
|
-
@client.list_subscribers(
|
234
|
-
expect(a_get(
|
235
|
-
expect(a_get(
|
232
|
+
it 'requests the correct resource' do
|
233
|
+
@client.list_subscribers('presidents').each {}
|
234
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
235
|
+
expect(a_get('/1.1/lists/subscribers.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
|
-
describe
|
242
|
-
context
|
241
|
+
describe '#list_subscribe' do
|
242
|
+
context 'with a screen name passed' do
|
243
243
|
before do
|
244
|
-
stub_post(
|
244
|
+
stub_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
245
245
|
end
|
246
|
-
it
|
247
|
-
@client.list_subscribe(
|
248
|
-
expect(a_post(
|
246
|
+
it 'requests the correct resource' do
|
247
|
+
@client.list_subscribe('sferik', 'presidents')
|
248
|
+
expect(a_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
249
249
|
end
|
250
|
-
it
|
251
|
-
list = @client.list_subscribe(
|
250
|
+
it 'returns the specified list' do
|
251
|
+
list = @client.list_subscribe('sferik', 'presidents')
|
252
252
|
expect(list).to be_a Twitter::List
|
253
|
-
expect(list.name).to eq(
|
253
|
+
expect(list.name).to eq('presidents')
|
254
254
|
end
|
255
255
|
end
|
256
|
-
context
|
256
|
+
context 'without a screen name passed' do
|
257
257
|
before do
|
258
|
-
stub_get(
|
259
|
-
stub_post(
|
258
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
259
|
+
stub_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
260
260
|
end
|
261
|
-
it
|
262
|
-
@client.list_subscribe(
|
263
|
-
expect(a_post(
|
261
|
+
it 'requests the correct resource' do
|
262
|
+
@client.list_subscribe('presidents')
|
263
|
+
expect(a_post('/1.1/lists/subscribers/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
264
264
|
end
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
-
describe
|
269
|
-
context
|
268
|
+
describe '#list_subscriber?' do
|
269
|
+
context 'with a screen name passed' do
|
270
270
|
before do
|
271
|
-
stub_get(
|
272
|
-
stub_get(
|
273
|
-
stub_get(
|
271
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
272
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '18755393'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
|
273
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).to_return(:body => fixture('not_found.json'), :status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
|
274
274
|
end
|
275
|
-
it
|
276
|
-
@client.list_subscriber?(
|
277
|
-
expect(a_get(
|
275
|
+
it 'requests the correct resource' do
|
276
|
+
@client.list_subscriber?('sferik', 'presidents', 813_286)
|
277
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
278
278
|
end
|
279
|
-
it
|
280
|
-
list_subscriber = @client.list_subscriber?(
|
279
|
+
it 'returns true if the specified user subscribes to the specified list' do
|
280
|
+
list_subscriber = @client.list_subscriber?('sferik', 'presidents', 813_286)
|
281
281
|
expect(list_subscriber).to be true
|
282
282
|
end
|
283
|
-
it
|
284
|
-
list_subscriber = @client.list_subscriber?(
|
283
|
+
it 'returns false if the specified user does not subscribe to the specified list' do
|
284
|
+
list_subscriber = @client.list_subscriber?('sferik', 'presidents', 18_755_393)
|
285
285
|
expect(list_subscriber).to be false
|
286
286
|
end
|
287
|
-
it
|
288
|
-
list_subscriber = @client.list_subscriber?(
|
287
|
+
it 'returns false if user does not exist' do
|
288
|
+
list_subscriber = @client.list_subscriber?('sferik', 'presidents', 12_345_678)
|
289
289
|
expect(list_subscriber).to be false
|
290
290
|
end
|
291
291
|
end
|
292
|
-
context
|
292
|
+
context 'with a owner ID passed' do
|
293
293
|
before do
|
294
|
-
stub_get(
|
294
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
295
295
|
end
|
296
|
-
it
|
297
|
-
@client.list_subscriber?(
|
298
|
-
expect(a_get(
|
296
|
+
it 'requests the correct resource' do
|
297
|
+
@client.list_subscriber?(12_345_678, 'presidents', 813_286)
|
298
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
299
299
|
end
|
300
300
|
end
|
301
|
-
context
|
301
|
+
context 'with a list ID passed' do
|
302
302
|
before do
|
303
|
-
stub_get(
|
303
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
304
304
|
end
|
305
|
-
it
|
306
|
-
@client.list_subscriber?(
|
307
|
-
expect(a_get(
|
305
|
+
it 'requests the correct resource' do
|
306
|
+
@client.list_subscriber?('sferik', 12_345_678, 813_286)
|
307
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})).to have_been_made
|
308
308
|
end
|
309
309
|
end
|
310
|
-
context
|
310
|
+
context 'with a list object passed' do
|
311
311
|
before do
|
312
|
-
stub_get(
|
312
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
313
313
|
end
|
314
|
-
it
|
315
|
-
list = Twitter::List.new(:id =>
|
316
|
-
@client.list_subscriber?(list,
|
317
|
-
expect(a_get(
|
314
|
+
it 'requests the correct resource' do
|
315
|
+
list = Twitter::List.new(:id => 12_345_678, :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
316
|
+
@client.list_subscriber?(list, 813_286)
|
317
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})).to have_been_made
|
318
318
|
end
|
319
319
|
end
|
320
|
-
context
|
320
|
+
context 'with a screen name passed for user_to_check' do
|
321
321
|
before do
|
322
|
-
stub_get(
|
322
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
323
323
|
end
|
324
|
-
it
|
325
|
-
@client.list_subscriber?(
|
326
|
-
expect(a_get(
|
324
|
+
it 'requests the correct resource' do
|
325
|
+
@client.list_subscriber?('sferik', 'presidents', 'erebor')
|
326
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})).to have_been_made
|
327
327
|
end
|
328
328
|
end
|
329
|
-
context
|
329
|
+
context 'without a screen name passed' do
|
330
330
|
before do
|
331
|
-
stub_get(
|
332
|
-
stub_get(
|
331
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
332
|
+
stub_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
333
333
|
end
|
334
|
-
it
|
335
|
-
@client.list_subscriber?(
|
336
|
-
expect(a_get(
|
334
|
+
it 'requests the correct resource' do
|
335
|
+
@client.list_subscriber?('presidents', 813_286)
|
336
|
+
expect(a_get('/1.1/lists/subscribers/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
337
337
|
end
|
338
338
|
end
|
339
339
|
end
|
340
340
|
|
341
|
-
describe
|
342
|
-
context
|
341
|
+
describe '#list_unsubscribe' do
|
342
|
+
context 'with a screen name passed' do
|
343
343
|
before do
|
344
|
-
stub_post(
|
344
|
+
stub_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
345
345
|
end
|
346
|
-
it
|
347
|
-
@client.list_unsubscribe(
|
348
|
-
expect(a_post(
|
346
|
+
it 'requests the correct resource' do
|
347
|
+
@client.list_unsubscribe('sferik', 'presidents')
|
348
|
+
expect(a_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
349
349
|
end
|
350
|
-
it
|
351
|
-
list = @client.list_unsubscribe(
|
350
|
+
it 'returns the specified list' do
|
351
|
+
list = @client.list_unsubscribe('sferik', 'presidents')
|
352
352
|
expect(list).to be_a Twitter::List
|
353
|
-
expect(list.name).to eq(
|
353
|
+
expect(list.name).to eq('presidents')
|
354
354
|
end
|
355
355
|
end
|
356
|
-
context
|
356
|
+
context 'without a screen name passed' do
|
357
357
|
before do
|
358
|
-
stub_get(
|
359
|
-
stub_post(
|
358
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
359
|
+
stub_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
360
360
|
end
|
361
|
-
it
|
362
|
-
@client.list_unsubscribe(
|
363
|
-
expect(a_post(
|
361
|
+
it 'requests the correct resource' do
|
362
|
+
@client.list_unsubscribe('presidents')
|
363
|
+
expect(a_post('/1.1/lists/subscribers/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
364
364
|
end
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
368
|
-
describe
|
369
|
-
context
|
368
|
+
describe '#add_list_members' do
|
369
|
+
context 'with a screen name passed' do
|
370
370
|
before do
|
371
|
-
stub_post(
|
371
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
372
372
|
end
|
373
|
-
it
|
374
|
-
@client.add_list_members(
|
375
|
-
expect(a_post(
|
373
|
+
it 'requests the correct resource' do
|
374
|
+
@client.add_list_members('sferik', 'presidents', [813_286, 18_755_393])
|
375
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
|
376
376
|
end
|
377
|
-
it
|
378
|
-
list = @client.add_list_members(
|
377
|
+
it 'returns the list' do
|
378
|
+
list = @client.add_list_members('sferik', 'presidents', [813_286, 18_755_393])
|
379
379
|
expect(list).to be_a Twitter::List
|
380
|
-
expect(list.name).to eq(
|
380
|
+
expect(list.name).to eq('presidents')
|
381
381
|
end
|
382
382
|
end
|
383
|
-
context
|
383
|
+
context 'with a combination of member IDs and member screen names to add' do
|
384
384
|
before do
|
385
|
-
stub_post(
|
385
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
386
386
|
end
|
387
|
-
it
|
388
|
-
@client.add_list_members(
|
389
|
-
expect(a_post(
|
387
|
+
it 'requests the correct resource' do
|
388
|
+
@client.add_list_members('sferik', 'presidents', [813_286, 'pengwynn', 18_755_393, 'erebor'])
|
389
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'})).to have_been_made
|
390
390
|
end
|
391
391
|
end
|
392
|
-
context
|
392
|
+
context 'without a screen name passed' do
|
393
393
|
before do
|
394
|
-
stub_get(
|
395
|
-
stub_post(
|
394
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
395
|
+
stub_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
396
396
|
end
|
397
|
-
it
|
398
|
-
@client.add_list_members(
|
399
|
-
expect(a_post(
|
397
|
+
it 'requests the correct resource' do
|
398
|
+
@client.add_list_members('presidents', [813_286, 18_755_393])
|
399
|
+
expect(a_post('/1.1/lists/members/create_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
|
400
400
|
end
|
401
401
|
end
|
402
402
|
end
|
403
403
|
|
404
|
-
describe
|
405
|
-
context
|
404
|
+
describe '#list_member?' do
|
405
|
+
context 'with a screen name passed' do
|
406
406
|
before do
|
407
|
-
stub_get(
|
408
|
-
stub_get(
|
409
|
-
stub_get(
|
407
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
408
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '65493023'}).to_return(:body => fixture('not_found.json'), :status => 404, :headers => {:content_type => 'application/json; charset=utf-8'})
|
409
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '12345678'}).to_return(:body => fixture('not_found.json'), :status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
|
410
410
|
end
|
411
|
-
it
|
412
|
-
@client.list_member?(
|
413
|
-
expect(a_get(
|
411
|
+
it 'requests the correct resource' do
|
412
|
+
@client.list_member?('sferik', 'presidents', 813_286)
|
413
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
414
414
|
end
|
415
|
-
it
|
416
|
-
list_member = @client.list_member?(
|
415
|
+
it 'returns true if user is a list member' do
|
416
|
+
list_member = @client.list_member?('sferik', 'presidents', 813_286)
|
417
417
|
expect(list_member).to be true
|
418
418
|
end
|
419
|
-
it
|
420
|
-
list_member = @client.list_member?(
|
419
|
+
it 'returns false if user is not a list member' do
|
420
|
+
list_member = @client.list_member?('sferik', 'presidents', 65_493_023)
|
421
421
|
expect(list_member).to be false
|
422
422
|
end
|
423
|
-
it
|
424
|
-
list_member = @client.list_member?(
|
423
|
+
it 'returns false if user does not exist' do
|
424
|
+
list_member = @client.list_member?('sferik', 'presidents', 12_345_678)
|
425
425
|
expect(list_member).to be false
|
426
426
|
end
|
427
427
|
end
|
428
|
-
context
|
428
|
+
context 'with an owner ID passed' do
|
429
429
|
before do
|
430
|
-
stub_get(
|
430
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
431
431
|
end
|
432
|
-
it
|
433
|
-
@client.list_member?(
|
434
|
-
expect(a_get(
|
432
|
+
it 'requests the correct resource' do
|
433
|
+
@client.list_member?(12_345_678, 'presidents', 813_286)
|
434
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
435
435
|
end
|
436
436
|
end
|
437
|
-
context
|
437
|
+
context 'with a list ID passed' do
|
438
438
|
before do
|
439
|
-
stub_get(
|
439
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
440
440
|
end
|
441
|
-
it
|
442
|
-
@client.list_member?(
|
443
|
-
expect(a_get(
|
441
|
+
it 'requests the correct resource' do
|
442
|
+
@client.list_member?('sferik', 12_345_678, 813_286)
|
443
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678', :user_id => '813286'})).to have_been_made
|
444
444
|
end
|
445
445
|
end
|
446
|
-
context
|
446
|
+
context 'with a list object passed' do
|
447
447
|
before do
|
448
|
-
stub_get(
|
448
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
449
449
|
end
|
450
|
-
it
|
451
|
-
list = Twitter::List.new(:id =>
|
452
|
-
@client.list_member?(list,
|
453
|
-
expect(a_get(
|
450
|
+
it 'requests the correct resource' do
|
451
|
+
list = Twitter::List.new(:id => 12_345_678, :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
452
|
+
@client.list_member?(list, 813_286)
|
453
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678', :user_id => '813286'})).to have_been_made
|
454
454
|
end
|
455
455
|
end
|
456
|
-
context
|
456
|
+
context 'with a screen name passed for user_to_check' do
|
457
457
|
before do
|
458
|
-
stub_get(
|
458
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/.json; charset=utf-8'})
|
459
459
|
end
|
460
|
-
it
|
461
|
-
@client.list_member?(
|
462
|
-
expect(a_get(
|
460
|
+
it 'requests the correct resource' do
|
461
|
+
@client.list_member?('sferik', 'presidents', 'erebor')
|
462
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :screen_name => 'erebor'})).to have_been_made
|
463
463
|
end
|
464
464
|
end
|
465
|
-
context
|
465
|
+
context 'without a screen name passed' do
|
466
466
|
before do
|
467
|
-
stub_get(
|
468
|
-
stub_get(
|
467
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
468
|
+
stub_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/.json; charset=utf-8'})
|
469
469
|
end
|
470
|
-
it
|
471
|
-
@client.list_member?(
|
472
|
-
expect(a_get(
|
470
|
+
it 'requests the correct resource' do
|
471
|
+
@client.list_member?('presidents', 813_286)
|
472
|
+
expect(a_get('/1.1/lists/members/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
473
473
|
end
|
474
474
|
end
|
475
475
|
end
|
476
476
|
|
477
|
-
describe
|
478
|
-
context
|
477
|
+
describe '#list_members' do
|
478
|
+
context 'with a screen name passed' do
|
479
479
|
before do
|
480
|
-
stub_get(
|
480
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
481
481
|
end
|
482
|
-
it
|
483
|
-
@client.list_members(
|
484
|
-
expect(a_get(
|
482
|
+
it 'requests the correct resource' do
|
483
|
+
@client.list_members('sferik', 'presidents')
|
484
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
485
485
|
end
|
486
|
-
it
|
487
|
-
list_members = @client.list_members(
|
486
|
+
it 'returns the members of the specified list' do
|
487
|
+
list_members = @client.list_members('sferik', 'presidents')
|
488
488
|
expect(list_members).to be_a Twitter::Cursor
|
489
489
|
expect(list_members.first).to be_a Twitter::User
|
490
|
-
expect(list_members.first.id).to eq(
|
490
|
+
expect(list_members.first.id).to eq(7_505_382)
|
491
491
|
end
|
492
|
-
context
|
492
|
+
context 'with each' do
|
493
493
|
before do
|
494
|
-
stub_get(
|
494
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
495
495
|
end
|
496
|
-
it
|
497
|
-
@client.list_members(
|
498
|
-
expect(a_get(
|
499
|
-
expect(a_get(
|
496
|
+
it 'requests the correct resource' do
|
497
|
+
@client.list_members('sferik', 'presidents').each {}
|
498
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
499
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
500
500
|
end
|
501
501
|
end
|
502
502
|
end
|
503
|
-
context
|
503
|
+
context 'with a user ID passed' do
|
504
504
|
before do
|
505
|
-
stub_get(
|
505
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
506
506
|
end
|
507
|
-
it
|
508
|
-
@client.list_members(
|
509
|
-
expect(a_get(
|
507
|
+
it 'requests the correct resource' do
|
508
|
+
@client.list_members(7_505_382, 'presidents')
|
509
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
510
510
|
end
|
511
|
-
context
|
511
|
+
context 'with each' do
|
512
512
|
before do
|
513
|
-
stub_get(
|
513
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
514
514
|
end
|
515
|
-
it
|
516
|
-
@client.list_members(
|
517
|
-
expect(a_get(
|
518
|
-
expect(a_get(
|
515
|
+
it 'requests the correct resource' do
|
516
|
+
@client.list_members(7_505_382, 'presidents').each {}
|
517
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
518
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_id => '7505382', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
519
519
|
end
|
520
520
|
end
|
521
521
|
end
|
522
|
-
context
|
522
|
+
context 'without a screen name passed' do
|
523
523
|
before do
|
524
|
-
stub_get(
|
525
|
-
stub_get(
|
524
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
525
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'}).to_return(:body => fixture('users_list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
526
526
|
end
|
527
|
-
it
|
528
|
-
@client.list_members(
|
529
|
-
expect(a_get(
|
527
|
+
it 'requests the correct resource' do
|
528
|
+
@client.list_members('presidents')
|
529
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
530
530
|
end
|
531
|
-
context
|
531
|
+
context 'with each' do
|
532
532
|
before do
|
533
|
-
stub_get(
|
533
|
+
stub_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'}).to_return(:body => fixture('users_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
534
534
|
end
|
535
|
-
it
|
536
|
-
@client.list_members(
|
537
|
-
expect(a_get(
|
538
|
-
expect(a_get(
|
535
|
+
it 'requests the correct resource' do
|
536
|
+
@client.list_members('presidents').each {}
|
537
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '-1'})).to have_been_made
|
538
|
+
expect(a_get('/1.1/lists/members.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents', :cursor => '1322801608223717003'})).to have_been_made
|
539
539
|
end
|
540
540
|
end
|
541
541
|
end
|
542
542
|
end
|
543
543
|
|
544
|
-
describe
|
545
|
-
context
|
544
|
+
describe '#add_list_member' do
|
545
|
+
context 'with a screen name passed' do
|
546
546
|
before do
|
547
|
-
stub_post(
|
547
|
+
stub_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
548
548
|
end
|
549
|
-
it
|
550
|
-
@client.add_list_member(
|
551
|
-
expect(a_post(
|
549
|
+
it 'requests the correct resource' do
|
550
|
+
@client.add_list_member('sferik', 'presidents', 813_286)
|
551
|
+
expect(a_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
552
552
|
end
|
553
|
-
it
|
554
|
-
list = @client.add_list_member(
|
553
|
+
it 'returns the list' do
|
554
|
+
list = @client.add_list_member('sferik', 'presidents', 813_286)
|
555
555
|
expect(list).to be_a Twitter::List
|
556
|
-
expect(list.name).to eq(
|
556
|
+
expect(list.name).to eq('presidents')
|
557
557
|
end
|
558
558
|
end
|
559
|
-
context
|
559
|
+
context 'without a screen name passed' do
|
560
560
|
before do
|
561
|
-
stub_get(
|
562
|
-
stub_post(
|
561
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
562
|
+
stub_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
563
563
|
end
|
564
|
-
it
|
565
|
-
@client.add_list_member(
|
566
|
-
expect(a_post(
|
564
|
+
it 'requests the correct resource' do
|
565
|
+
@client.add_list_member('presidents', 813_286)
|
566
|
+
expect(a_post('/1.1/lists/members/create.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286'})).to have_been_made
|
567
567
|
end
|
568
568
|
end
|
569
569
|
end
|
570
570
|
|
571
|
-
describe
|
572
|
-
context
|
571
|
+
describe '#destroy_list' do
|
572
|
+
context 'with a screen name passed' do
|
573
573
|
before do
|
574
|
-
stub_post(
|
574
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
575
575
|
end
|
576
|
-
it
|
577
|
-
@client.destroy_list(
|
578
|
-
expect(a_post(
|
576
|
+
it 'requests the correct resource' do
|
577
|
+
@client.destroy_list('sferik', 'presidents')
|
578
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
579
579
|
end
|
580
|
-
it
|
581
|
-
list = @client.destroy_list(
|
580
|
+
it 'returns the deleted list' do
|
581
|
+
list = @client.destroy_list('sferik', 'presidents')
|
582
582
|
expect(list).to be_a Twitter::List
|
583
|
-
expect(list.name).to eq(
|
583
|
+
expect(list.name).to eq('presidents')
|
584
584
|
end
|
585
585
|
end
|
586
|
-
context
|
586
|
+
context 'without a screen name passed' do
|
587
587
|
before do
|
588
|
-
stub_get(
|
589
|
-
stub_post(
|
588
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
589
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
590
590
|
end
|
591
|
-
it
|
592
|
-
@client.destroy_list(
|
593
|
-
expect(a_post(
|
591
|
+
it 'requests the correct resource' do
|
592
|
+
@client.destroy_list('presidents')
|
593
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
594
594
|
end
|
595
595
|
end
|
596
|
-
context
|
596
|
+
context 'with a list ID passed' do
|
597
597
|
before do
|
598
|
-
stub_post(
|
598
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
599
599
|
end
|
600
|
-
it
|
601
|
-
@client.destroy_list(
|
602
|
-
expect(a_post(
|
600
|
+
it 'requests the correct resource' do
|
601
|
+
@client.destroy_list('sferik', 12_345_678)
|
602
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678'})).to have_been_made
|
603
603
|
end
|
604
604
|
end
|
605
|
-
context
|
605
|
+
context 'with a list object passed' do
|
606
606
|
before do
|
607
|
-
stub_post(
|
607
|
+
stub_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
608
608
|
end
|
609
|
-
it
|
610
|
-
list = Twitter::List.new(:id =>
|
609
|
+
it 'requests the correct resource' do
|
610
|
+
list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
611
611
|
@client.destroy_list(list)
|
612
|
-
expect(a_post(
|
612
|
+
expect(a_post('/1.1/lists/destroy.json').with(:body => {:owner_id => '7505382', :list_id => '12345678'})).to have_been_made
|
613
613
|
end
|
614
614
|
end
|
615
615
|
end
|
616
616
|
|
617
|
-
describe
|
618
|
-
context
|
617
|
+
describe '#list_update' do
|
618
|
+
context 'with a screen name passed' do
|
619
619
|
before do
|
620
|
-
stub_post(
|
620
|
+
stub_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
621
621
|
end
|
622
|
-
it
|
623
|
-
@client.list_update(
|
624
|
-
expect(a_post(
|
622
|
+
it 'requests the correct resource' do
|
623
|
+
@client.list_update('sferik', 'presidents', :description => 'Presidents of the United States of America')
|
624
|
+
expect(a_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'})).to have_been_made
|
625
625
|
end
|
626
|
-
it
|
627
|
-
list = @client.list_update(
|
626
|
+
it 'returns the updated list' do
|
627
|
+
list = @client.list_update('sferik', 'presidents', :description => 'Presidents of the United States of America')
|
628
628
|
expect(list).to be_a Twitter::List
|
629
|
-
expect(list.name).to eq(
|
629
|
+
expect(list.name).to eq('presidents')
|
630
630
|
end
|
631
631
|
end
|
632
|
-
context
|
632
|
+
context 'without a screen name passed' do
|
633
633
|
before do
|
634
|
-
stub_get(
|
635
|
-
stub_post(
|
634
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
635
|
+
stub_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
636
636
|
end
|
637
|
-
it
|
638
|
-
@client.list_update(
|
639
|
-
expect(a_post(
|
637
|
+
it 'requests the correct resource' do
|
638
|
+
@client.list_update('presidents', :description => 'Presidents of the United States of America')
|
639
|
+
expect(a_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :description => 'Presidents of the United States of America'})).to have_been_made
|
640
640
|
end
|
641
641
|
end
|
642
|
-
context
|
642
|
+
context 'with a list ID passed' do
|
643
643
|
before do
|
644
|
-
stub_post(
|
644
|
+
stub_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
645
645
|
end
|
646
|
-
it
|
647
|
-
@client.list_update(
|
648
|
-
expect(a_post(
|
646
|
+
it 'requests the correct resource' do
|
647
|
+
@client.list_update('sferik', 12_345_678, :description => 'Presidents of the United States of America')
|
648
|
+
expect(a_post('/1.1/lists/update.json').with(:body => {:owner_screen_name => 'sferik', :list_id => '12345678', :description => 'Presidents of the United States of America'})).to have_been_made
|
649
649
|
end
|
650
650
|
end
|
651
|
-
context
|
651
|
+
context 'with a list object passed' do
|
652
652
|
before do
|
653
|
-
stub_post(
|
653
|
+
stub_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => 'Presidents of the United States of America'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
654
654
|
end
|
655
|
-
it
|
656
|
-
list = Twitter::List.new(:id =>
|
657
|
-
@client.list_update(list, :description =>
|
658
|
-
expect(a_post(
|
655
|
+
it 'requests the correct resource' do
|
656
|
+
list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
657
|
+
@client.list_update(list, :description => 'Presidents of the United States of America')
|
658
|
+
expect(a_post('/1.1/lists/update.json').with(:body => {:owner_id => '7505382', :list_id => '12345678', :description => 'Presidents of the United States of America'})).to have_been_made
|
659
659
|
end
|
660
660
|
end
|
661
661
|
end
|
662
662
|
|
663
|
-
describe
|
663
|
+
describe '#create_list' do
|
664
664
|
before do
|
665
|
-
stub_post(
|
665
|
+
stub_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
666
666
|
end
|
667
|
-
it
|
668
|
-
@client.create_list(
|
669
|
-
expect(a_post(
|
667
|
+
it 'requests the correct resource' do
|
668
|
+
@client.create_list('presidents')
|
669
|
+
expect(a_post('/1.1/lists/create.json').with(:body => {:name => 'presidents'})).to have_been_made
|
670
670
|
end
|
671
|
-
it
|
672
|
-
list = @client.create_list(
|
671
|
+
it 'returns the created list' do
|
672
|
+
list = @client.create_list('presidents')
|
673
673
|
expect(list).to be_a Twitter::List
|
674
|
-
expect(list.name).to eq(
|
674
|
+
expect(list.name).to eq('presidents')
|
675
675
|
end
|
676
676
|
end
|
677
677
|
|
678
|
-
describe
|
679
|
-
context
|
678
|
+
describe '#list' do
|
679
|
+
context 'with a screen name passed' do
|
680
680
|
before do
|
681
|
-
stub_get(
|
681
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
682
682
|
end
|
683
|
-
it
|
684
|
-
@client.list(
|
685
|
-
expect(a_get(
|
683
|
+
it 'requests the correct resource' do
|
684
|
+
@client.list('sferik', 'presidents')
|
685
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
686
686
|
end
|
687
|
-
it
|
688
|
-
list = @client.list(
|
687
|
+
it 'returns the updated list' do
|
688
|
+
list = @client.list('sferik', 'presidents')
|
689
689
|
expect(list).to be_a Twitter::List
|
690
|
-
expect(list.name).to eq(
|
690
|
+
expect(list.name).to eq('presidents')
|
691
691
|
end
|
692
692
|
end
|
693
|
-
context
|
693
|
+
context 'with a user ID passed' do
|
694
694
|
before do
|
695
|
-
stub_get(
|
695
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
696
696
|
end
|
697
|
-
it
|
698
|
-
@client.list(
|
699
|
-
expect(a_get(
|
697
|
+
it 'requests the correct resource' do
|
698
|
+
@client.list(12_345_678, 'presidents')
|
699
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'})).to have_been_made
|
700
700
|
end
|
701
701
|
end
|
702
|
-
context
|
702
|
+
context 'with a user object passed' do
|
703
703
|
before do
|
704
|
-
stub_get(
|
704
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
705
705
|
end
|
706
|
-
it
|
707
|
-
user = Twitter::User.new(:id =>
|
708
|
-
@client.list(user,
|
709
|
-
expect(a_get(
|
706
|
+
it 'requests the correct resource' do
|
707
|
+
user = Twitter::User.new(:id => '12345678')
|
708
|
+
@client.list(user, 'presidents')
|
709
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '12345678', :slug => 'presidents'})).to have_been_made
|
710
710
|
end
|
711
711
|
end
|
712
|
-
context
|
712
|
+
context 'without a screen name passed' do
|
713
713
|
before do
|
714
|
-
stub_get(
|
715
|
-
stub_get(
|
714
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
715
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
716
716
|
end
|
717
|
-
it
|
718
|
-
@client.list(
|
719
|
-
expect(a_get(
|
717
|
+
it 'requests the correct resource' do
|
718
|
+
@client.list('presidents')
|
719
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :slug => 'presidents'})).to have_been_made
|
720
720
|
end
|
721
721
|
end
|
722
|
-
context
|
722
|
+
context 'with a list ID passed' do
|
723
723
|
before do
|
724
|
-
stub_get(
|
724
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
725
725
|
end
|
726
|
-
it
|
727
|
-
@client.list(
|
728
|
-
expect(a_get(
|
726
|
+
it 'requests the correct resource' do
|
727
|
+
@client.list('sferik', 12_345_678)
|
728
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_screen_name => 'sferik', :list_id => '12345678'})).to have_been_made
|
729
729
|
end
|
730
730
|
end
|
731
|
-
context
|
731
|
+
context 'with a list object passed' do
|
732
732
|
before do
|
733
|
-
stub_get(
|
733
|
+
stub_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
734
734
|
end
|
735
|
-
it
|
736
|
-
list = Twitter::List.new(:id =>
|
735
|
+
it 'requests the correct resource' do
|
736
|
+
list = Twitter::List.new(:id => '12345678', :user => {:id => 7_505_382, :screen_name => 'sferik'})
|
737
737
|
@client.list(list)
|
738
|
-
expect(a_get(
|
738
|
+
expect(a_get('/1.1/lists/show.json').with(:query => {:owner_id => '7505382', :list_id => '12345678'})).to have_been_made
|
739
739
|
end
|
740
740
|
end
|
741
741
|
end
|
742
742
|
|
743
|
-
describe
|
744
|
-
context
|
743
|
+
describe '#subscriptions' do
|
744
|
+
context 'with a screen name passed' do
|
745
745
|
before do
|
746
|
-
stub_get(
|
746
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
747
747
|
end
|
748
|
-
it
|
749
|
-
@client.subscriptions(
|
750
|
-
expect(a_get(
|
748
|
+
it 'requests the correct resource' do
|
749
|
+
@client.subscriptions('sferik')
|
750
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
751
751
|
end
|
752
|
-
it
|
753
|
-
subscriptions = @client.subscriptions(
|
752
|
+
it 'returns the lists the specified user follows' do
|
753
|
+
subscriptions = @client.subscriptions('sferik')
|
754
754
|
expect(subscriptions).to be_a Twitter::Cursor
|
755
755
|
expect(subscriptions.first).to be_a Twitter::List
|
756
|
-
expect(subscriptions.first.name).to eq(
|
756
|
+
expect(subscriptions.first.name).to eq('Rubyists')
|
757
757
|
end
|
758
|
-
context
|
758
|
+
context 'with each' do
|
759
759
|
before do
|
760
|
-
stub_get(
|
760
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
761
761
|
end
|
762
|
-
it
|
763
|
-
@client.subscriptions(
|
764
|
-
expect(a_get(
|
765
|
-
expect(a_get(
|
762
|
+
it 'requests the correct resource' do
|
763
|
+
@client.subscriptions('sferik').each {}
|
764
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
765
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
|
766
766
|
end
|
767
767
|
end
|
768
768
|
end
|
769
|
-
context
|
769
|
+
context 'with a user ID passed' do
|
770
770
|
before do
|
771
|
-
stub_get(
|
771
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
772
772
|
end
|
773
|
-
it
|
774
|
-
@client.subscriptions(
|
775
|
-
expect(a_get(
|
773
|
+
it 'requests the correct resource' do
|
774
|
+
@client.subscriptions(7_505_382)
|
775
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
776
776
|
end
|
777
|
-
context
|
777
|
+
context 'with each' do
|
778
778
|
before do
|
779
|
-
stub_get(
|
779
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
780
780
|
end
|
781
|
-
it
|
782
|
-
@client.subscriptions(
|
783
|
-
expect(a_get(
|
784
|
-
expect(a_get(
|
781
|
+
it 'requests the correct resource' do
|
782
|
+
@client.subscriptions(7_505_382).each {}
|
783
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '-1'})).to have_been_made
|
784
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:user_id => '7505382', :cursor => '1401037770457540712'})).to have_been_made
|
785
785
|
end
|
786
786
|
end
|
787
787
|
end
|
788
|
-
context
|
788
|
+
context 'without a screen name passed' do
|
789
789
|
before do
|
790
|
-
stub_get(
|
791
|
-
stub_get(
|
790
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
791
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('subscriptions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
792
792
|
end
|
793
|
-
it
|
793
|
+
it 'requests the correct resource' do
|
794
794
|
@client.subscriptions
|
795
|
-
expect(a_get(
|
795
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
796
796
|
end
|
797
|
-
context
|
797
|
+
context 'with each' do
|
798
798
|
before do
|
799
|
-
stub_get(
|
799
|
+
stub_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'}).to_return(:body => fixture('subscriptions2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
800
800
|
end
|
801
|
-
it
|
802
|
-
@client.subscriptions.each{}
|
803
|
-
expect(a_get(
|
804
|
-
expect(a_get(
|
801
|
+
it 'requests the correct resource' do
|
802
|
+
@client.subscriptions.each {}
|
803
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
804
|
+
expect(a_get('/1.1/lists/subscriptions.json').with(:query => {:screen_name => 'sferik', :cursor => '1401037770457540712'})).to have_been_made
|
805
805
|
end
|
806
806
|
end
|
807
807
|
end
|
808
808
|
end
|
809
809
|
|
810
|
-
describe
|
811
|
-
context
|
810
|
+
describe '#remove_list_members' do
|
811
|
+
context 'with a screen name passed' do
|
812
812
|
before do
|
813
|
-
stub_post(
|
813
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
814
814
|
end
|
815
|
-
it
|
816
|
-
@client.remove_list_members(
|
817
|
-
expect(a_post(
|
815
|
+
it 'requests the correct resource' do
|
816
|
+
@client.remove_list_members('sferik', 'presidents', [813_286, 18_755_393])
|
817
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
|
818
818
|
end
|
819
|
-
it
|
820
|
-
list = @client.remove_list_members(
|
819
|
+
it 'returns the list' do
|
820
|
+
list = @client.remove_list_members('sferik', 'presidents', [813_286, 18_755_393])
|
821
821
|
expect(list).to be_a Twitter::List
|
822
|
-
expect(list.name).to eq(
|
822
|
+
expect(list.name).to eq('presidents')
|
823
823
|
end
|
824
824
|
end
|
825
|
-
context
|
825
|
+
context 'with a user ID passed' do
|
826
826
|
before do
|
827
|
-
stub_post(
|
827
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
828
828
|
end
|
829
|
-
it
|
830
|
-
@client.remove_list_members(
|
831
|
-
expect(a_post(
|
829
|
+
it 'requests the correct resource' do
|
830
|
+
@client.remove_list_members(7_505_382, 'presidents', [813_286, 18_755_393])
|
831
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_id => '7505382', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
|
832
832
|
end
|
833
833
|
end
|
834
|
-
context
|
834
|
+
context 'with a combination of member IDs and member screen names to add' do
|
835
835
|
before do
|
836
|
-
stub_post(
|
836
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
837
837
|
end
|
838
|
-
it
|
839
|
-
@client.remove_list_members(
|
840
|
-
expect(a_post(
|
838
|
+
it 'requests the correct resource' do
|
839
|
+
@client.remove_list_members('sferik', 'presidents', [813_286, 'pengwynn', 18_755_393, 'erebor'])
|
840
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393', :screen_name => 'pengwynn,erebor'})).to have_been_made
|
841
841
|
end
|
842
842
|
end
|
843
|
-
context
|
843
|
+
context 'without a screen name passed' do
|
844
844
|
before do
|
845
|
-
stub_get(
|
846
|
-
stub_post(
|
845
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
846
|
+
stub_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'}).to_return(:body => fixture('list.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
847
847
|
end
|
848
|
-
it
|
849
|
-
@client.remove_list_members(
|
850
|
-
expect(a_post(
|
848
|
+
it 'requests the correct resource' do
|
849
|
+
@client.remove_list_members('presidents', [813_286, 18_755_393])
|
850
|
+
expect(a_post('/1.1/lists/members/destroy_all.json').with(:body => {:owner_screen_name => 'sferik', :slug => 'presidents', :user_id => '813286,18755393'})).to have_been_made
|
851
851
|
end
|
852
852
|
end
|
853
853
|
end
|
854
854
|
|
855
|
-
describe
|
856
|
-
context
|
855
|
+
describe '#owned_lists' do
|
856
|
+
context 'with a screen name passed' do
|
857
857
|
before do
|
858
|
-
stub_get(
|
858
|
+
stub_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('ownerships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
859
859
|
end
|
860
|
-
it
|
861
|
-
@client.owned_lists(
|
862
|
-
expect(a_get(
|
860
|
+
it 'requests the correct resource' do
|
861
|
+
@client.owned_lists('sferik')
|
862
|
+
expect(a_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
863
863
|
end
|
864
|
-
it
|
865
|
-
lists = @client.owned_lists(
|
864
|
+
it 'returns the requested list' do
|
865
|
+
lists = @client.owned_lists('sferik')
|
866
866
|
expect(lists).to be_a Twitter::Cursor
|
867
867
|
expect(lists.first).to be_a Twitter::List
|
868
|
-
expect(lists.first.name).to eq(
|
868
|
+
expect(lists.first.name).to eq('My favstar.fm list')
|
869
869
|
end
|
870
870
|
end
|
871
|
-
context
|
871
|
+
context 'without a screen name passed' do
|
872
872
|
before do
|
873
|
-
stub_get(
|
874
|
-
stub_get(
|
873
|
+
stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
874
|
+
stub_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'}).to_return(:body => fixture('ownerships.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
875
875
|
end
|
876
|
-
it
|
876
|
+
it 'requests the correct resource' do
|
877
877
|
@client.owned_lists
|
878
|
-
expect(a_get(
|
878
|
+
expect(a_get('/1.1/lists/ownerships.json').with(:query => {:screen_name => 'sferik', :cursor => '-1'})).to have_been_made
|
879
879
|
end
|
880
|
-
it
|
880
|
+
it 'returns the requested list' do
|
881
881
|
lists = @client.owned_lists
|
882
882
|
expect(lists).to be_a Twitter::Cursor
|
883
883
|
expect(lists.first).to be_a Twitter::List
|
884
|
-
expect(lists.first.name).to eq(
|
884
|
+
expect(lists.first.name).to eq('My favstar.fm list')
|
885
885
|
end
|
886
886
|
end
|
887
887
|
end
|