-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the streaming API raise exceptions for status codes.
- Loading branch information
1 parent
86cf51a
commit b571e03
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Streaming::Response do | ||
subject { Twitter::Streaming::Response.new } | ||
|
||
describe '#on_headers_complete' do | ||
it 'should not error if status code is 200' do | ||
expect do | ||
subject << "HTTP/1.1 200 OK\r\nSome-Header: Woo\r\n\r\n" | ||
end.to_not raise_error | ||
end | ||
|
||
Twitter::Error.errors.each do |code, klass| | ||
it "should raise an exception of type #{klass} for status code #{code}" do | ||
expect do | ||
subject << "HTTP/1.1 #{code} NOK\r\nSome-Header: Woo\r\n\r\n" | ||
end.to raise_error(klass) | ||
end | ||
end | ||
end | ||
end |