Sha256: 171b7a4f4be35ad77a35d9f1a033045fe3b50abee2791ba24b7486c941408409

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require_relative "spec_helper"

module Nyara
  describe Request do
    before :each do
      @request = Ext.request_new
      @request_attrs = {
        method_num: HTTP_METHODS['GET'],
        path: '/',
        query: HeaderHash.new.tap{|h| h['id'] = 1 },
        fiber: nil,
        scope: '/',
        format: 'html'
      }
      request_set_attrs
    end

    context "#scheme detect by forwarded.." do
      it "ssl" do
        @request.header['X-Forwarded-Ssl'] = 'on'
        assert_equal 'https', @request.scheme
      end

      it "scheme" do
        @request.header['X-Forwarded-Scheme'] = 'ical'
        assert_equal 'ical', @request.scheme
      end

      it "protocol" do
        @request.header['X-Forwarded-Proto'] = 'https,http'
        assert_equal 'https', @request.scheme
      end
    end

    it "#domain and #port" do
      @request.header['Host'] = "yavaeye.com:3000"
      assert_equal 'yavaeye.com', @request.domain
      assert_equal 3000, @request.port
    end

    def request_set_attrs
      Ext.request_set_attrs @request, @request_attrs
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nyara-0.0.1.pre.6 spec/request_spec.rb
nyara-0.0.1.pre.5 spec/request_spec.rb
nyara-0.0.1.pre.4 spec/request_spec.rb
nyara-0.0.1.pre.3 spec/request_spec.rb