Sha256: 171d73b228209e1c3cdd669758601a3428d6a4424684e0a35a9113490bf807ce

Contents?: true

Size: 1.06 KB

Versions: 34

Compression:

Stored size: 1.06 KB

Contents

require_relative '../spec_helper'

describe RestfulResource::Base, 'authorization' do
  before :each 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 "should use two different http instances" do
    expect(FirstTest.send(:http)).not_to equal(SecondTest.send(:http))
  end

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

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

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
restful_resource-2.3.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.8 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.7 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.6 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.5 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.4 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.3 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.2 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.2.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.0.2 spec/restful_resource/base_authorization_spec.rb
restful_resource-2.0.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.6.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.5.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.4.3 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.4.2 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.4.1 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.4.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.3.0 spec/restful_resource/base_authorization_spec.rb
restful_resource-1.2.2 spec/restful_resource/base_authorization_spec.rb