Sha256: 9127cc2d6ec03d27c3766c4739eff03257b5289532ffc8786f2ae2d9e065ed0d

Contents?: true

Size: 1.84 KB

Versions: 5

Compression:

Stored size: 1.84 KB

Contents

require 'integration/spec_helper'
require 'json'

describe server(:proxy) do
  describe http('http://app.example.com') do
    it "sends GET request with Host header" do
      expect(response.body).to include('app')
    end
  end

  describe http('http://static.example.com') do
    it "sends GET request with Host header" do
      expect(response.body).to include('static')
    end
  end

  # If accept-encoding is not specified explicitly,
  # Net::HTTP (faraday's default adapter) sends request with accept-encoding=gzip
  # and inflate response as gzip automaticallly
  describe http('http://static.example.com', headers: {"Accept-Encoding" => "gzip"}) do
    it "gets response compressed by gzip" do
      expect(response.headers['content-encoding']).to eq('gzip')
    end
  end
end

describe server(:app) do
  let(:body_as_json) { JSON.parse(response.body) }

  describe http('http://app.example.com') do
    it "sends GET request" do
      expect(response.body).to include('app')
    end
  end

  describe http('http://app.example.com/path/to/resource', params: {'foo' => 'bar'}, headers: {'USER' => 'VALUE'}) do
    it "sends GET request with params" do
      expect(body_as_json['method']).to eq('GET')
      expect(body_as_json['path']).to eq('/path/to/resource')
      expect(body_as_json['params']).to eq({"foo" => "bar"})
      expect(body_as_json['headers']['USER']).not_to be_empty
      expect(body_as_json['headers']['USER']).to eq('VALUE')
    end
  end

  describe http('http://app.example.com', method: :post, params: {'foo' => 'bar'}, headers: {'USER' => 'VALUE'}) do
    it "sends POST request with params" do
      expect(body_as_json['method']).to eq('POST')
      expect(body_as_json['params']).to eq({"foo" => "bar"})
      expect(body_as_json['headers']['USER']).not_to be_empty
      expect(body_as_json['headers']['USER']).to eq('VALUE')
    end
  end
end


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
infrataster-0.1.11 spec/integration/http_spec.rb
infrataster-0.1.10 spec/integration/http_spec.rb
infrataster-0.1.9 spec/integration/http_spec.rb
infrataster-0.1.8 spec/integration/http_spec.rb
infrataster-0.1.7 spec/integration/http_spec.rb