Sha256: caf4b7d5ce971a406968aee603013accfb899c964ca413c69881c1a68656f9f8

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

require 'minitest/autorun'
#require 'rack/test'
require 'sinatra'
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.1 test/test_sinatra_hijacker.rb