-
-
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.
Enable injection of custom TCP/SSL socket classes.
Twitter::Streaming::Client class now accepts custom TCP/SSL socket classes. It passes those along to Twitter::Streaming::Connection. It's possible to inject non-blocking sockets this way, which in turn makes it possible to use Twitter::Streaming funcitonality with Celluloid. The Connection class blocks the Actor's mailbox otherwise.
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 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
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,34 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Streaming::Connection do | ||
|
||
describe 'initialize' do | ||
|
||
context "no options provided" do | ||
subject(:connection) { Twitter::Streaming::Connection.new } | ||
|
||
it "sets the default socket classes" do | ||
connection.tcp_socket_klass == TCPSocket | ||
connection.tcp_socket_klass == OpenSSL::SSL::SSLSocket | ||
end | ||
end | ||
|
||
context "custom socket classes provided in opts" do | ||
class DummyTCPSocket; end | ||
class DummySSLSocket; end | ||
|
||
subject(:connection) { Twitter::Streaming::Connection.new( | ||
tcp_socket_klass: DummyTCPSocket, | ||
ssl_socket_klass: DummySSLSocket | ||
)} | ||
|
||
it "sets the default socket classes" do | ||
connection.tcp_socket_klass == DummyTCPSocket | ||
connection.ssl_socket_klass == DummySSLSocket | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
|