Sha256: c2a0eb5475f7f702a65de1f0554dff2be16931b52100876d4e733dfe7b79206c

Contents?: true

Size: 916 Bytes

Versions: 6

Compression:

Stored size: 916 Bytes

Contents

require_relative '../test_helper'
require 'hyperclient/resource_collection'

module Hyperclient
  describe ResourceCollection do
    let(:entry_point) { stub('Entry point', config: {base_uri: '/'}) }

    let(:representation) do
      JSON.parse( File.read('test/fixtures/element.json'))
    end

    let(:resources) do
      ResourceCollection.new(representation['_embedded'], entry_point)
    end

    it 'is a collection' do
      ResourceCollection.ancestors.must_include Collection
    end

    it 'initializes the collection with resources' do
      resources.must_respond_to :author
      resources.must_respond_to :episodes
    end

    it 'returns resource objects for each resource' do
      resources.author.must_be_kind_of Resource
    end

    it 'also builds arras of resource' do
      resources.episodes.must_be_kind_of Array
      resources.episodes.first.must_be_kind_of Resource
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyperclient-0.4.0 test/hyperclient/resource_collection_test.rb
hyperclient-0.3.2 test/hyperclient/resource_collection_test.rb
hyperclient-0.3.1 test/hyperclient/resource_collection_test.rb
hyperclient-0.3.0 test/hyperclient/resource_collection_test.rb
hyperclient-0.2.0 test/hyperclient/resource_collection_test.rb
hyperclient-0.1.0 test/hyperclient/resource_collection_test.rb