Skip to content

Commit

Permalink
Add an empty line after before
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Feb 4, 2023
1 parent 79ca50e commit 6cdf65a
Show file tree
Hide file tree
Showing 26 changed files with 292 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/twitter/cursor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
stub_get('/1.1/followers/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'}).to_return(body: fixture('ids_list.json'), headers: {content_type: 'application/json; charset=utf-8'})
stub_get('/1.1/followers/ids.json').with(query: {cursor: '1305102810874389703', screen_name: 'sferik'}).to_return(body: fixture('ids_list2.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resources' do
@client.follower_ids('sferik').each {}
expect(a_get('/1.1/followers/ids.json').with(query: {cursor: '-1', screen_name: 'sferik'})).to have_been_made
Expand Down
2 changes: 2 additions & 0 deletions spec/twitter/error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
body = "{\"#{key}\":\"Internal Server Error\"}"
stub_get('/1.1/statuses/user_timeline.json').with(query: {screen_name: 'sferik'}).to_return(status: 500, body: body, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'raises an exception with the proper message' do
expect { @client.user_timeline('sferik') }.to raise_error(Twitter::Error::InternalServerError)
end
Expand All @@ -43,6 +44,7 @@
before do
stub_get('/1.1/statuses/user_timeline.json').with(query: {screen_name: 'sferik'}).to_return(status: status, body: '{}', headers: {content_type: 'application/json; charset=utf-8'})
end

it "raises #{exception}" do
expect { @client.user_timeline('sferik') }.to raise_error(exception)
end
Expand Down
1 change: 1 addition & 0 deletions spec/twitter/geo_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
before do
@geo_results = described_class.new(result: {places: [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}, {id: 6}]})
end

it 'iterates' do
count = 0
@geo_results.each { count += 1 }
Expand Down
2 changes: 2 additions & 0 deletions spec/twitter/rate_limit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
before do
Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
end

after do
Timecop.return
end

it 'returns an Integer when x-rate-limit-reset header is set' do
rate_limit = described_class.new('x-rate-limit-reset' => '1339019097')
expect(rate_limit.reset_in).to be_an Integer
Expand Down
7 changes: 7 additions & 0 deletions spec/twitter/rest/account_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
before do
stub_post('/1.1/account_activity/all/env_name/webhooks.json?url=url').with(query: {url: 'url'}).to_return(body: fixture('account_activity_create_webhook.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request create webhook' do
@client.create_webhook('env_name', 'url')
expect(a_post('/1.1/account_activity/all/env_name/webhooks.json?url=url').with(body: {})).to have_been_made
Expand All @@ -28,6 +29,7 @@
before do
stub_get('/1.1/account_activity/all/env_name/webhooks.json').to_return(body: fixture('account_activity_list_webhook.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request list webhooks' do
@client.list_webhooks('env_name')
expect(a_get('/1.1/account_activity/all/env_name/webhooks.json').with(body: {})).to have_been_made
Expand All @@ -48,6 +50,7 @@
before do
stub_put('/1.1/account_activity/all/env_name/webhooks/1234567890.json').to_return(status: 204, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request crc check' do
@client.trigger_crc_check('env_name', '1234567890')
expect(a_put('/1.1/account_activity/all/env_name/webhooks/1234567890.json').with(body: {})).to have_been_made
Expand All @@ -65,6 +68,7 @@
before do
stub_post('/1.1/account_activity/all/env_name/subscriptions.json').to_return(status: 204, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request create subscription' do
@client.create_subscription('env_name')
expect(a_post('/1.1/account_activity/all/env_name/subscriptions.json').with(body: {})).to have_been_made
Expand All @@ -82,6 +86,7 @@
before do
stub_get('/1.1/account_activity/all/env_name/subscriptions.json').to_return(status: 204, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request check subscription' do
@client.check_subscription('env_name')
expect(a_get('/1.1/account_activity/all/env_name/subscriptions.json').with(body: {})).to have_been_made
Expand All @@ -99,6 +104,7 @@
before do
stub_delete('/1.1/account_activity/all/env_name/webhooks/1234567890.json').to_return(status: 204, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request delete webhook' do
@client.delete_webhook('env_name', '1234567890')
expect(a_delete('/1.1/account_activity/all/env_name/webhooks/1234567890.json').with(body: {})).to have_been_made
Expand All @@ -116,6 +122,7 @@
before do
stub_delete('/1.1/account_activity/all/env_name/subscriptions.json').to_return(status: 204, headers: {content_type: 'application/json; charset=utf-8'})
end

it 'request deactivate subscription' do
@client.deactivate_subscription('env_name')
expect(a_delete('/1.1/account_activity/all/env_name/subscriptions.json').with(body: {})).to have_been_made
Expand Down
11 changes: 11 additions & 0 deletions spec/twitter/rest/direct_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
before do
stub_get('/1.1/direct_messages/events/list.json').with(query: {count: 50}).to_return(body: fixture('direct_message_events.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.direct_messages_received
expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: 50})).to have_been_made
Expand Down Expand Up @@ -51,6 +52,7 @@
before do
stub_get('/1.1/direct_messages/events/list.json').with(query: {count: 50}).to_return(body: fixture('direct_message_events.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.direct_messages_sent
expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: 50})).to have_been_made
Expand All @@ -68,6 +70,7 @@
before do
stub_get('/1.1/direct_messages/events/show.json').with(query: {id: '1825786345'}).to_return(body: fixture('direct_message_event.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.direct_message(1_825_786_345)
expect(a_get('/1.1/direct_messages/events/show.json').with(query: {id: '1825786345'})).to have_been_made
Expand All @@ -85,6 +88,7 @@
before do
stub_get('/1.1/direct_messages/events/show.json').with(query: {id: '1825786345'}).to_return(body: fixture('direct_message_event.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.direct_messages(1_825_786_345)
expect(a_get('/1.1/direct_messages/events/show.json').with(query: {id: '1825786345'})).to have_been_made
Expand All @@ -101,6 +105,7 @@
before do
stub_get('/1.1/direct_messages/events/list.json').with(query: {count: 50}).to_return(body: fixture('direct_message_events.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.direct_messages
expect(a_get('/1.1/direct_messages/events/list.json').with(query: {count: 50})).to have_been_made
Expand All @@ -119,6 +124,7 @@
before do
stub_delete('/1.1/direct_messages/events/destroy.json?id=1825785544').to_return(status: 204, body: '', headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.destroy_direct_message(1_825_785_544)
expect(a_delete('/1.1/direct_messages/events/destroy.json?id=1825785544')).to have_been_made
Expand All @@ -145,6 +151,7 @@
before do
stub_post('/1.1/direct_messages/events/new.json').to_return(body: fixture('direct_message_event.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.create_direct_message('7505382', "My #newride from @PUBLICBikes. Don't you want one? https://t.co/7HIwCl68Y8 https://t.co/JSSxDPr4Sf")
expect(a_post('/1.1/direct_messages/events/new.json').with(body: json_options)).to have_been_made
Expand All @@ -162,6 +169,7 @@
before do
stub_post('/1.1/direct_messages/events/new.json').with(body: {event: {type: 'message_create', message_create: {target: {recipient_id: 58_983}, message_data: {text: 'testing'}}}}).to_return(body: fixture('direct_message_event.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.create_direct_message_event(58_983, 'testing')
expect(a_post('/1.1/direct_messages/events/new.json').with(body: {event: {type: 'message_create', message_create: {target: {recipient_id: 58_983}, message_data: {text: 'testing'}}}})).to have_been_made
Expand All @@ -179,6 +187,7 @@
stub_post('/1.1/direct_messages/events/new.json').to_return(body: fixture('direct_message_event.json'), headers: {content_type: 'application/json; charset=utf-8'})
stub_request(:post, 'https://upload.twitter.com/1.1/media/upload.json').to_return(body: fixture('upload.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

context 'with a gif image' do
it 'requests the correct resource' do
@client.create_direct_message_event_with_media(58_983, 'testing', fixture('pbjt.gif'))
Expand All @@ -197,6 +206,7 @@
before do
expect(File).to receive(:size).with(big_gif).and_return(7_000_000)
end

it 'requests the correct resource' do
@client.create_direct_message_event_with_media(58_983, 'testing', big_gif)
expect(a_request(:post, 'https://upload.twitter.com/1.1/media/upload.json')).to have_been_made.times(3)
Expand Down Expand Up @@ -276,6 +286,7 @@
end
context 'when Twitter::Client#timeouts[:upload] is set' do
before(:each) { @client.timeouts = {upload: 0.1} }

it 'raises an error when the finalize step is too slow' do
init_request = {body: fixture('chunk_upload_init.json'), headers: {content_type: 'application/json; charset=utf-8'}}
append_request = {body: '', headers: {content_type: 'text/html;charset=utf-8'}}
Expand Down
13 changes: 13 additions & 0 deletions spec/twitter/rest/favorites_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
before do
stub_get('/1.1/favorites/list.json').with(query: {screen_name: 'sferik'}).to_return(body: fixture('user_timeline.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.favorites('sferik')
expect(a_get('/1.1/favorites/list.json').with(query: {screen_name: 'sferik'})).to have_been_made
Expand All @@ -34,6 +35,7 @@
before do
stub_get('/1.1/favorites/list.json').to_return(body: fixture('user_timeline.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.favorites
expect(a_get('/1.1/favorites/list.json')).to have_been_made
Expand All @@ -52,6 +54,7 @@
before do
stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.unfavorite(540_897_316_908_331_009)
expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'})).to have_been_made
Expand All @@ -68,6 +71,7 @@
before do
stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'does not raise an error' do
expect { @client.unfavorite(540_897_316_908_331_009) }.not_to raise_error
end
Expand All @@ -92,6 +96,7 @@
before do
stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.unfavorite!(540_897_316_908_331_009)
expect(a_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'})).to have_been_made
Expand All @@ -108,6 +113,7 @@
before do
stub_post('/1.1/favorites/destroy.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'raises a NotFound error' do
expect { @client.unfavorite!(540_897_316_908_331_009) }.to raise_error(Twitter::Error::NotFound)
end
Expand All @@ -132,6 +138,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.favorite(540_897_316_908_331_009)
expect(a_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'})).to have_been_made
Expand All @@ -148,6 +155,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(status: 403, body: fixture('already_favorited.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'does not raise an error' do
expect { @client.favorite(540_897_316_908_331_009) }.not_to raise_error
end
Expand All @@ -156,6 +164,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'does not raise an error' do
expect { @client.favorite(540_897_316_908_331_009) }.not_to raise_error
end
Expand All @@ -180,6 +189,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(body: fixture('status.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'requests the correct resource' do
@client.favorite!(540_897_316_908_331_009)
expect(a_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'})).to have_been_made
Expand All @@ -196,6 +206,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(status: 403, body: '{}', headers: {content_type: 'application/json; charset=utf-8'})
end

it 'raises a Forbidden error' do
expect { @client.favorite!(540_897_316_908_331_009) }.to raise_error(Twitter::Error::Forbidden)
end
Expand All @@ -204,6 +215,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(status: 403, body: fixture('already_favorited.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'raises an AlreadyFavorited error' do
expect { @client.favorite!(540_897_316_908_331_009) }.to raise_error(Twitter::Error::AlreadyFavorited)
end
Expand All @@ -212,6 +224,7 @@
before do
stub_post('/1.1/favorites/create.json').with(body: {id: '540897316908331009'}).to_return(status: 404, body: fixture('not_found.json'), headers: {content_type: 'application/json; charset=utf-8'})
end

it 'raises a NotFound error' do
expect { @client.favorite!(540_897_316_908_331_009) }.to raise_error(Twitter::Error::NotFound)
end
Expand Down
Loading

0 comments on commit 6cdf65a

Please sign in to comment.