Sha256: fd7fdd7abdd7a8f179652484fb78f52fcf8f423bdfa14736778f9d9939315c20

Contents?: true

Size: 897 Bytes

Versions: 3

Compression:

Stored size: 897 Bytes

Contents

require_relative '../test_helper'
require 'hyperclient/resource_factory'

module Hyperclient
  describe ResourceFactory do
    let(:resource) do
      ResourceFactory.resource('/path/to/resource')
    end

    before do
      Hyperclient::Resource.entry_point = 'http://myapi.org'
    end

    describe 'resource' do
      it 'creates a new resource when is not present in the identity map' do
        resource = ResourceFactory.resource('/path/to/resource')

        resource.url.must_include '/path/to/resource'
      end

      it 'returns the resource when is already present in the identity map' do
        new_resource = ResourceFactory.resource('/path/to/resource')

        new_resource.object_id.must_equal resource.object_id
      end

      it 'raises if the given url is nil' do
        proc { ResourceFactory.resource(nil) }.must_raise MissingURLException
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyperclient-0.0.8 test/hyperclient/resource_factory_test.rb
hyperclient-0.0.7 test/hyperclient/resource_factory_test.rb
hyperclient-0.0.6 test/hyperclient/resource_factory_test.rb