Sha256: 4017212b3ecc05cf6c10ee1db33ca7258b0eda09ee253cd4012adb0e79517484

Contents?: true

Size: 847 Bytes

Versions: 4

Compression:

Stored size: 847 Bytes

Contents

require 'spec_helper'

describe 'host in the swagger_doc' do
  include_context 'the api entities'

  before :all do
    module TheApi
      class EmptyApi < Grape::API
        format :json

        add_swagger_documentation
      end
    end
  end

  def app
    TheApi::EmptyApi
  end

  describe 'host should include port' do
    subject do
      get 'http://example.com:8080/swagger_doc'
      JSON.parse(last_response.body)
    end

    specify do
      expect(subject['host']).to eq 'example.com:8080'
    end
  end

  describe 'respect X-Forwarded-Host over Host header' do
    subject do
      header 'Host', 'dummy.example.com'
      header 'X-Forwarded-Host', 'real.example.com'
      get '/swagger_doc'
      JSON.parse(last_response.body)
    end

    specify do
      expect(subject['host']).to eq 'real.example.com'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grape-swagger-0.23.0 spec/swagger_v2/host.rb
grape-swagger-0.22.0 spec/swagger_v2/host.rb
grape-swagger-0.21.0 spec/swagger_v2/host.rb
grape-swagger-0.20.3 spec/swagger_v2/host.rb