Sha256: 602c64fcdc1e01f9a933f2053d68e072f5d42960077675cd30d0abcadfb1b7ba

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

require 'spec_helper'
require 'hi/request'

describe Hi::Request do
  describe '#to_h' do
    it 'includes all the important bits' do
      hash = described_class.new({}).to_h

      expect(hash).to include :headers
      expect(hash).to include :body
      expect(hash).to include :url
    end
  end

  describe '#headers' do
    it 'returns all headers from the environment' do
      headers = {
        'HTTP_MY_HEADER'       => 'is present',
        'HTTP_MY_OTHER_HEADER' => 'is also present',
      }

      request = described_class.new \
        headers.merge('NOT_A_HEADER' => 'is not present')

      expect(request.headers).to eq headers
    end
  end

  describe '#host' do
    it 'returns the host passed in the environment' do
      host = 'amazing.dev'

      request = described_class.new('HTTP_HOST' => host)

      expect(request.host).to eq host
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hi-1.2.2 spec/hi/request_spec.rb
hi-1.2.1 spec/hi/request_spec.rb
hi-1.2.0 spec/hi/request_spec.rb
hi-1.1.1 spec/hi/request_spec.rb