Sha256: 216aa5cd724dd95193322de5989b661ddfbb9bed78e67be01beaa33ed8f4f31b

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

require_relative '../spec_helper'

describe RestfulResource::Base, 'authorization' do
  before do
    class FirstClient < RestfulResource::Base
    end

    class SecondClient < RestfulResource::Base
    end

    class NotConfiguredClient < RestfulResource::Base; end

    class FirstTest < FirstClient
      resource_path 'test'
    end

    class SecondTest < SecondClient
      resource_path 'test'
    end

    FirstClient.configure(base_url: 'http://api.carwow.co.uk/api/first')
    SecondClient.configure(base_url: 'http://api.carwow.co.uk/api/second',
                           username: 'test_user',
                           password: 'test_pass'
                          )
  end

  it 'uses two different http instances' do
    expect(FirstTest.send(:http)).not_to equal(SecondTest.send(:http))
  end

  it 'has same http auth on superclass' do
    expect(SecondTest.send(:http)).to equal(SecondClient.send(:http))
  end

  it 'raises exception if base_url is not set' do
    expect { NotConfiguredClient.send(:base_url) }.to raise_error 'Base url missing'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
restful_resource-2.5.3 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.5.2 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.5.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.5.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.4.0 spec/restful_resource/base_authorization_spec.rb