diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index a478521a..724c9a7b 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -219,6 +219,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -232,6 +233,7 @@ expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: '50', max_id: '856477710595624962', include_entities: 'true'})).to have_been_made end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -257,6 +259,7 @@ EOS end end + context '--number' do before do stub_get('/1.1/users/lookup.json').with(query: {user_id: '358486183'}).to_return(body: fixture('users.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -268,6 +271,7 @@ expect(a_get('/1.1/users/lookup.json').with(query: {user_id: '358486183'})).to have_been_made end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -361,6 +365,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -373,6 +378,7 @@ expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: '50', include_entities: 'true'})).to have_been_made end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -388,6 +394,7 @@ EOS end end + context '--number' do it 'limits the number of results 1' do @cli.options = @cli.options.merge('number' => 1) @@ -401,6 +408,7 @@ expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: '50', max_id: '856480385957548034', include_entities: 'false'})).to have_been_made end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -485,6 +493,7 @@ expect(a_get('/1.1/lists/members/show.json').with(query: {owner_screen_name: 'testcli', screen_name: 'sferik', slug: 'presidents'})).to have_been_made end end + context 'with an owner passed' do it 'has the correct output' do @cli.does_contain('testcli/presidents', 'testcli') @@ -504,12 +513,14 @@ end end end + context 'with a user passed' do it 'has the correct output' do @cli.does_contain('presidents', 'testcli') expect($stdout.string.chomp).to eq 'Yes, presidents contains @testcli.' end end + context 'false' do before do stub_get('/1.1/lists/members/show.json').with(query: {owner_screen_name: 'testcli', screen_name: 'testcli', slug: 'presidents'}).to_return(body: fixture('not_found.json'), status: 404, headers: {content_type: 'application/json; charset=utf-8'}) @@ -555,6 +566,7 @@ expect($stdout.string.chomp).to eq 'Yes, @sferik follows @testcli.' end end + context 'with a user passed' do before do stub_get('/1.1/friendships/show.json').with(query: {source_screen_name: 'ev', target_screen_name: 'sferik'}).to_return(body: fixture('following.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -600,6 +612,7 @@ end end end + context 'false' do before do stub_get('/1.1/friendships/show.json').with(query: {source_screen_name: 'ev', target_screen_name: 'testcli'}).to_return(body: fixture('not_following.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -751,6 +764,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -766,6 +780,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -830,6 +845,7 @@ end end end + context '--max-id' do before do @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744) @@ -841,6 +857,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '20', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--number' do before do stub_get('/1.1/favorites/list.json').with(query: {count: '1', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -860,6 +877,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '1', max_id: '265500541700956160', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744) @@ -871,6 +889,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '20', since_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context 'with a user passed' do before do stub_get('/1.1/favorites/list.json').with(query: {count: '20', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -891,6 +910,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {user_id: '7505382', count: '20', include_entities: 'false'})).to have_been_made end end + context '--max-id' do before do @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744) @@ -902,6 +922,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '20', screen_name: 'sferik', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--number' do before do stub_get('/1.1/favorites/list.json').with(query: {count: '1', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -921,6 +942,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '1', screen_name: 'sferik', max_id: '265500541700956160', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744) @@ -974,6 +996,7 @@ expect(a_post('/1.1/friendships/create.json').with(body: {user_id: '14100886'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', user_id: '7505382'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1021,6 +1044,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1035,6 +1059,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1045,6 +1070,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1055,6 +1081,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1065,6 +1092,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1075,6 +1103,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1085,6 +1114,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1095,6 +1125,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1105,6 +1136,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1115,6 +1147,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1125,6 +1158,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with a user passed' do before do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1136,6 +1170,7 @@ expect(a_get('/1.1/users/lookup.json').with(query: {user_id: '7505382'})).to have_been_made end end + context '--id' do before do @cli.options = @cli.options.merge('id' => true) @@ -1181,6 +1216,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1195,6 +1231,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1205,6 +1242,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1215,6 +1253,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1225,6 +1264,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1235,6 +1275,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1245,6 +1286,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1255,6 +1297,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1265,6 +1308,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1275,6 +1319,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1285,6 +1330,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with two users passed' do before do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', screen_name: 'pengwynn'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1345,6 +1391,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1359,6 +1406,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1369,6 +1417,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1379,6 +1428,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1389,6 +1439,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1399,6 +1450,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1409,6 +1461,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1419,6 +1472,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1429,6 +1483,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1439,6 +1494,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1449,6 +1505,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with a user passed' do before do stub_get('/1.1/followers/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1508,6 +1565,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1522,6 +1580,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1532,6 +1591,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1542,6 +1602,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1552,6 +1613,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1562,6 +1624,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1572,6 +1635,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1582,6 +1646,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1592,6 +1657,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1602,6 +1668,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1612,6 +1679,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with a user passed' do before do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1674,6 +1742,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1688,6 +1757,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1698,6 +1768,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1708,6 +1779,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1718,6 +1790,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1728,6 +1801,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1738,6 +1812,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1748,6 +1823,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1758,6 +1834,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1768,6 +1845,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1778,6 +1856,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with a user passed' do before do stub_get('/1.1/followers/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('followers_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -1839,6 +1918,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -1853,6 +1933,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -1863,6 +1944,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -1873,6 +1955,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -1883,6 +1966,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -1893,6 +1977,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -1903,6 +1988,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -1913,6 +1999,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -1923,6 +2010,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -1933,6 +2021,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--type=followers' do before do @cli.options = @cli.options.merge('type' => 'followers') @@ -1952,6 +2041,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -1962,6 +2052,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with two users passed' do before do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', screen_name: 'pengwynn'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -2024,6 +2115,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -2038,6 +2130,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -2048,6 +2141,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -2058,6 +2152,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -2068,6 +2163,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -2078,6 +2174,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -2088,6 +2185,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -2098,6 +2196,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -2108,6 +2207,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -2118,6 +2218,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -2128,6 +2229,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'with a user passed' do before do stub_get('/1.1/friends/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('friends_ids.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -2185,6 +2287,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -2200,6 +2303,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -2210,6 +2314,7 @@ expect($stdout.string.chomp).to eq '@sferik/test @twitter/team @pengwynn/rubyists' end end + context '--sort=members' do before do @cli.options = @cli.options.merge('sort' => 'members') @@ -2220,6 +2325,7 @@ expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team' end end + context '--sort=mode' do before do @cli.options = @cli.options.merge('sort' => 'mode') @@ -2230,6 +2336,7 @@ expect($stdout.string.chomp).to eq '@twitter/team @sferik/test @pengwynn/rubyists' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -2240,6 +2347,7 @@ expect($stdout.string.chomp).to eq '@twitter/team @pengwynn/rubyists @sferik/test' end end + context '--sort=subscribers' do before do @cli.options = @cli.options.merge('sort' => 'subscribers') @@ -2250,6 +2358,7 @@ expect($stdout.string.chomp).to eq '@sferik/test @pengwynn/rubyists @twitter/team' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -2260,6 +2369,7 @@ expect($stdout.string.chomp).to eq '@pengwynn/rubyists @twitter/team @sferik/test' end end + context 'with a user passed' do before do stub_get('/1.1/lists/list.json').with(query: {screen_name: 'sferik'}).to_return(body: fixture('lists.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -2421,6 +2531,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -2436,6 +2547,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -2500,6 +2612,7 @@ end end end + context '--number' do before do stub_get('/1.1/statuses/mentions_timeline.json').with(query: {count: '1', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -2586,6 +2699,7 @@ expect(a_get('/1.1/users/show.json').with(query: {user_id: '420'})).to have_been_made end end + context '--status' do before do @cli.options = @cli.options.merge('status' => true) @@ -2667,6 +2781,7 @@ expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench @sferik.' end end + context 'with file' do before do @cli.options = @cli.options.merge('file' => "#{fixture_path}/long.png") @@ -2684,6 +2799,7 @@ expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.' end end + context '--location' do before do @cli.options = @cli.options.merge('location' => 'location') @@ -2703,6 +2819,7 @@ expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.' end end + context "--location 'latitude,longitude'" do before do @cli.options = @cli.options.merge('location' => '41.03132,28.9869') @@ -2722,6 +2839,7 @@ expect($stdout.string.split("\n").first).to eq 'Reply posted by @testcli to @joshfrench.' end end + context 'no status provided' do it 'opens an editor to prompt for the status' do expect(T::Editor).to receive(:gets).and_return 'Testing' @@ -2871,6 +2989,7 @@ EOS end end + context '--csv' do before do @cli.options = @cli.options.merge('csv' => true) @@ -2903,6 +3022,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -2916,6 +3036,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', max_id: '244102729860009983', include_entities: 'true'})).to have_been_made.times(3) end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -2980,6 +3101,7 @@ end end end + context '--number' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -2998,6 +3120,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', max_id: '244107823733174271', include_entities: 'false'})).to have_been_made end end + context 'with a user passed' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3116,6 +3239,7 @@ EOS end end + context '--csv' do before do @cli.options = @cli.options.merge('csv' => true) @@ -3148,6 +3272,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -3159,6 +3284,7 @@ expect(a_get('/1.1/statuses/retweets_of_me.json').with(query: {count: '20', include_entities: 'true'})).to have_been_made end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -3223,6 +3349,7 @@ end end end + context '--number' do before do stub_get('/1.1/statuses/retweets_of_me.json').with(query: {count: '1', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3302,6 +3429,7 @@ EOS end end + context 'with no street address' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_street_address.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3321,6 +3449,7 @@ EOS end end + context 'with no locality' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_locality.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3340,6 +3469,7 @@ EOS end end + context 'with no attributes' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_attributes.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3359,6 +3489,7 @@ EOS end end + context 'with no country' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_country.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3378,6 +3509,7 @@ EOS end end + context 'with no full name' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_full_name.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3397,6 +3529,7 @@ EOS end end + context 'with no place' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_place.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3436,6 +3569,7 @@ EOS end end + context 'with no state' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status_no_place.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3457,6 +3591,7 @@ end end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -3470,6 +3605,7 @@ EOS end end + describe '--relative-dates' do before do stub_get('/1.1/statuses/show/55709764298092545.json').with(query: {include_my_retweet: 'false', include_entities: 'false'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3521,6 +3657,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -3628,6 +3765,7 @@ EOS end end + context '--csv' do before do @cli.options = @cli.options.merge('csv' => true) @@ -3660,6 +3798,7 @@ EOS end end + context '--decode-uris' do before do @cli.options = @cli.options.merge('decode_uris' => true) @@ -3675,6 +3814,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--exclude=replies' do before do @cli.options = @cli.options.merge('exclude' => 'replies') @@ -3686,6 +3826,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '20', exclude_replies: 'true', include_entities: 'false'})).to have_been_made end end + context '--exclude=retweets' do before do @cli.options = @cli.options.merge('exclude' => 'retweets') @@ -3697,6 +3838,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '20', include_rts: 'false', include_entities: 'false'})).to have_been_made end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -3761,6 +3903,7 @@ end end end + context '--max-id' do before do @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744) @@ -3772,6 +3915,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '20', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--number' do before do stub_get('/1.1/statuses/home_timeline.json').with(query: {count: '1', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3791,6 +3935,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '1', max_id: '265500541700956160', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744) @@ -3802,6 +3947,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '20', since_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context 'with a user passed' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '20', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3822,6 +3968,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '20', user_id: '7505382', include_entities: 'false'})).to have_been_made end end + context '--max-id' do before do @cli.options = @cli.options.merge('max_id' => 244_104_558_433_951_744) @@ -3833,6 +3980,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '20', screen_name: 'sferik', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--number' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '1', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3852,6 +4000,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '1', screen_name: 'sferik', max_id: '265500541700956160', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @cli.options = @cli.options.merge('since_id' => 244_104_558_433_951_744) @@ -3894,6 +4043,7 @@ expect($stdout.string.chomp).to eq '#sevenwordsaftersex Walkman Allen Iverson' end end + context 'with a WOEID passed' do before do stub_get('/1.1/trends/place.json').with(query: {id: '2487956'}).to_return(body: fixture('trends.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -3939,6 +4089,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -3955,6 +4106,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -3965,6 +4117,7 @@ expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco' end end + context '--sort=country' do before do @cli.options = @cli.options.merge('sort' => 'country') @@ -3975,6 +4128,7 @@ expect($stdout.string.chomp).to eq 'Worldwide Soweto San Francisco United States' end end + context '--sort=parent' do before do @cli.options = @cli.options.merge('sort' => 'parent') @@ -3985,6 +4139,7 @@ expect($stdout.string.chomp).to eq 'Worldwide United States Soweto San Francisco' end end + context '--sort=type' do before do @cli.options = @cli.options.merge('sort' => 'type') @@ -3995,6 +4150,7 @@ expect($stdout.string.chomp).to eq 'United States Worldwide San Francisco Soweto' end end + context '--sort=woeid' do before do @cli.options = @cli.options.merge('sort' => 'woeid') @@ -4005,6 +4161,7 @@ expect($stdout.string.chomp).to eq 'Worldwide Soweto San Francisco United States' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -4044,6 +4201,7 @@ expect(a_post('/1.1/friendships/destroy.json').with(body: {user_id: '7505382'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_post('/1.1/friendships/destroy.json').with(body: {screen_name: 'sferik'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -4091,6 +4249,7 @@ expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.' end end + context '--location' do before do @cli.options = @cli.options.merge('location' => 'location') @@ -4108,6 +4267,7 @@ expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.' end end + context "--location 'latitude,longitude'" do before do @cli.options = @cli.options.merge('location' => '41.03132,28.9869') @@ -4125,6 +4285,7 @@ expect($stdout.string.split("\n").first).to eq 'Tweet posted by @testcli.' end end + context 'no status provided' do it 'opens an editor to prompt for the status' do expect(T::Editor).to receive(:gets).and_return 'Testing' @@ -4160,6 +4321,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -4174,6 +4336,7 @@ EOS end end + context '--reverse' do before do @cli.options = @cli.options.merge('reverse' => true) @@ -4184,6 +4347,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @cli.options = @cli.options.merge('sort' => 'favorites') @@ -4194,6 +4358,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @cli.options = @cli.options.merge('sort' => 'followers') @@ -4204,6 +4369,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @cli.options = @cli.options.merge('sort' => 'friends') @@ -4214,6 +4380,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--id' do before do @cli.options = @cli.options.merge('id' => true) @@ -4225,6 +4392,7 @@ expect(a_get('/1.1/users/lookup.json').with(query: {user_id: '7505382,14100886'})).to have_been_made end end + context '--sort=listed' do before do @cli.options = @cli.options.merge('sort' => 'listed') @@ -4235,6 +4403,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @cli.options = @cli.options.merge('sort' => 'since') @@ -4245,6 +4414,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @cli.options = @cli.options.merge('sort' => 'tweets') @@ -4255,6 +4425,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @cli.options = @cli.options.merge('sort' => 'tweeted') @@ -4265,6 +4436,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @cli.options = @cli.options.merge('unsorted' => true) @@ -4324,6 +4496,7 @@ EOS end end + context '--id' do before do @cli.options = @cli.options.merge('id' => true) @@ -4335,6 +4508,7 @@ expect(a_get('/1.1/users/show.json').with(query: {user_id: '7505382', include_entities: 'false'})).to have_been_made end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -4390,6 +4564,7 @@ EOS end end + context '--long' do before do @cli.options = @cli.options.merge('long' => true) @@ -4403,6 +4578,7 @@ EOS end end + context 'no configuration' do it 'prints a helpful message and no errors' do T::RCFile.instance.path = '' diff --git a/spec/delete_spec.rb b/spec/delete_spec.rb index 1cafef38..1a57f1ec 100644 --- a/spec/delete_spec.rb +++ b/spec/delete_spec.rb @@ -67,6 +67,7 @@ expect($stdout.string.chomp).to eq '@testcli deleted the direct message sent to @sferik: "testing"' end end + context 'no' do it 'has the correct output' do expect(Readline).to receive(:readline).with('Are you sure you want to permanently delete the direct message to @sferik: "testing"? [y/N] ', false).and_return('no') @@ -74,6 +75,7 @@ expect($stdout.string.chomp).to be_empty end end + context '--force' do before do @delete.options = @delete.options.merge('force' => true) @@ -110,6 +112,7 @@ expect($stdout.string).to match(/^@testcli unfavorited @sferik's status: "The problem with your code is that it's doing exactly what you told it to do\."$/) end end + context 'no' do it 'has the correct output' do expect(Readline).to receive(:readline).with("Are you sure you want to remove @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\" from your favorites? [y/N] ", false).and_return('no') @@ -117,6 +120,7 @@ expect($stdout.string.chomp).to be_empty end end + context '--force' do before do @delete.options = @delete.options.merge('force' => true) @@ -154,6 +158,7 @@ expect($stdout.string.chomp).to eq '@testcli deleted the list "presidents".' end end + context 'no' do it 'has the correct output' do expect(Readline).to receive(:readline).with('Are you sure you want to permanently delete the list "presidents"? [y/N] ', false).and_return('no') @@ -161,6 +166,7 @@ expect($stdout.string.chomp).to be_empty end end + context '--force' do before do @delete.options = @delete.options.merge('force' => true) @@ -176,6 +182,7 @@ expect($stdout.string.chomp).to eq '@testcli deleted the list "presidents".' end end + context '--id' do before do @delete.options = @delete.options.merge('id' => true) @@ -283,6 +290,7 @@ expect($stdout.string.chomp).to eq "@testcli deleted the Tweet: \"The problem with your code is that it's doing exactly what you told it to do.\"" end end + context 'no' do it 'has the correct output' do expect(Readline).to receive(:readline).with("Are you sure you want to permanently delete @sferik's status: \"The problem with your code is that it's doing exactly what you told it to do.\"? [y/N] ", false).and_return('no') @@ -290,6 +298,7 @@ expect($stdout.string.chomp).to be_empty end end + context '--force' do before do @delete.options = @delete.options.merge('force' => true) diff --git a/spec/list_spec.rb b/spec/list_spec.rb index faaaf24e..f7c12504 100644 --- a/spec/list_spec.rb +++ b/spec/list_spec.rb @@ -56,6 +56,7 @@ expect(a_post('/1.1/lists/members/create_all.json').with(body: {user_id: '7505382', slug: 'presidents', owner_id: '7505382'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_post('/1.1/lists/members/create_all.json').with(body: {screen_name: 'BarackObama', slug: 'presidents', owner_id: '7505382'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -141,6 +142,7 @@ end end end + context '--csv' do before do @list.options = @list.options.merge('csv' => true) @@ -183,6 +185,7 @@ EOS end end + context '--long' do before do @list.options = @list.options.merge('long' => true) @@ -197,6 +200,7 @@ EOS end end + context '--reverse' do before do @list.options = @list.options.merge('reverse' => true) @@ -207,6 +211,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @list.options = @list.options.merge('sort' => 'favorites') @@ -217,6 +222,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @list.options = @list.options.merge('sort' => 'followers') @@ -227,6 +233,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @list.options = @list.options.merge('sort' => 'friends') @@ -237,6 +244,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @list.options = @list.options.merge('sort' => 'listed') @@ -247,6 +255,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @list.options = @list.options.merge('sort' => 'since') @@ -257,6 +266,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @list.options = @list.options.merge('sort' => 'tweets') @@ -267,6 +277,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @list.options = @list.options.merge('sort' => 'tweeted') @@ -277,6 +288,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @list.options = @list.options.merge('unsorted' => true) @@ -287,6 +299,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context 'with a user passed' do it 'requests the correct resource' do @list.members('testcli/presidents') @@ -335,6 +348,7 @@ expect(a_post('/1.1/lists/members/destroy_all.json').with(body: {user_id: '7505382', slug: 'presidents', owner_id: '7505382'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_post('/1.1/lists/members/destroy_all.json').with(body: {screen_name: 'BarackObama', slug: 'presidents', owner_id: '7505382'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -522,6 +536,7 @@ EOS end end + context '--color=auto' do before do @list.options = @list.options.merge('color' => 'auto') @@ -689,6 +704,7 @@ EOS end end + context '--color=icon' do before do @list.options = @list.options.merge('color' => 'icon') @@ -846,6 +862,7 @@ EOS end end + context '--decode-uris' do before do @list.options = @list.options.merge('decode_uris' => true) @@ -861,6 +878,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--long' do before do @list.options = @list.options.merge('long' => true) @@ -925,6 +943,7 @@ end end end + context '--number' do before do stub_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '1', slug: 'presidents', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -944,6 +963,7 @@ expect(a_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '1', max_id: '265500541700956160', slug: 'presidents', include_entities: 'false'})).to have_been_made end end + context 'with a user passed' do it 'requests the correct resource' do @list.timeline('testcli/presidents') diff --git a/spec/rcfile_spec.rb b/spec/rcfile_spec.rb index e02e7cb3..c645acaa 100644 --- a/spec/rcfile_spec.rb +++ b/spec/rcfile_spec.rb @@ -145,6 +145,7 @@ expect(rcfile.empty?).to be false end end + context 'when file does not exist at path' do it 'returns true' do rcfile = T::RCFile.instance @@ -162,6 +163,7 @@ expect(rcfile.load_file['profiles']['testcli']['abc123']['username']).to eq 'testcli' end end + context 'when file does not exist at path' do it 'loads default structure' do rcfile = T::RCFile.instance diff --git a/spec/search_spec.rb b/spec/search_spec.rb index ebaf37c7..0ecae657 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -149,6 +149,7 @@ EOS end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -181,6 +182,7 @@ EOS end end + context '--number' do before do stub_get('/1.1/search/tweets.json').with(query: {q: 'twitter', count: '1', include_entities: 'false'}).to_return(body: fixture('search2.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -239,6 +241,7 @@ EOS end end + context '--decode-uris' do before do @search.options = @search.options.merge('decode_uris' => true) @@ -256,6 +259,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -270,6 +274,7 @@ EOS end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/favorites/list.json').with(query: {count: '200', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -279,6 +284,7 @@ expect(a_get('/1.1/favorites/list.json').with(query: {count: '200', include_entities: 'false'})).to have_been_made.times(3) end end + context 'with a user passed' do before do stub_get('/1.1/favorites/list.json').with(query: {count: '200', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -367,6 +373,7 @@ EOS end end + context '--decode-uris' do before do @search.options = @search.options.merge('decode_uris' => true) @@ -384,6 +391,7 @@ expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152' end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -398,6 +406,7 @@ EOS end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/statuses/mentions_timeline.json').with(query: {count: '200', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -446,6 +455,7 @@ EOS end end + context '--decode-uris' do before do @search.options = @search.options.merge('decode_uris' => true) @@ -463,6 +473,7 @@ expect($stdout.string).to include 'https://dev.twitter.com/docs/api/post/direct_messages/destroy' end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -477,6 +488,7 @@ EOS end end + context 'with a user passed' do it 'requests the correct resource' do @search.list('testcli/presidents', 'twitter') @@ -496,6 +508,7 @@ end end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/lists/statuses.json').with(query: {count: '200', owner_screen_name: 'testcli', slug: 'presidents', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -539,6 +552,7 @@ EOS end end + context '--decode-uris' do before do @search.options = @search.options.merge('decode_uris' => true) @@ -556,6 +570,7 @@ expect($stdout.string).to include 'http://heymosaic.com/i/1Z8ssK' end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -569,6 +584,7 @@ EOS end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -578,6 +594,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', include_entities: 'false'})).to have_been_made.times(3) end end + context 'with a user passed' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', include_rts: 'true', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -658,6 +675,7 @@ EOS end end + context '--decode-uris' do before do @search.options = @search.options.merge('decode_uris' => true) @@ -675,6 +693,7 @@ expect($stdout.string).to include 'https://dev.twitter.com/docs/api/post/direct_messages/destroy' end end + context '--exclude=replies' do before do @search.options = @search.options.merge('exclude' => 'replies') @@ -688,6 +707,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', exclude_replies: 'true', max_id: '244099460672679937', include_entities: 'false'})).to have_been_made end end + context '--exclude=retweets' do before do @search.options = @search.options.merge('exclude' => 'retweets') @@ -701,6 +721,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', include_rts: 'false', max_id: '244099460672679937', include_entities: 'false'})).to have_been_made end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -715,6 +736,7 @@ EOS end end + context '--max-id' do before do @search.options = @search.options.merge('max_id' => 244_104_558_433_951_744) @@ -726,6 +748,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @search.options = @search.options.merge('since_id' => 244_104_558_433_951_744) @@ -739,6 +762,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', max_id: '244099460672679937', since_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -748,6 +772,7 @@ expect(a_get('/1.1/statuses/home_timeline.json').with(query: {count: '200', include_entities: 'false'})).to have_been_made.times(3) end end + context 'with a user passed' do before do stub_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', screen_name: 'sferik', include_entities: 'false'}).to_return(body: fixture('statuses.json'), headers: {content_type: 'application/json; charset=utf-8'}) @@ -785,6 +810,7 @@ EOS end end + context '--id' do before do @search.options = @search.options.merge('id' => true) @@ -798,6 +824,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', max_id: '244099460672679937', user_id: '7505382', include_entities: 'false'})).to have_been_made end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -812,6 +839,7 @@ EOS end end + context '--max-id' do before do @search.options = @search.options.merge('max_id' => 244_104_558_433_951_744) @@ -823,6 +851,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', screen_name: 'sferik', max_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context '--since-id' do before do @search.options = @search.options.merge('since_id' => 244_104_558_433_951_744) @@ -836,6 +865,7 @@ expect(a_get('/1.1/statuses/user_timeline.json').with(query: {count: '200', screen_name: 'sferik', max_id: '244099460672679937', since_id: '244104558433951744', include_entities: 'false'})).to have_been_made end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/statuses/user_timeline.json').with(query: {screen_name: 'sferik', count: '200', include_entities: 'false'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) @@ -877,6 +907,7 @@ EOS end end + context '--long' do before do @search.options = @search.options.merge('long' => true) @@ -891,6 +922,7 @@ EOS end end + context '--reverse' do before do @search.options = @search.options.merge('reverse' => true) @@ -901,6 +933,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=favorites' do before do @search.options = @search.options.merge('sort' => 'favorites') @@ -911,6 +944,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=followers' do before do @search.options = @search.options.merge('sort' => 'followers') @@ -921,6 +955,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=friends' do before do @search.options = @search.options.merge('sort' => 'friends') @@ -931,6 +966,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=listed' do before do @search.options = @search.options.merge('sort' => 'listed') @@ -941,6 +977,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=since' do before do @search.options = @search.options.merge('sort' => 'since') @@ -951,6 +988,7 @@ expect($stdout.string.chomp).to eq 'sferik pengwynn' end end + context '--sort=tweets' do before do @search.options = @search.options.merge('sort' => 'tweets') @@ -961,6 +999,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--sort=tweeted' do before do @search.options = @search.options.merge('sort' => 'tweeted') @@ -971,6 +1010,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context '--unsorted' do before do @search.options = @search.options.merge('unsorted' => true) @@ -981,6 +1021,7 @@ expect($stdout.string.chomp).to eq 'pengwynn sferik' end end + context 'Twitter is down' do it 'retries 3 times and then raise an error' do stub_get('/1.1/users/search.json').with(query: {page: '2', q: 'Erik'}).to_return(status: 502, headers: {content_type: 'application/json; charset=utf-8'}) diff --git a/spec/stream_spec.rb b/spec/stream_spec.rb index 2f939c19..0bf2997b 100644 --- a/spec/stream_spec.rb +++ b/spec/stream_spec.rb @@ -48,6 +48,7 @@ @stream.all end end + context '--long' do before do @stream.options = @stream.options.merge('long' => true) @@ -66,6 +67,7 @@ @stream.all end end + it 'invokes Twitter::Streaming::Client#sample' do allow(@streaming_client).to receive(:before_request) allow(@streaming_client).to receive(:sample) @@ -104,6 +106,7 @@ expect(a_get('/1.1/lists/members.json').with(query: {cursor: '-1', owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made end end + context '--long' do before do @stream.options = @stream.options.merge('long' => true) @@ -120,6 +123,7 @@ expect(a_get('/1.1/lists/members.json').with(query: {cursor: '-1', owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made end end + it 'performs a REST search when the stream initializes' do allow(@streaming_client).to receive(:before_request).and_yield allow(@streaming_client).to receive(:filter) @@ -178,6 +182,7 @@ @stream.search(%w[twitter gem]) end end + context '--long' do before do @stream.options = @stream.options.merge('long' => true) @@ -190,6 +195,7 @@ @stream.search(%w[twitter gem]) end end + it 'performs a REST search when the stream initializes' do allow(@streaming_client).to receive(:before_request).and_yield allow(@streaming_client).to receive(:filter) @@ -224,6 +230,7 @@ @stream.timeline end end + context '--long' do before do @stream.options = @stream.options.merge('long' => true) @@ -235,6 +242,7 @@ @stream.timeline end end + it 'performs a REST search when the stream initializes' do allow(@streaming_client).to receive(:before_request).and_yield allow(@streaming_client).to receive(:user) @@ -275,6 +283,7 @@ @stream.users('123') end end + context '--long' do before do @stream.options = @stream.options.merge('long' => true) @@ -293,6 +302,7 @@ @stream.users('123') end end + it 'invokes Twitter::Streaming::Client#follow' do allow(@streaming_client).to receive(:filter) expect(@streaming_client).to receive(:filter).with(follow: '123,456,789')