Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thiagoa/ba8012a1bb813cb5c9c7cf86707d82df to your computer and use it in GitHub Desktop.
Save thiagoa/ba8012a1bb813cb5c9c7cf86707d82df to your computer and use it in GitHub Desktop.
When unauthorized error refers to an invalid token
context 'when the timeline is unauthorized' do
# previous context here
context 'when the unauthorized error refers to an invalid token' do
it 'fails' do
twitter_client = instance_double(Twitter::REST::Client)
allow(twitter_client).to receive(:user_timeline)
.with('screen_name', count: 5)
.once {
fail Twitter::Error::Unauthorized, 'Invalid or expired token'
}
twitter_timeline_hub = TwitterTimelineHub.new(twitter_client)
expect { twitter_timeline_hub.call('screen_name', count: 5) }.to(
raise_error(Twitter::Error::Unauthorized)
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment