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-1.4.1 spec/configured_base_uri_spec.rb
shutl_resource-1.4.0 spec/configured_base_uri_spec.rb
shutl_resource-1.3.6 spec/configured_base_uri_spec.rb
shutl_resource-1.3.5 spec/configured_base_uri_spec.rb
shutl_resource-1.3.4 spec/configured_base_uri_spec.rb
shutl_resource-1.3.3 spec/configured_base_uri_spec.rb
shutl_resource-1.3.2 spec/configured_base_uri_spec.rb
shutl_resource-1.3.1 spec/configured_base_uri_spec.rb
shutl_resource-1.3.0 spec/configured_base_uri_spec.rb
shutl_resource-1.2.0 spec/configured_base_uri_spec.rb
shutl_resource-1.1.1 spec/configured_base_uri_spec.rb
shutl_resource-1.1.0 spec/configured_base_uri_spec.rb
shutl_resource-1.0.0 spec/configured_base_uri_spec.rb
shutl_resource-0.11.4 spec/configured_base_uri_spec.rb
shutl_resource-0.11.3 spec/configured_base_uri_spec.rb
shutl_resource-0.11.2 spec/configured_base_uri_spec.rb
shutl_resource-0.11.1 spec/configured_base_uri_spec.rb
shutl_resource-0.11.0 spec/configured_base_uri_spec.rb
shutl_resource-0.10.6 spec/configured_base_uri_spec.rb
shutl_resource-0.10.5 spec/configured_base_uri_spec.rb