Sha256: fa97fe6578af04c98dbb8b37500f7926aca7b87ae943468d9acf135404878395
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' require 'grocer/ssl_server' describe Grocer::SSLServer do subject { described_class.new(options) } let(:options) { { port: 12345 } } let(:mock_server) { stub_everything } let(:mock_ssl_server) { stub_everything } let(:mock_client) { stub_everything } before do TCPServer.stubs(:new).returns(mock_server) OpenSSL::SSL::SSLServer.stubs(:new).returns(mock_ssl_server) mock_ssl_server.stubs(:accept).returns(mock_client).then.returns(nil) end it "is constructed with a port option" do subject.port.should == 12345 end describe "#accept" do it "accepts client connections, yielding the client socket" do clients = [] subject.accept { |c| clients << c } clients.should == [mock_client] end end describe "#close" do it "closes the SSL socket" do mock_ssl_server.expects(:close) subject.accept # "open" socket subject.close end it "is a no-op if the server has not been started" do mock_server.expects(:close).never mock_ssl_server.expects(:close).never subject.close end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grocer-0.0.9 | spec/grocer/ssl_server_spec.rb |
grocer-0.0.8 | spec/grocer/ssl_server_spec.rb |
grocer-0.0.7 | spec/grocer/ssl_server_spec.rb |