Sha256: 906644a95d4177588b8e696a25682f1c14d516c201fda93bdce06010f713fd26

Contents?: true

Size: 1.05 KB

Versions: 21

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

21 entries across 21 versions & 1 rubygems

Version Path
restful_resource-2.18.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.18.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.17.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.16.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.15.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.14.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.13.4 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.13.3 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.13.2 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.13.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.13.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.12.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.12.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.11.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.10.3 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.10.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.10.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.9.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.8.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.7.0 spec/restful_resource/base_authorization_spec.rb