Sha256: cd0f1125fd3e8713158699a4e52771e6c232fd7422e2810b37b6cd91d47d5d89

Contents?: true

Size: 1.33 KB

Versions: 40

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe TestConfiguredBaseUriResource do
  let(:headers) do
    {'Accept' => 'application/json',
     'Content-Type' => 'application/json',
     'Authorization' => 'Bearer some auth'}
  end

  before do
    Shutl::Resource.configure do |config|
      config.base_uri = "http://configured"
    end
  end

  after do
    Shutl::Resource.configure do |config|
      config.base_uri = nil
    end
  end

  context "uses the configured base uri if present" do
    before do
      @request = stub_request(:get, 'http://configured/test_configured_base_uri_resources/a').
        to_return(:status  => 200,
                  :body    => '{"test_configured_base_uri_resource": { "a": "a", "b": 2 }}',
                  :headers => headers)
    end

    it 'should query the endpoint' do
      TestConfiguredBaseUriResource.find('a', auth: "some auth")

      @request.should have_been_requested
    end
  end

  context "doesnt override a resources declared base uri" do
    before do
      @request = stub_request(:get, 'http://host/test_rests/a').
        to_return(:status  => 200,
                  :body    => '{"test_rest": { "a": "a", "b": 2 }}',
                  :headers => headers)
    end

    it 'should query the endpoint' do
      TestRest.find('a', auth: "some auth")

      @request.should have_been_requested
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
shutl_resource-2.0.2 spec/configured_base_uri_spec.rb
shutl_resource-2.0.1 spec/configured_base_uri_spec.rb
shutl_resource-2.0.0 spec/configured_base_uri_spec.rb
shutl_resource-1.9.1 spec/configured_base_uri_spec.rb
shutl_resource-1.9.0 spec/configured_base_uri_spec.rb
shutl_resource-1.8.2 spec/configured_base_uri_spec.rb
shutl_resource-1.8.0 spec/configured_base_uri_spec.rb
shutl_resource-1.7.3 spec/configured_base_uri_spec.rb
shutl_resource-1.7.2 spec/configured_base_uri_spec.rb
shutl_resource-1.7.1 spec/configured_base_uri_spec.rb
shutl_resource-1.7.0 spec/configured_base_uri_spec.rb
shutl_resource-1.6.0 spec/configured_base_uri_spec.rb
shutl_resource-1.5.6 spec/configured_base_uri_spec.rb
shutl_resource-1.5.5 spec/configured_base_uri_spec.rb
shutl_resource-1.5.4 spec/configured_base_uri_spec.rb
shutl_resource-1.5.3 spec/configured_base_uri_spec.rb
shutl_resource-1.5.2 spec/configured_base_uri_spec.rb
shutl_resource-1.5.1 spec/configured_base_uri_spec.rb
shutl_resource-1.5.0 spec/configured_base_uri_spec.rb
shutl_resource-1.4.2 spec/configured_base_uri_spec.rb