Sha256: 50284cf6b7ebf59dfdead51b01d6ed2d1bc15527f85df320b92fa2ab0d55fe02

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require_relative '../test_helper'
require 'hyperclient/entry_point'

module Hyperclient
  describe EntryPoint do
    let(:entry_point) do
      EntryPoint.new 'http://my.api.org'
    end

    describe 'connection' do
      it 'creates a Faraday connection with the entry point url' do
        entry_point.connection.url_prefix.to_s.must_equal 'http://my.api.org/'
      end

      it 'creates a Faraday connection with the default headers' do
        entry_point.headers['Content-Type'].must_equal 'application/json'
        entry_point.headers['Accept'].must_equal 'application/json'
      end

      it 'creates a Faraday connection with the default block' do
        handlers = entry_point.connection.builder.handlers
        handlers.must_include FaradayMiddleware::FollowRedirects
        handlers.must_include FaradayMiddleware::EncodeJson
        handlers.must_include FaradayMiddleware::ParseJson
        handlers.must_include Faraday::Adapter::NetHttp
      end
    end

    describe 'initialize' do
      it 'sets a Link with the entry point url' do
        entry_point._url.must_equal 'http://my.api.org'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hyperclient-0.5.0 test/hyperclient/entry_point_test.rb