Sha256: e0bbc39634d5325f38936fc93b13b9cd16c5f1ea81a9f67401b8b87cc6176d67
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. require 'async/websocket' require 'async/websocket/client' require 'rack/test' require 'falcon/server' require 'falcon/adapters/rack' RSpec.describe Async::WebSocket::Connection do include_context Async::RSpec::Reactor let(:server_address) {Async::IO::Endpoint.tcp('0.0.0.0', 9000)} let(:app) {Rack::Builder.parse_file(File.expand_path('../connection_spec.ru', __FILE__)).first} let(:server) {Falcon::Server.new(Falcon::Adapters::Rack.new(app), server_address)} it "should connect to the websocket server" do server_task = reactor.async do server.run end events = [] server_address.connect do |socket| client = Async::WebSocket::Client.new(socket) while event = client.next_event events << event end client.close # optional end expect(events.size).to be > 0 server_task.stop end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
async-websocket-0.5.0 | spec/async/websocket/connection_spec.rb |
async-websocket-0.4.1 | spec/async/websocket/connection_spec.rb |
async-websocket-0.4.0 | spec/async/websocket/connection_spec.rb |