Sha256: 49247f54366b94d1310d4012d0409231b34445a78f60324fd839f5ccffc0ba5f

Contents?: true

Size: 1.95 KB

Versions: 9

Compression:

Stored size: 1.95 KB

Contents

shared_examples_for 'all server drafts' do
  def validate_request
    handshake << client_request

    handshake.error.should be_nil
    handshake.should be_finished
    handshake.should be_valid
    handshake.to_s.should eql(server_response)
  end

  it "should be valid" do
    handshake << client_request

    handshake.error.should be_nil
    handshake.should be_finished
    handshake.should be_valid
  end

  it "should return valid version" do
    handshake << client_request

    handshake.version.should eql(version)
  end

  it "should return valid host" do
    @request_params = { :host => "www.test.cc" }
    handshake << client_request

    handshake.host.should eql('www.test.cc')
  end

  it "should return valid path" do
    @request_params = { :path => "/custom" }
    handshake << client_request

    handshake.path.should eql('/custom')
  end

  it "should return valid query" do
    @request_params = { :path => "/custom?aaa=bbb" }
    handshake << client_request

    handshake.query.should eql('aaa=bbb')
  end

  it "should return valid port" do
    @request_params = { :port => 123 }
    handshake << client_request

    handshake.port.should eql("123")
  end

  it "should return valid response" do
    validate_request
  end

  it "should allow custom path" do
    @request_params = { :path => "/custom" }
    validate_request
  end

  it "should allow query in path" do
    @request_params = { :path => "/custom?test=true" }
    validate_request
  end

  it "should allow custom port" do
    @request_params = { :port => 123 }
    validate_request
  end

  it "should recognize unfinished requests" do
    handshake << client_request[0..-10]

    handshake.should_not be_finished
    handshake.should_not be_valid
  end

  it "should disallow requests with invalid request method" do
    handshake << client_request.gsub('GET', 'POST')

    handshake.should be_finished
    handshake.should_not be_valid
    handshake.error.should eql(:get_request_required)
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
websocket-1.0.7 spec/support/all_server_drafts.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/websocket-1.0.6/spec/support/all_server_drafts.rb
websocket-1.0.6 spec/support/all_server_drafts.rb
websocket-1.0.5 spec/support/all_server_drafts.rb
websocket-1.0.4 spec/support/all_server_drafts.rb
websocket-1.0.3 spec/support/all_server_drafts.rb
websocket-1.0.2 spec/support/all_server_drafts.rb
websocket-1.0.1 spec/support/all_server_drafts.rb
websocket-1.0.0 spec/support/all_server_drafts.rb