Sha256: a9382abe7c1e3c7156d83dce9609c2584ad9ec2d6f743bc7dadefcb778fe106c

Contents?: true

Size: 897 Bytes

Versions: 8

Compression:

Stored size: 897 Bytes

Contents

require_relative '../test_helper'
require 'hyperclient'

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

8 entries across 8 versions & 1 rubygems

Version Path
hyperclient-0.9.3 test/hyperclient/resource_collection_test.rb
hyperclient-0.9.1 test/hyperclient/resource_collection_test.rb
hyperclient-0.9.0 test/hyperclient/resource_collection_test.rb
hyperclient-0.8.6 test/hyperclient/resource_collection_test.rb
hyperclient-0.8.5 test/hyperclient/resource_collection_test.rb
hyperclient-0.8.4 test/hyperclient/resource_collection_test.rb
hyperclient-0.8.3 test/hyperclient/resource_collection_test.rb
hyperclient-0.8.2 test/hyperclient/resource_collection_test.rb