Skip to content

Commit

Permalink
Add an empty line after it
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Apr 30, 2023
1 parent 64ce23e commit 3585768
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 0 deletions.
117 changes: 117 additions & 0 deletions spec/cli_spec.rb

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions spec/delete_spec.rb
Expand Up @@ -28,10 +28,12 @@
@delete.block('sferik')
expect(a_post('/1.1/blocks/destroy.json').with(body: {screen_name: 'sferik'})).to have_been_made
end

it 'has the correct output' do
@delete.block('sferik')
expect($stdout.string).to match(/^@testcli unblocked 1 user\.$/)
end

context '--id' do
before do
@delete.options = @delete.options.merge('id' => true)
Expand Down Expand Up @@ -60,6 +62,7 @@
expect(a_delete('/1.1/direct_messages/events/destroy.json').with(query: {id: '1773478249'})).to have_been_made
expect(a_get('/1.1/users/show.json').with(query: {user_id: '58983'})).to have_been_made
end

context 'yes' 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('yes')
Expand All @@ -85,6 +88,7 @@
@delete.dm('1773478249')
expect(a_delete('/1.1/direct_messages/events/destroy.json').with(query: {id: '1773478249'})).to have_been_made
end

it 'has the correct output' do
@delete.dm('1773478249')
expect($stdout.string.chomp).to eq '@testcli deleted 1 direct message.'
Expand All @@ -105,6 +109,7 @@
expect(a_get('/1.1/statuses/show/28439861609.json').with(query: {include_my_retweet: 'false'})).to have_been_made
expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '28439861609'})).to have_been_made
end

context 'yes' 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('yes')
Expand All @@ -130,6 +135,7 @@
@delete.favorite('28439861609')
expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '28439861609'})).to have_been_made
end

it 'has the correct output' do
@delete.favorite('28439861609')
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\."$/)
Expand All @@ -151,6 +157,7 @@
expect(a_get('/1.1/account/verify_credentials.json').with(query: {skip_status: 'true'})).to have_been_made
expect(a_post('/1.1/lists/destroy.json').with(body: {owner_id: '7505382', list_id: '8863586'})).to have_been_made
end

context 'yes' 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('yes')
Expand All @@ -177,6 +184,7 @@
expect(a_get('/1.1/account/verify_credentials.json').with(query: {skip_status: 'true'})).to have_been_made
expect(a_post('/1.1/lists/destroy.json').with(body: {owner_id: '7505382', list_id: '8863586'})).to have_been_made
end

it 'has the correct output' do
@delete.list('presidents')
expect($stdout.string.chomp).to eq '@testcli deleted the list "presidents".'
Expand Down Expand Up @@ -209,10 +217,12 @@
@delete.mute('sferik')
expect(a_post('/1.1/mutes/users/destroy.json').with(body: {screen_name: 'sferik'})).to have_been_made
end

it 'has the correct output' do
@delete.mute('sferik')
expect($stdout.string).to match(/^@testcli unmuted 1 user\.$/)
end

context '--id' do
before do
@delete.options = @delete.options.merge('id' => true)
Expand Down Expand Up @@ -283,6 +293,7 @@
expect(a_get('/1.1/statuses/show/26755176471724032.json').with(query: {include_my_retweet: 'false'})).to have_been_made
expect(a_post('/1.1/statuses/destroy/26755176471724032.json').with(body: {trim_user: 'true'})).to have_been_made
end

context 'yes' 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('yes')
Expand All @@ -308,6 +319,7 @@
@delete.status('26755176471724032')
expect(a_post('/1.1/statuses/destroy/26755176471724032.json').with(body: {trim_user: 'true'})).to have_been_made
end

it 'has the correct output' do
@delete.status('26755176471724032')
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.\""
Expand Down
19 changes: 19 additions & 0 deletions spec/list_spec.rb
Expand Up @@ -40,10 +40,12 @@
expect(a_get('/1.1/account/verify_credentials.json').with(query: {skip_status: 'true'})).to have_been_made
expect(a_post('/1.1/lists/members/create_all.json').with(body: {screen_name: 'BarackObama', slug: 'presidents', owner_id: '7505382'})).to have_been_made
end

it 'has the correct output' do
@list.add('presidents', 'BarackObama')
expect($stdout.string.split("\n").first).to eq '@testcli added 1 member to the list "presidents".'
end

context '--id' do
before do
@list.options = @list.options.merge('id' => true)
Expand Down Expand Up @@ -78,6 +80,7 @@
@list.create('presidents')
expect(a_post('/1.1/lists/create.json').with(body: {name: 'presidents'})).to have_been_made
end

