Sha256: 57c9b8743bbeebc7e8d9db4a6d3685c573d2f204e1b0c82a873aee7630c74d52

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'openssl'

describe 'client requester' do
  before do
    allow(RestClient::Request).to receive(:execute)
    RSpec::Mocks.space.proxy_for(self).remove_stub_if_present(:get)
  end

  after do
    allow(RestClient).to receive(:send).and_call_original
    Airborne.configure { |config| config.headers =  {} }
  end

  it 'should set :content_type to :json by default' do
    get '/foo'

    expect(RestClient::Request).to have_received(:execute)
                            .with(:method => :get, :url => 'http://www.example.com/foo', 
                            :headers => { content_type: :json }, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
  end

  it 'should override headers with option[:headers]' do
    get '/foo', { content_type: 'application/x-www-form-urlencoded' }

    expect(RestClient::Request).to have_received(:execute)
                            .with(:method => :get, :url => 'http://www.example.com/foo', 
                            :headers => { content_type: 'application/x-www-form-urlencoded' }, 
                            :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
  end

  it 'should override headers with airborne config headers' do
    Airborne.configure { |config| config.headers = { content_type: 'text/plain' } }

    get '/foo'

    expect(RestClient::Request).to have_received(:execute)
                            .with(:method => :get, :url => 'http://www.example.com/foo', 
                            :headers => { content_type: 'text/plain' },
                            :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hops-airborne-0.2.16 spec/airborne/client_requester_spec.rb
hops-airborne-0.2.15 spec/airborne/client_requester_spec.rb