Sha256: 56a283abad78772a03efdfdc511610f78542b7648b65ccb6aa4ff7f88f76413c

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe 'client requester' do
  before do
    allow(RestClient).to receive(:send)
    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).to have_received(:send)
                            .with(:get, 'http://www.example.com/foo', { content_type: :json })
  end

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

    expect(RestClient).to have_received(:send)
                            .with(:get, 'http://www.example.com/foo', { content_type: 'application/x-www-form-urlencoded' })
  end

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

    get '/foo'

    expect(RestClient).to have_received(:send)
                            .with(:get, 'http://www.example.com/foo', { content_type: 'text/plain' })
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
airborne-0.3.0 spec/airborne/client_requester_spec.rb
airborne-0.2.13 spec/airborne/client_requester_spec.rb
airborne-0.2.12 spec/airborne/client_requester_spec.rb
airborne-0.2.11 spec/airborne/client_requester_spec.rb
airborne-0.2.10 spec/airborne/client_requester_spec.rb
airborne-0.2.9 spec/airborne/client_requester_spec.rb
airborne-0.2.8 spec/airborne/client_requester_spec.rb
airborne-0.2.7 spec/airborne/client_requester_spec.rb
airborne-0.2.6 spec/airborne/client_requester_spec.rb
airborne-0.2.5 spec/airborne/client_requester_spec.rb
airborne-0.2.4 spec/airborne/client_requester_spec.rb
airborne-0.2.3 spec/airborne/client_requester_spec.rb