Sha256: fca3208d63878c2f0422bf9be735acf89a13520f309f7f5fec19726b797bd3ae

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

require 'minitest/autorun'
require 'rack/test'
require 'sinatra/base'
require 'sinatra/hijacker'
require 'socket'

class HijackerTest < MiniTest::Test
  include Rack::Test::Methods

  class App < Sinatra::Base
    register Sinatra::Hijacker
    get '/' do
      200
    end
    websocket '/ws' do
      ws.onmessage do
        throw :onmessage
      end
    end
  end
  
  def app
    App
  end
  
  def test_get
    get '/'
    assert last_response.ok?
  end
  
  def test_through_websocket?
    assert_raises Tubesock::HijackNotAvailable do
      get '/ws', {}, {'HTTP_CONNECTION' => 'UPGRADE', 'HTTP_UPGRADE' => 'WEBSOCKET' }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-hijacker-0.0.2 test/test_sinatra_hijacker.rb