it 'has the correct output' do
@list.create('presidents')
expect($stdout.string.chomp).to eq '@testcli created the list "presidents".'
Expand All @@ -94,6 +97,7 @@
@list.information('presidents')
expect(a_get('/1.1/lists/show.json').with(query: {owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made
end

it 'has the correct output' do
@list.information('presidents')
expect($stdout.string).to eq <<~EOS
Expand All @@ -109,6 +113,7 @@
URL https://twitter.com/sferik/presidents
EOS
end

it 'has the correct output with --relative-dates turned on' do
@list.options = @list.options.merge('relative_dates' => true)
@list.information('presidents')
Expand All @@ -125,11 +130,13 @@
URL https://twitter.com/sferik/presidents
EOS
end

context 'with a user passed' do
it 'requests the correct resource' do
@list.information('testcli/presidents')
expect(a_get('/1.1/lists/show.json').with(query: {owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made
end

context '--id' do
before do
@list.options = @list.options.merge('id' => true)
Expand Down Expand Up @@ -167,10 +174,12 @@
@list.members('presidents')
expect(a_get('/1.1/lists/members.json').with(query: {cursor: '-1', owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made
end

it 'has the correct output' do
@list.members('presidents')
expect($stdout.string.chomp).to eq 'pengwynn sferik'
end

context '--csv' do
before do
@list.options = @list.options.merge('csv' => true)
Expand Down Expand Up @@ -305,6 +314,7 @@
@list.members('testcli/presidents')
expect(a_get('/1.1/lists/members.json').with(query: {cursor: '-1', owner_screen_name: 'testcli', slug: 'presidents'})).to have_been_made
end

context '--id' do
before do
@list.options = @list.options.merge('id' => true)
Expand All @@ -331,11 +341,13 @@
expect(a_get('/1.1/account/verify_credentials.json').with(query: {skip_status: 'true'})).to have_been_made
expect(a_post('/1.1/lists/members/destroy_all.json').with(body: {screen_name: 'BarackObama', slug: 'presidents', owner_id: '7505382'})).to have_been_made
end

it 'has the correct output' do
stub_post('/1.1/lists/members/destroy_all.json').with(body: {screen_name: 'BarackObama', slug: 'presidents', owner_id: '7505382'}).to_return(body: fixture('list.json'), headers: {content_type: 'application/json; charset=utf-8'})
@list.remove('presidents', 'BarackObama')
expect($stdout.string.split("\n").first).to eq '@testcli removed 1 member from the list "presidents".'
end

context '--id' do
before do
@list.options = @list.options.merge('id' => true)
Expand Down Expand Up @@ -370,6 +382,7 @@
@list.timeline('presidents')
expect(a_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '20', slug: 'presidents', include_entities: 'false'})).to have_been_made
end

it 'has the correct output' do
@list.timeline('presidents')
expect($stdout.string).to eq <<-EOS
Expand Down Expand Up @@ -450,6 +463,7 @@
EOS
end

context '--color=never' do
before do
@list.options = @list.options.merge('color' => 'never')
Expand Down Expand Up @@ -622,6 +636,7 @@
EOS
end

it 'outputs with color when stdout is a tty' do
allow($stdout).to receive(:tty?).and_return(true)
@list.timeline('presidents')
Expand Down Expand Up @@ -873,6 +888,7 @@
@list.timeline('presidents')
expect(a_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '20', slug: 'presidents', include_entities: 'true'})).to have_been_made
end

it 'decodes URLs' do
@list.timeline('presidents')
expect($stdout.string).to include 'https://twitter.com/sferik/status/243988000076337152'
Expand Down Expand Up @@ -910,6 +926,7 @@
244099460672679938 Sep 7 07:47 @dwiskus Gentlemen, you can't fig...
EOS
end

context '--reverse' do
before do
@list.options = @list.options.merge('reverse' => true)
Expand Down Expand Up @@ -956,6 +973,7 @@
@list.timeline('presidents')
expect(a_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '1', slug: 'presidents', include_entities: 'false'})).to have_been_made
end

it 'limits the number of results to 201' do
@list.options = @list.options.merge('number' => 201)
@list.timeline('presidents')
Expand All @@ -969,6 +987,7 @@
@list.timeline('testcli/presidents')
expect(a_get('/1.1/lists/statuses.json').with(query: {owner_screen_name: 'testcli', count: '20', slug: 'presidents', include_entities: 'false'})).to have_been_made
end

context '--id' do
before do
@list.options = @list.options.merge('id' => true)
Expand Down
3 changes: 3 additions & 0 deletions spec/rcfile_spec.rb
Expand Up @@ -38,6 +38,7 @@
}
expect(rcfile['testcli'].keys).to eq %w[abc123]
end

it 'is not be world writable' do
rcfile = T::RCFile.instance
rcfile.path = "#{project_path}/tmp/trc"
Expand All @@ -52,6 +53,7 @@
}
expect(File.world_writable?(rcfile.path)).to be_nil
end

it 'is not be world readable' do
rcfile = T::RCFile.instance
rcfile.path = "#{project_path}/tmp/trc"
Expand Down Expand Up @@ -185,6 +187,7 @@
rcfile.path = "#{project_path}/tmp/trc"
expect(rcfile.path).to eq "#{project_path}/tmp/trc"
end

it 'reloads data' do
rcfile = T::RCFile.instance
rcfile.path = "#{fixture_path}/.trc"
Expand Down

0 comments on commit 3585768

Please sign in to comment.